1 Description
:= Static runtime libraries for clang
/Linux.
9 # We don't currently have any general purpose way to target architectures other
10 # than the compiler defaults (because there is no generalized way to invoke
11 # cross compilers). For now, we just find the target architecture of the
12 # compiler and only define configurations we know that compiler can generate.
13 CompilerTargetTriple
:= $(shell \
14 LANG
=C
$(CC
) -v
2>&1 | grep
'Target:' | cut
-d
' ' -f2
)
15 ifeq ($(CompilerTargetTriple
),)
16 $(error
"unable to infer compiler target triple for $(CC)")
19 # Only define configs if we detected a linux target.
20 ifneq ($(findstring -linux-
,$(CompilerTargetTriple
)),)
22 # Define configs only if arch in triple is i386 or x86_64
23 CompilerTargetArch
:= $(firstword $(subst -, ,$(CompilerTargetTriple
)))
24 ifeq ($(call contains
,i386 x86_64
,$(CompilerTargetArch
)),true
)
26 # TryCompile compiler source flags
27 # Returns exit code of running a compiler invocation.
31 for flag in
$(3); do \
32 cflags="$$cflags $$flag"; \
34 $(1) $$cflags $(2) -o
/dev
/null
> /dev
/null
2> /dev
/null
; \
37 test_source
= $(ProjSrcRoot
)/make
/platform
/clang_linux_test_input.c
38 ifeq ($(CompilerTargetArch
),i386
)
39 SupportedArches
:= i386
40 ifeq ($(call TryCompile
,$(CC
),$(test_source
),-m64
),0)
41 SupportedArches
+= x86_64
44 SupportedArches
:= x86_64
45 ifeq ($(call TryCompile
,$(CC
),$(test_source
),-m32
),0)
46 SupportedArches
+= i386
50 # Build runtime libraries for i386.
51 ifeq ($(call contains
,$(SupportedArches
),i386
),true
)
52 Configs
+= full-i386 profile-i386 san-i386 asan-i386 ubsan-i386 ubsan_cxx-i386
53 Arch.full-i386
:= i386
54 Arch.profile-i386
:= i386
56 Arch.asan-i386
:= i386
57 Arch.ubsan-i386
:= i386
58 Arch.ubsan_cxx-i386
:= i386
61 # Build runtime libraries for x86_64.
62 ifeq ($(call contains
,$(SupportedArches
),x86_64
),true
)
63 Configs
+= full-x86_64 profile-x86_64 san-x86_64 asan-x86_64 tsan-x86_64 \
64 msan-x86_64 ubsan-x86_64 ubsan_cxx-x86_64 dfsan-x86_64 lsan-x86_64
65 Arch.full-x86_64
:= x86_64
66 Arch.profile-x86_64
:= x86_64
67 Arch.san-x86_64
:= x86_64
68 Arch.asan-x86_64
:= x86_64
69 Arch.tsan-x86_64
:= x86_64
70 Arch.msan-x86_64
:= x86_64
71 Arch.ubsan-x86_64
:= x86_64
72 Arch.ubsan_cxx-x86_64
:= x86_64
73 Arch.dfsan-x86_64
:= x86_64
74 Arch.lsan-x86_64
:= x86_64
79 ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR
),)
80 Configs
+= asan-arm-android
81 Arch.asan-arm-android
:= arm-android
88 CFLAGS
:= -Wall
-Werror
-O3
-fomit-frame-pointer
89 SANITIZER_CFLAGS
:= -std
=c
++11 -fPIE
-fno-builtin
-gline-tables-only
91 CFLAGS.full-i386
:= $(CFLAGS
) -m32
92 CFLAGS.full-x86_64
:= $(CFLAGS
) -m64
93 CFLAGS.profile-i386
:= $(CFLAGS
) -m32
94 CFLAGS.profile-x86_64
:= $(CFLAGS
) -m64
95 CFLAGS.san-i386
:= $(CFLAGS
) -m32
$(SANITIZER_CFLAGS
) -fno-rtti
96 CFLAGS.san-x86_64
:= $(CFLAGS
) -m64
$(SANITIZER_CFLAGS
) -fno-rtti
97 CFLAGS.asan-i386
:= $(CFLAGS
) -m32
$(SANITIZER_CFLAGS
) -fno-rtti
98 CFLAGS.asan-x86_64
:= $(CFLAGS
) -m64
$(SANITIZER_CFLAGS
) -fno-rtti
99 CFLAGS.tsan-x86_64
:= $(CFLAGS
) -m64
$(SANITIZER_CFLAGS
) -fno-rtti
100 CFLAGS.msan-x86_64
:= $(CFLAGS
) -m64
$(SANITIZER_CFLAGS
) -fno-rtti
101 CFLAGS.ubsan-i386
:= $(CFLAGS
) -m32
$(SANITIZER_CFLAGS
) -fno-rtti
102 CFLAGS.ubsan-x86_64
:= $(CFLAGS
) -m64
$(SANITIZER_CFLAGS
) -fno-rtti
103 CFLAGS.ubsan_cxx-i386
:= $(CFLAGS
) -m32
$(SANITIZER_CFLAGS
)
104 CFLAGS.ubsan_cxx-x86_64
:= $(CFLAGS
) -m64
$(SANITIZER_CFLAGS
)
105 CFLAGS.dfsan-x86_64
:= $(CFLAGS
) -m64
$(SANITIZER_CFLAGS
)
106 CFLAGS.lsan-x86_64
:= $(CFLAGS
) -m64
$(SANITIZER_CFLAGS
) -fno-rtti
108 SHARED_LIBRARY.asan-arm-android
:= 1
109 ANDROID_COMMON_FLAGS
:= -target arm-linux-androideabi \
110 --sysroot
=$(LLVM_ANDROID_TOOLCHAIN_DIR
)/sysroot \
111 -B
$(LLVM_ANDROID_TOOLCHAIN_DIR
)
112 CFLAGS.asan-arm-android
:= $(CFLAGS
) -fPIC
-fno-builtin \
113 $(ANDROID_COMMON_FLAGS
) -fno-rtti \
114 -I
$(ProjSrcRoot
)/android
/include
115 LDFLAGS.asan-arm-android
:= $(LDFLAGS
) $(ANDROID_COMMON_FLAGS
) -ldl
-lm
-llog \
116 -lstdc
++ -Wl
,-soname
=libclang_rt.asan-arm-android.so
-Wl
,-z
,defs
118 # Use our stub SDK as the sysroot to support more portable building. For now we
119 # just do this for the core module, because the stub SDK doesn't have
120 # enough support to build the sanitizers or profile runtimes.
121 CFLAGS.full-i386
+= --sysroot
=$(ProjSrcRoot
)/SDKs
/linux
122 CFLAGS.full-x86_64
+= --sysroot
=$(ProjSrcRoot
)/SDKs
/linux
124 FUNCTIONS.full-i386
:= $(CommonFunctions
) $(ArchFunctions.i386
)
125 FUNCTIONS.full-x86_64
:= $(CommonFunctions
) $(ArchFunctions.x86_64
)
126 FUNCTIONS.profile-i386
:= GCDAProfiling
127 FUNCTIONS.profile-x86_64
:= GCDAProfiling
128 FUNCTIONS.san-i386
:= $(SanitizerCommonFunctions
)
129 FUNCTIONS.san-x86_64
:= $(SanitizerCommonFunctions
)
130 FUNCTIONS.asan-i386
:= $(AsanFunctions
) $(InterceptionFunctions
) \
131 $(SanitizerCommonFunctions
)
132 FUNCTIONS.asan-x86_64
:= $(AsanFunctions
) $(InterceptionFunctions
) \
133 $(SanitizerCommonFunctions
) $(LsanCommonFunctions
)
134 FUNCTIONS.asan-arm-android
:= $(AsanFunctions
) $(InterceptionFunctions
) \
135 $(SanitizerCommonFunctions
)
136 FUNCTIONS.tsan-x86_64
:= $(TsanFunctions
) $(InterceptionFunctions
) \
137 $(SanitizerCommonFunctions
)
138 FUNCTIONS.msan-x86_64
:= $(MsanFunctions
) $(InterceptionFunctions
) \
139 $(SanitizerCommonFunctions
)
140 FUNCTIONS.ubsan-i386
:= $(UbsanFunctions
)
141 FUNCTIONS.ubsan-x86_64
:= $(UbsanFunctions
)
142 FUNCTIONS.ubsan_cxx-i386
:= $(UbsanCXXFunctions
)
143 FUNCTIONS.ubsan_cxx-x86_64
:= $(UbsanCXXFunctions
)
144 FUNCTIONS.dfsan-x86_64
:= $(DfsanFunctions
) $(SanitizerCommonFunctions
)
145 FUNCTIONS.lsan-x86_64
:= $(LsanFunctions
) $(InterceptionFunctions
) \
146 $(SanitizerCommonFunctions
)
148 # Always use optimized variants.
151 # We don't need to use visibility hidden on Linux.
152 VISIBILITY_HIDDEN
:= 0
154 SHARED_LIBRARY_SUFFIX
:= so