clang_linux.mk revision 0d49904d50fc42b411c396c472ce70f8e4575f99
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
50endif
51
52###
53
54CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
55
56CFLAGS.full-i386 := $(CFLAGS) -m32
57CFLAGS.full-x86_64 := $(CFLAGS) -m64
58CFLAGS.profile-i386 := $(CFLAGS) -m32
59CFLAGS.profile-x86_64 := $(CFLAGS) -m64
60CFLAGS.asan-i386 := $(CFLAGS) -m32
61CFLAGS.asan-x86_64 := $(CFLAGS) -m64
62
63# Use our stub SDK as the sysroot to support more portable building. For now we
64# just do this for the non-ASAN modules, because the stub SDK doesn't have
65# enough support to build ASAN.
66CFLAGS.full-i386 += --sysroot=$(ProjSrcRoot)/SDKs/linux
67CFLAGS.full-x86_64 += --sysroot=$(ProjSrcRoot)/SDKs/linux
68CFLAGS.profile-i386 += --sysroot=$(ProjSrcRoot)/SDKs/linux
69CFLAGS.profile-x86_64 += --sysroot=$(ProjSrcRoot)/SDKs/linux
70
71FUNCTIONS.full-i386 := $(CommonFunctions) $(ArchFunctions.i386)
72FUNCTIONS.full-x86_64 := $(CommonFunctions) $(ArchFunctions.x86_64)
73FUNCTIONS.profile-i386 := GCDAProfiling
74FUNCTIONS.profile-x86_64 := GCDAProfiling
75FUNCTIONS.asan-i386 := $(AsanFunctions) $(InterceptionFunctions)
76FUNCTIONS.asan-x86_64 := $(AsanFunctions) $(InterceptionFunctions)
77
78# Always use optimized variants.
79OPTIMIZED := 1
80
81# We don't need to use visibility hidden on Linux.
82VISIBILITY_HIDDEN := 0
83