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 += builtins-i386 profile-i386
53 Arch.builtins-i386 := i386
54 Arch.profile-i386 := i386
57 # Build runtime libraries for x86_64.
58 ifeq ($(call contains,$(SupportedArches),x86_64),true)
59 Configs += builtins-x86_64 profile-x86_64
60 Arch.builtins-x86_64 := x86_64
61 Arch.profile-x86_64 := x86_64
70 CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
72 CFLAGS.builtins-i386 := $(CFLAGS) -m32
73 CFLAGS.builtins-x86_64 := $(CFLAGS) -m64
74 CFLAGS.profile-i386 := $(CFLAGS) -m32
75 CFLAGS.profile-x86_64 := $(CFLAGS) -m64
77 FUNCTIONS.builtins-i386 := $(CommonFunctions) $(ArchFunctions.i386)
78 FUNCTIONS.builtins-x86_64 := $(CommonFunctions) $(ArchFunctions.x86_64)
79 FUNCTIONS.profile-i386 := GCDAProfiling InstrProfiling InstrProfilingBuffer \
80 InstrProfilingFile InstrProfilingPlatformOther \
81 InstrProfilingRuntime InstrProfilingUtil \
82 InstrProfilingWriter InstrProfilingValue
83 FUNCTIONS.profile-x86_64 := $(FUNCTIONS.profile-i386)
85 # Always use optimized variants.
88 # We don't need to use visibility hidden on Linux.
89 VISIBILITY_HIDDEN := 0
91 SHARED_LIBRARY_SUFFIX := so