Skip to contentSkip to conversation

xen/build: Fix build with Clang

PATCH In review Andrew Cooper 3 participants 6 messages Apr 7, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/build: Fix build with Clang

c/s 607044bf9 "build: avoid putting local absolute symbols in symbol tables" breaks the build with Clang, as the command line argument isn't understood.

Clang does not appear to have any equivielent option, and already has outstanding issues with duplicate symbols. Excluding this option makes the problem no worse.

---
CC: Jan Beulich <[email protected]>

The clang build already has many duplicate symbols for some reason I have yet to identify, e.g.

Duplicate symbol 'asid.c#get_cpu_info' (ffff82d0801e6840 != ffff82d0801c8190) Duplicate symbol 'ats.c#__list_add' (ffff82d08015b900 != ffff82d0801546a0) Duplicate symbol 'common.c#clear_bit' (ffff82d080213560 != ffff82d0801baf10) Duplicate symbol 'common.c#constant_test_bit' (ffff82d080213550 != ffff82d0801ba750) Duplicate symbol 'common.c#cpumask_check' (ffff82d080218c50 != ffff82d0801baf20) Duplicate symbol 'common.c#cpumask_clear_cpu' (ffff82d080214990 != ffff82d0801bae40) Duplicate symbol 'common.c#get_cpu_info' (ffff82d080212210 != ffff82d0801bad20)

The resulting binary does function. Someone with more time can investigate making symbol handling work better with Clang

---
 xen/Rules.mk | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
xen/Rules.mk +7 -1
index d4dffde..7183d69 100644
@@ -50,9 +50,15 @@ ALL_OBJS-$(CONFIG_X86)   += $(BASEDIR)/crypto/built_in.o
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
 CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
-CFLAGS += -Wa,--strip-local-absolute
 CFLAGS += '-D__OBJECT_FILE__="$@"'
 
+ifneq ($(clang),y)
+# Clang doesn't understand this command line argument, and doesn't appear to
+# have an suitable alternative.  The resulting compiled binary does function,
+# but has an excessively large symbol table.
+CFLAGS += -Wa,--strip-local-absolute
+endif
+
 CFLAGS-$(verbose)       += -DVERBOSE
 CFLAGS-$(crash_debug)   += -DCRASH_DEBUG
 CFLAGS-$(perfc)         += -DPERF_COUNTERS
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 20:46, <[email protected]> wrote:

The clang build already has many duplicate symbols for some reason I have yet to identify, e.g.

Duplicate symbol 'asid.c#get_cpu_info' (ffff82d0801e6840 != ffff82d0801c8190) Duplicate symbol 'ats.c#__list_add' (ffff82d08015b900 != ffff82d0801546a0) Duplicate symbol 'common.c#clear_bit' (ffff82d080213560 != ffff82d0801baf10) Duplicate symbol 'common.c#constant_test_bit' (ffff82d080213550 != ffff82d0801ba750) Duplicate symbol 'common.c#cpumask_check' (ffff82d080218c50 != ffff82d0801baf20) Duplicate symbol 'common.c#cpumask_clear_cpu' (ffff82d080214990 != ffff82d0801bae40) Duplicate symbol 'common.c#get_cpu_info' (ffff82d080212210 != ffff82d0801bad20)

Quoted 2 lines

The resulting binary does function. Someone with more time can investigate making symbol handling work better with Clang

I'd guess that's because they don't inline functions as aggressively as gcc does.

Quoted 5 lines
xen/Rules.mk +0 -0
@@ -50,9 +50,15 @@ ALL_OBJS-$(CONFIG_X86)   += $(BASEDIR)/crypto/built_in.o
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith

xen/Rules.mk ALL_OBJS-$(CONFIG_X86) += $(BASEDIR)/crypto/built_in.o · line 60

Quoted 10 lines
xen/Rules.mk +6 -1
 CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
-CFLAGS += -Wa,--strip-local-absolute
 CFLAGS += '-D__OBJECT_FILE__="$@"'
 
+ifneq ($(clang),y)
+# Clang doesn't understand this command line argument, and doesn't appear to
+# have an suitable alternative.  The resulting compiled binary does function,
+# but has an excessively large symbol table.
+CFLAGS += -Wa,--strip-local-absolute
+endif

Well, that's the brute force undo-it-altogether-for-clang approach that I think Doug had also considered. You may have seen the discussion (on irc iirc) - I'd really like to see the option still getting passed to gas (for all the .S files) even when using clang. Would that really be hard to arrange for?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 26 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 20:46, <[email protected]> wrote:

The clang build already has many duplicate symbols for some reason I have yet to identify, e.g.

Duplicate symbol 'asid.c#get_cpu_info' (ffff82d0801e6840 != ffff82d0801c8190) Duplicate symbol 'ats.c#__list_add' (ffff82d08015b900 != ffff82d0801546a0) Duplicate symbol 'common.c#clear_bit' (ffff82d080213560 != ffff82d0801baf10) Duplicate symbol 'common.c#constant_test_bit' (ffff82d080213550 != ffff82d0801ba750) Duplicate symbol 'common.c#cpumask_check' (ffff82d080218c50 != ffff82d0801baf20) Duplicate symbol 'common.c#cpumask_clear_cpu' (ffff82d080214990 != ffff82d0801bae40) Duplicate symbol 'common.c#get_cpu_info' (ffff82d080212210 != ffff82d0801bad20)

Quoted 2 lines

The resulting binary does function. Someone with more time can investigate making symbol handling work better with Clang

I'd guess that's because they don't inline functions as aggressively as gcc does.

Quoted 9 lines
xen/Rules.mk +0 -1
@@ -50,9 +50,15 @@ ALL_OBJS-$(CONFIG_X86)   += $(BASEDIR)/crypto/built_in.o
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
 CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
-CFLAGS += -Wa,--strip-local-absolute
 CFLAGS += '-D__OBJECT_FILE__="$@"'
 
Quoted 11 lines

xen/Rules.mk ALL_OBJS-$(CONFIG_X86) += $(BASEDIR)/crypto/built_in.o · line 60

Quoted 6 lines
xen/Rules.mk +6 -0
+ifneq ($(clang),y)
+# Clang doesn't understand this command line argument, and doesn't appear to
+# have an suitable alternative.  The resulting compiled binary does function,
+# but has an excessively large symbol table.
+CFLAGS += -Wa,--strip-local-absolute
+endif

Well, that's the brute force undo-it-altogether-for-clang approach that I think Doug had also considered. You may have seen the discussion (on irc iirc) - I'd really like to see the option still getting passed to gas (for all the .S files) even when using clang. Would that really be hard to arrange for?

That won't fix the fact that all the .c files which include cpufeatureset.h also gets the absolute symbols, to allow the alternatives() blocks to compile.

It will complicate the clang build quite a bit, and won't make much of a dent on the symbol table bloat.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 21:16, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 20:46, <[email protected]> wrote:
xen/Rules.mk +0 -1
@@ -50,9 +50,15 @@ ALL_OBJS-$(CONFIG_X86)   += $(BASEDIR)/crypto/built_in.o
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
 CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
-CFLAGS += -Wa,--strip-local-absolute
 CFLAGS += '-D__OBJECT_FILE__="$@"'
 
Quoted 11 lines

xen/Rules.mk ALL_OBJS-$(CONFIG_X86) += $(BASEDIR)/crypto/built_in.o · line 60

Quoted 6 lines
xen/Rules.mk +6 -0
+ifneq ($(clang),y)
+# Clang doesn't understand this command line argument, and doesn't appear to
+# have an suitable alternative.  The resulting compiled binary does function,
+# but has an excessively large symbol table.
+CFLAGS += -Wa,--strip-local-absolute
+endif

Well, that's the brute force undo-it-altogether-for-clang approach that I think Doug had also considered. You may have seen the discussion (on irc iirc) - I'd really like to see the option still getting passed to gas (for all the .S files) even when using clang. Would that really be hard to arrange for?

Quoted 3 lines

That won't fix the fact that all the .c files which include cpufeatureset.h also gets the absolute symbols, to allow the alternatives() blocks to compile.

That's understood.

Quoted 2 lines

It will complicate the clang build quite a bit, and won't make much of a dent on the symbol table bloat.

While this I'm unclear about: Istr Doug mentioning that simply adding the option in suitable for to AFLAGS would do.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
Quoted 26 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 21:16, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 20:46, <[email protected]> wrote:
xen/Rules.mk +0 -1
@@ -50,9 +50,15 @@ ALL_OBJS-$(CONFIG_X86)   += $(BASEDIR)/crypto/built_in.o
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
 CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
-CFLAGS += -Wa,--strip-local-absolute
 CFLAGS += '-D__OBJECT_FILE__="$@"'
 
Quoted 11 lines

xen/Rules.mk ALL_OBJS-$(CONFIG_X86) += $(BASEDIR)/crypto/built_in.o · line 60

Quoted 6 lines
xen/Rules.mk +6 -0
+ifneq ($(clang),y)
+# Clang doesn't understand this command line argument, and doesn't appear to
+# have an suitable alternative.  The resulting compiled binary does function,
+# but has an excessively large symbol table.
+CFLAGS += -Wa,--strip-local-absolute
+endif

Well, that's the brute force undo-it-altogether-for-clang approach that I think Doug had also considered. You may have seen the discussion (on irc iirc) - I'd really like to see the option still getting passed to gas (for all the .S files) even when using clang. Would that really be hard to arrange for?

Quoted 3 lines

That won't fix the fact that all the .c files which include cpufeatureset.h also gets the absolute symbols, to allow the alternatives() blocks to compile.

Quoted 6 lines

That's understood.

Quoted 2 lines

It will complicate the clang build quite a bit, and won't make much of a dent on the symbol table bloat.

While this I'm unclear about: Istr Doug mentioning that simply adding the option in suitable for to AFLAGS would do.

In which case I clearly missed that bit on IRC.

I am happy to defer to Doug's solution if it actually resolves the underlying issue.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw
In reply to Jan Beulich
Quoted 30 lines · Jan Beulich
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 21:16, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 20:46, <[email protected]> wrote:
xen/Rules.mk +0 -1
@@ -50,9 +50,15 @@ ALL_OBJS-$(CONFIG_X86)   += $(BASEDIR)/crypto/built_in.o
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
 CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
-CFLAGS += -Wa,--strip-local-absolute
 CFLAGS += '-D__OBJECT_FILE__="$@"'
 
Quoted 11 lines

xen/Rules.mk ALL_OBJS-$(CONFIG_X86) += $(BASEDIR)/crypto/built_in.o · line 60

Quoted 6 lines
xen/Rules.mk +6 -0
+ifneq ($(clang),y)
+# Clang doesn't understand this command line argument, and doesn't appear to
+# have an suitable alternative.  The resulting compiled binary does function,
+# but has an excessively large symbol table.
+CFLAGS += -Wa,--strip-local-absolute
+endif

Well, that's the brute force undo-it-altogether-for-clang approach that I think Doug had also considered. You may have seen the discussion (on irc iirc) - I'd really like to see the option still getting passed to gas (for all the .S files) even when using clang. Would that really be hard to arrange for?

Quoted 3 lines

That won't fix the fact that all the .c files which include cpufeatureset.h also gets the absolute symbols, to allow the alternatives() blocks to compile.

That's understood.

Quoted 8 lines
Quoted 2 lines

It will complicate the clang build quite a bit, and won't make much of a dent on the symbol table bloat.

While this I'm unclear about: Istr Doug mentioning that simply adding the option in suitable for to AFLAGS would do.

Jan

I was trying to do exactly what you mentioned where we still passed it to gas and didn't pass it to llvm but unfortunately at some point the flags get combined together and passed to llvm and fails.

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel