[llvm-commits] building compiler-rt with -fPIC

Kostya Serebryany kcc at google.com
Mon Dec 12 16:56:58 PST 2011


Hi,

I've just noticed that AddressSanitizer run-time does not work with -pie
because the library is not built with -fPIC (or -fPIE).
This probably applies to other parts of compiler-rt as well.

The simplest fix is to add -fPIC to the compiler-rt build flags (patch
below). Does anyone object?
A more complex alternative would be to build a PIC and non-PIC variants.

Thanks,

--kcc

Index: make/config.mk
===================================================================
--- make/config.mk      (revision 146376)
+++ make/config.mk      (working copy)
@@ -42,4 +42,5 @@

 ###
 # Common compiler options
-COMMON_CXXFLAGS=-fno-exceptions
+COMMON_CXXFLAGS=-fno-exceptions -fPIC
+COMMON_CFLAGS=-fPIC
Index: Makefile
===================================================================
--- Makefile    (revision 146376)
+++ Makefile    (working copy)
@@ -227,7 +227,7 @@
        $(Verb) $(Tmp.CC) $(Tmp.CFLAGS) -c -o $$@ $$<
 $(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.c $(Tmp.Dependencies)
$(Tmp.ObjPath)/.dir
        $(Summary) "  COMPILE:   $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
-       $(Verb) $(Tmp.CC) $(Tmp.CFLAGS) -c -o $$@ $$<
+       $(Verb) $(Tmp.CC) $(Tmp.CFLAGS) -c $(COMMON_CFLAGS) -o $$@ $$<
 $(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.cc $(Tmp.Dependencies)
$(Tmp.ObjPath)/.dir
        $(Summary) "  COMPILE:   $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
        $(Verb) $(Tmp.CC) $(Tmp.CFLAGS) -c $(COMMON_CXXFLAGS) -o $$@ $$<
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111212/74dbc9af/attachment.html>


More information about the llvm-commits mailing list