1Description := Static runtime libraries for clang/Linux. 2 3### 4 5CC := clang 6Arch := unknown 7Configs := 8 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. 13CompilerTargetTriple := $(shell \ 14 LANG=C $(CC) -v 2>&1 | grep 'Target:' | cut -d' ' -f2) 15ifeq ($(CompilerTargetTriple),) 16$(error "unable to infer compiler target triple for $(CC)") 17endif 18 19# Only define configs if we detected a linux target. 20ifneq ($(findstring -linux-,$(CompilerTargetTriple)),) 21 22# Define configs only if arch in triple is i386 or x86_64 23CompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple))) 24ifeq ($(call contains,i386 x86_64,$(CompilerTargetArch)),true) 25 26# TryCompile compiler source flags 27# Returns exit code of running a compiler invocation. 28TryCompile = \ 29 $(shell \ 30 cflags=""; \ 31 for flag in $(3); do \ 32 cflags="$$cflags $$flag"; \ 33 done; \ 34 $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \ 35 echo $$?) 36 37test_source = $(ProjSrcRoot)/make/platform/clang_linux_test_input.c 38ifeq ($(CompilerTargetArch),i386) 39 SupportedArches := i386 40 ifeq ($(call TryCompile,$(CC),$(test_source),-m64),0) 41 SupportedArches += x86_64 42 endif 43else 44 SupportedArches := x86_64 45 ifeq ($(call TryCompile,$(CC),$(test_source),-m32),0) 46 SupportedArches += i386 47 endif 48endif 49 50# Build runtime libraries for i386. 51ifeq ($(call contains,$(SupportedArches),i386),true) 52Configs += builtins-i386 profile-i386 53Arch.builtins-i386 := i386 54Arch.profile-i386 := i386 55endif 56 57# Build runtime libraries for x86_64. 58ifeq ($(call contains,$(SupportedArches),x86_64),true) 59Configs += builtins-x86_64 profile-x86_64 60Arch.builtins-x86_64 := x86_64 61Arch.profile-x86_64 := x86_64 62endif 63 64endif 65 66endif 67 68### 69 70CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer 71 72CFLAGS.builtins-i386 := $(CFLAGS) -m32 73CFLAGS.builtins-x86_64 := $(CFLAGS) -m64 74CFLAGS.profile-i386 := $(CFLAGS) -m32 75CFLAGS.profile-x86_64 := $(CFLAGS) -m64 76 77FUNCTIONS.builtins-i386 := $(CommonFunctions) $(ArchFunctions.i386) 78FUNCTIONS.builtins-x86_64 := $(CommonFunctions) $(ArchFunctions.x86_64) 79FUNCTIONS.profile-i386 := GCDAProfiling InstrProfiling InstrProfilingBuffer \ 80 InstrProfilingFile InstrProfilingPlatformOther \ 81 InstrProfilingRuntime InstrProfilingUtil \ 82 InstrProfilingWriter InstrProfilingValue 83FUNCTIONS.profile-x86_64 := $(FUNCTIONS.profile-i386) 84 85# Always use optimized variants. 86OPTIMIZED := 1 87 88# We don't need to use visibility hidden on Linux. 89VISIBILITY_HIDDEN := 0 90 91SHARED_LIBRARY_SUFFIX := so 92