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 archicture of the compiler 12# and only define configurations we know that compiler can generate. 13CompilerTargetTriple := $(shell \ 14 $(CC) -v 2>&1 | grep 'Target:' | cut -d' ' -f2) 15ifneq ($(DEBUGMAKE),) 16ifeq ($(CompilerTargetTriple),) 17$(error "unable to infer compiler target triple for $(CC)") 18endif 19endif 20 21CompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple))) 22 23# Only define configs if we detected a linux target. 24ifneq ($(findstring -linux-,$(CompilerTargetTriple)),) 25 26# Configurations which just include all the runtime functions. 27ifeq ($(call contains,i386 x86_64,$(CompilerTargetArch)),true) 28Configs += full-i386 full-x86_64 29Arch.full-i386 := i386 30Arch.full-x86_64 := x86_64 31endif 32 33# Configuration for profile runtime. 34ifeq ($(call contains,i386 x86_64,$(CompilerTargetArch)),true) 35Configs += profile-i386 profile-x86_64 36Arch.profile-i386 := i386 37Arch.profile-x86_64 := x86_64 38endif 39 40# Configuration for ASAN runtime. 41ifeq ($(CompilerTargetArch),i386) 42Configs += asan-i386 43Arch.asan-i386 := i386 44endif 45ifeq ($(CompilerTargetArch),x86_64) 46Configs += asan-x86_64 47Arch.asan-x86_64 := x86_64 48endif 49 50# Configuration for TSAN runtime. 51ifeq ($(CompilerTargetArch),x86_64) 52Configs += tsan-x86_64 53Arch.tsan-x86_64 := x86_64 54endif 55 56endif 57 58### 59 60CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer 61 62CFLAGS.full-i386 := $(CFLAGS) -m32 63CFLAGS.full-x86_64 := $(CFLAGS) -m64 64CFLAGS.profile-i386 := $(CFLAGS) -m32 65CFLAGS.profile-x86_64 := $(CFLAGS) -m64 66CFLAGS.asan-i386 := $(CFLAGS) -m32 -fPIE -fno-builtin 67CFLAGS.asan-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin 68CFLAGS.tsan-x86_64 := $(CFLAGS) -m64 -fPIE -fno-builtin 69 70# Use our stub SDK as the sysroot to support more portable building. For now we 71# just do this for the non-ASAN modules, because the stub SDK doesn't have 72# enough support to build ASAN. 73CFLAGS.full-i386 += --sysroot=$(ProjSrcRoot)/SDKs/linux 74CFLAGS.full-x86_64 += --sysroot=$(ProjSrcRoot)/SDKs/linux 75CFLAGS.profile-i386 += --sysroot=$(ProjSrcRoot)/SDKs/linux 76CFLAGS.profile-x86_64 += --sysroot=$(ProjSrcRoot)/SDKs/linux 77 78FUNCTIONS.full-i386 := $(CommonFunctions) $(ArchFunctions.i386) 79FUNCTIONS.full-x86_64 := $(CommonFunctions) $(ArchFunctions.x86_64) 80FUNCTIONS.profile-i386 := GCDAProfiling 81FUNCTIONS.profile-x86_64 := GCDAProfiling 82FUNCTIONS.asan-i386 := $(AsanFunctions) $(InterceptionFunctions) \ 83 $(SanitizerCommonFunctions) 84FUNCTIONS.asan-x86_64 := $(AsanFunctions) $(InterceptionFunctions) \ 85 $(SanitizerCommonFunctions) 86FUNCTIONS.tsan-x86_64 := $(TsanFunctions) $(InterceptionFunctions) \ 87 $(SanitizerCommonFunctions) 88 89# Always use optimized variants. 90OPTIMIZED := 1 91 92# We don't need to use visibility hidden on Linux. 93VISIBILITY_HIDDEN := 0 94