From: Thomas Huth <thuth@redhat.com>
To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Drew Jones <drjones@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
David Hildenbrand <david@redhat.com>,
Janosch Frank <frankja@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>
Subject: [kvm-unit-tests PATCH 5/9] kbuild: fix asm-offset generation to work with clang
Date: Thu, 24 Sep 2020 18:16:08 +0200 [thread overview]
Message-ID: <20200924161612.144549-6-thuth@redhat.com> (raw)
In-Reply-To: <20200924161612.144549-1-thuth@redhat.com>
KBuild abuses the asm statement to write to a file and
clang chokes about these invalid asm statements. Hack it
even more by fooling this is actual valid asm code.
This is an adaption of the Linux kernel commit cf0c3e68aa81f992b0
which in turn is based on a patch for the U-Boot:
http://patchwork.ozlabs.org/patch/375026/
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
lib/kbuild.h | 6 +++---
scripts/asm-offsets.mak | 5 +++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/kbuild.h b/lib/kbuild.h
index ab99db6..79644e5 100644
--- a/lib/kbuild.h
+++ b/lib/kbuild.h
@@ -1,8 +1,8 @@
#ifndef _KBUILD_H_
#define _KBUILD_H_
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
#define OFFSET(sym, str, mem) DEFINE(sym, offsetof(struct str, mem))
-#define COMMENT(x) asm volatile("\n->#" x)
-#define BLANK() asm volatile("\n->" : : )
+#define COMMENT(x) asm volatile("\n.ascii \"->#" x "\"")
+#define BLANK() asm volatile("\n.ascii \"->\"" : : )
#endif
diff --git a/scripts/asm-offsets.mak b/scripts/asm-offsets.mak
index b35da09..7b64162 100644
--- a/scripts/asm-offsets.mak
+++ b/scripts/asm-offsets.mak
@@ -8,10 +8,11 @@
#
define sed-y
- "/^->/{s:->#\(.*\):/* \1 */:; \
+ 's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
+ /^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}"
+ s:->::; p;}'
endef
define make_asm_offsets
--
2.18.2
next prev parent reply other threads:[~2020-09-24 16:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 16:16 [kvm-unit-tests PATCH 0/9] Update travis CI Thomas Huth
2020-09-24 16:16 ` [kvm-unit-tests PATCH 1/9] travis.yml: Update from Bionic to Focal Thomas Huth
2020-09-24 16:16 ` [kvm-unit-tests PATCH 2/9] travis.yml: Rework the x86 64-bit tests Thomas Huth
2020-09-25 6:44 ` Thomas Huth
2020-09-24 16:16 ` [kvm-unit-tests PATCH 3/9] travis.yml: Refresh the x86 32-bit test list Thomas Huth
2020-09-24 16:16 ` [kvm-unit-tests PATCH 4/9] travis.yml: Add the selftest-setup ppc64 test Thomas Huth
2020-09-24 16:16 ` Thomas Huth [this message]
2020-09-24 16:16 ` [kvm-unit-tests PATCH 6/9] arm/pmu: Fix inline assembly for Clang Thomas Huth
2020-09-24 16:16 ` [kvm-unit-tests PATCH 7/9] lib/arm64/spinlock: " Thomas Huth
2020-09-24 16:16 ` [kvm-unit-tests PATCH 8/9] travis.yml: Rework the aarch64 jobs Thomas Huth
2020-09-24 16:16 ` [kvm-unit-tests PATCH 9/9] travis.yml: Update the list of s390x tests Thomas Huth
2020-09-25 9:57 ` Cornelia Huck
2020-09-25 10:09 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200924161612.144549-6-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=drjones@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox