[LLVMdev] Apple's GCC and .s/.S files in llvm-test
Julien Lerouge
jlerouge at apple.com
Fri Mar 21 10:59:09 PDT 2008
Hello,
Apple's GCC does not make the distinction between .s and .S files and
always run the preprocessor. From the man:
| file.s
| Assembler code. Apple's version of GCC runs the preprocessor on these
| files as well as those ending in .S.
|
| file.S
| Assembler code which must be preprocessed.
The problem is that sometimes llc generates comments in the assembly
that look like this for x86:
...
pushl %esi
...
# implicit-def: EDI
...
ret
The comment line is perfectly valid for the assembler, but the
preprocessor does not like it because it tries to interpret it as a
macro... I can see it happening for example if -std=c99 is set in the
CFLAGS (that's the case in SingleSource/Regression/C++) :
$ gcc --std=c99 -o t t.s
t.s:5:4: error: invalid preprocessing directive #implicit
One solution is to force the language to be assembler (and not
assembler-with-cpp) on Darwin, that's what the attached patch does, but
maybe there is a nicer solution ?
Thanks,
julien
--
Julien Lerouge
PGP Key Id: 0xB1964A62
PGP Fingerprint: 392D 4BAD DB8B CE7F 4E5F FA3C 62DB 4AA7 B196 4A62
PGP Public Key from: keyserver.pgp.com
-------------- next part --------------
Index: Makefile.programs
===================================================================
--- Makefile.programs (revision 48557)
+++ Makefile.programs (working copy)
@@ -377,15 +377,25 @@
LLCASSEMBLERFLAGS = -mcpu=v9
endif
+# On darwin, Apple's GCC doesn't make a distinction between file.s and file.S,
+# it always run the preprocessor. One way to disable that is to force the
+# language to be assembler (not assembler-with-cpp).
+FORCEASM =
+ifeq ($(OS),Darwin)
+FORCEASM = -x assembler
+endif
+
# Assemble (and link) an LLVM-linked program using the system assembler...
#
$(PROGRAMS_TO_TEST:%=Output/%.llc): \
Output/%.llc: Output/%.llc.s
- -$(LLVMGCCLD) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) $(TARGET_FLAGS) $(LDFLAGS)
+ -$(LLVMGCCLD) $(FORCEASM) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) \
+ $(TARGET_FLAGS) $(LDFLAGS)
$(PROGRAMS_TO_TEST:%=Output/%.llc-beta): \
Output/%.llc-beta: Output/%.llc-beta.s
- -$(LLVMGCCLD) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) $(TARGET_FLAGS) $(LDFLAGS)
+ -$(LLVMGCCLD) $(FORCEASM) $< -o $@ $(LLCLIBS) $(LLCASSEMBLERFLAGS) \
+ $(TARGET_FLAGS) $(LDFLAGS)
#
More information about the llvm-dev
mailing list