xref: /aosp_15_r20/external/compiler-rt/make/platform/clang_linux.mk (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger RobotDescription := Static runtime libraries for clang/Linux.
2*7c3d14c8STreehugger Robot
3*7c3d14c8STreehugger Robot###
4*7c3d14c8STreehugger Robot
5*7c3d14c8STreehugger RobotCC := clang
6*7c3d14c8STreehugger RobotArch := unknown
7*7c3d14c8STreehugger RobotConfigs :=
8*7c3d14c8STreehugger Robot
9*7c3d14c8STreehugger Robot# We don't currently have any general purpose way to target architectures other
10*7c3d14c8STreehugger Robot# than the compiler defaults (because there is no generalized way to invoke
11*7c3d14c8STreehugger Robot# cross compilers). For now, we just find the target architecture of the
12*7c3d14c8STreehugger Robot# compiler and only define configurations we know that compiler can generate.
13*7c3d14c8STreehugger RobotCompilerTargetTriple := $(shell \
14*7c3d14c8STreehugger Robot	LANG=C $(CC) -v 2>&1 | grep 'Target:' | cut -d' ' -f2)
15*7c3d14c8STreehugger Robotifeq ($(CompilerTargetTriple),)
16*7c3d14c8STreehugger Robot$(error "unable to infer compiler target triple for $(CC)")
17*7c3d14c8STreehugger Robotendif
18*7c3d14c8STreehugger Robot
19*7c3d14c8STreehugger Robot# Only define configs if we detected a linux target.
20*7c3d14c8STreehugger Robotifneq ($(findstring -linux-,$(CompilerTargetTriple)),)
21*7c3d14c8STreehugger Robot
22*7c3d14c8STreehugger Robot# Define configs only if arch in triple is i386 or x86_64
23*7c3d14c8STreehugger RobotCompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple)))
24*7c3d14c8STreehugger Robotifeq ($(call contains,i386 x86_64,$(CompilerTargetArch)),true)
25*7c3d14c8STreehugger Robot
26*7c3d14c8STreehugger Robot# TryCompile compiler source flags
27*7c3d14c8STreehugger Robot# Returns exit code of running a compiler invocation.
28*7c3d14c8STreehugger RobotTryCompile = \
29*7c3d14c8STreehugger Robot  $(shell \
30*7c3d14c8STreehugger Robot    cflags=""; \
31*7c3d14c8STreehugger Robot    for flag in $(3); do \
32*7c3d14c8STreehugger Robot      cflags="$$cflags $$flag"; \
33*7c3d14c8STreehugger Robot    done; \
34*7c3d14c8STreehugger Robot    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
35*7c3d14c8STreehugger Robot    echo $$?)
36*7c3d14c8STreehugger Robot
37*7c3d14c8STreehugger Robottest_source = $(ProjSrcRoot)/make/platform/clang_linux_test_input.c
38*7c3d14c8STreehugger Robotifeq ($(CompilerTargetArch),i386)
39*7c3d14c8STreehugger Robot  SupportedArches := i386
40*7c3d14c8STreehugger Robot  ifeq ($(call TryCompile,$(CC),$(test_source),-m64),0)
41*7c3d14c8STreehugger Robot    SupportedArches += x86_64
42*7c3d14c8STreehugger Robot  endif
43*7c3d14c8STreehugger Robotelse
44*7c3d14c8STreehugger Robot  SupportedArches := x86_64
45*7c3d14c8STreehugger Robot  ifeq ($(call TryCompile,$(CC),$(test_source),-m32),0)
46*7c3d14c8STreehugger Robot    SupportedArches += i386
47*7c3d14c8STreehugger Robot  endif
48*7c3d14c8STreehugger Robotendif
49*7c3d14c8STreehugger Robot
50*7c3d14c8STreehugger Robot# Build runtime libraries for i386.
51*7c3d14c8STreehugger Robotifeq ($(call contains,$(SupportedArches),i386),true)
52*7c3d14c8STreehugger RobotConfigs += builtins-i386 profile-i386
53*7c3d14c8STreehugger RobotArch.builtins-i386 := i386
54*7c3d14c8STreehugger RobotArch.profile-i386 := i386
55*7c3d14c8STreehugger Robotendif
56*7c3d14c8STreehugger Robot
57*7c3d14c8STreehugger Robot# Build runtime libraries for x86_64.
58*7c3d14c8STreehugger Robotifeq ($(call contains,$(SupportedArches),x86_64),true)
59*7c3d14c8STreehugger RobotConfigs += builtins-x86_64 profile-x86_64
60*7c3d14c8STreehugger RobotArch.builtins-x86_64 := x86_64
61*7c3d14c8STreehugger RobotArch.profile-x86_64 := x86_64
62*7c3d14c8STreehugger Robotendif
63*7c3d14c8STreehugger Robot
64*7c3d14c8STreehugger Robotendif
65*7c3d14c8STreehugger Robot
66*7c3d14c8STreehugger Robotendif
67*7c3d14c8STreehugger Robot
68*7c3d14c8STreehugger Robot###
69*7c3d14c8STreehugger Robot
70*7c3d14c8STreehugger RobotCFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
71*7c3d14c8STreehugger Robot
72*7c3d14c8STreehugger RobotCFLAGS.builtins-i386 := $(CFLAGS) -m32
73*7c3d14c8STreehugger RobotCFLAGS.builtins-x86_64 := $(CFLAGS) -m64
74*7c3d14c8STreehugger RobotCFLAGS.profile-i386 := $(CFLAGS) -m32
75*7c3d14c8STreehugger RobotCFLAGS.profile-x86_64 := $(CFLAGS) -m64
76*7c3d14c8STreehugger Robot
77*7c3d14c8STreehugger RobotFUNCTIONS.builtins-i386 := $(CommonFunctions) $(ArchFunctions.i386)
78*7c3d14c8STreehugger RobotFUNCTIONS.builtins-x86_64 := $(CommonFunctions) $(ArchFunctions.x86_64)
79*7c3d14c8STreehugger RobotFUNCTIONS.profile-i386 := GCDAProfiling InstrProfiling InstrProfilingBuffer \
80*7c3d14c8STreehugger Robot                          InstrProfilingFile InstrProfilingPlatformOther \
81*7c3d14c8STreehugger Robot                          InstrProfilingRuntime InstrProfilingUtil \
82*7c3d14c8STreehugger Robot                          InstrProfilingWriter InstrProfilingValue \
83*7c3d14c8STreehugger Robot                          InstrProfilingMerge InstrProfilingMergeFile
84*7c3d14c8STreehugger RobotFUNCTIONS.profile-x86_64 := $(FUNCTIONS.profile-i386)
85*7c3d14c8STreehugger Robot
86*7c3d14c8STreehugger Robot# Always use optimized variants.
87*7c3d14c8STreehugger RobotOPTIMIZED := 1
88*7c3d14c8STreehugger Robot
89*7c3d14c8STreehugger Robot# We don't need to use visibility hidden on Linux.
90*7c3d14c8STreehugger RobotVISIBILITY_HIDDEN := 0
91*7c3d14c8STreehugger Robot
92*7c3d14c8STreehugger RobotSHARED_LIBRARY_SUFFIX := so
93