Skip to contentSkip to conversation

x86emul: avoid assembler warning about .type not taking effect in test harness

PATCH In review Jan Beulich 2 participants 3 messages Jul 14, 2020 – Jul 31, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86emul: avoid assembler warning about .type not taking effect in test harness

gcc re-orders top level blocks by default when optimizing. This re-ordering results in all our .type directives to get emitted to the assembly file first, followed by gcc's. The assembler warns about attempts to change the type of a symbol when it was already set (and when there's no intervening setting to "notype").

---
v2: Refine description to no longer claim a gcc change to be the reason.

tools/tests/x86_emulator/Makefile +5 -0
@@ -295,4 +295,9 @@ x86-emulate.o cpuid.o test_x86_emulator.
 x86-emulate.o: x86_emulate/x86_emulate.c
 x86-emulate.o: HOSTCFLAGS += -D__XEN_TOOLS__
 
+# In order for our custom .type assembler directives to reliably land after
+# gcc's, we need to keep it from re-ordering top-level constructs.
+$(call cc-option-add,HOSTCFLAGS-toplevel,HOSTCC,-fno-toplevel-reorder)
+test_x86_emulator.o: HOSTCFLAGS += $(HOSTCFLAGS-toplevel)
+
 test_x86_emulator.o: $(addsuffix .h,$(TESTCASES)) $(addsuffix -opmask.h,$(OPMASK))
#1 lore raw

Ping: [PATCH v2] x86emul: avoid assembler warning about .type not taking effect in test harness

Quoted 23 lines · Jan Beulich

gcc re-orders top level blocks by default when optimizing. This re-ordering results in all our .type directives to get emitted to the assembly file first, followed by gcc's. The assembler warns about attempts to change the type of a symbol when it was already set (and when there's no intervening setting to "notype").

---
v2: Refine description to no longer claim a gcc change to be the reason.

tools/tests/x86_emulator/Makefile +5 -0
@@ -295,4 +295,9 @@ x86-emulate.o cpuid.o test_x86_emulator.
 x86-emulate.o: x86_emulate/x86_emulate.c
 x86-emulate.o: HOSTCFLAGS += -D__XEN_TOOLS__
 
+# In order for our custom .type assembler directives to reliably land after
+# gcc's, we need to keep it from re-ordering top-level constructs.
+$(call cc-option-add,HOSTCFLAGS-toplevel,HOSTCC,-fno-toplevel-reorder)
+test_x86_emulator.o: HOSTCFLAGS += $(HOSTCFLAGS-toplevel)
+
 test_x86_emulator.o: $(addsuffix .h,$(TESTCASES)) $(addsuffix -opmask.h,$(OPMASK))
Acked-by
#2 lore raw

Re: Ping: [PATCH v2] x86emul: avoid assembler warning about .type not taking effect in test harness

Quoted 8 lines · Jan Beulich
Quoted 7 lines · Jan Beulich

gcc re-orders top level blocks by default when optimizing. This re-ordering results in all our .type directives to get emitted to the assembly file first, followed by gcc's. The assembler warns about attempts to change the type of a symbol when it was already set (and when there's no intervening setting to "notype").