xref: /aosp_15_r20/external/compiler-rt/make/AppleBI.mk (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot
2*7c3d14c8STreehugger Robot#
3*7c3d14c8STreehugger Robot# Make rules to build compiler_rt in Apple B&I infrastructure
4*7c3d14c8STreehugger Robot#
5*7c3d14c8STreehugger Robot
6*7c3d14c8STreehugger Robot# set ProjSrcRoot appropriately
7*7c3d14c8STreehugger RobotProjSrcRoot := $(SRCROOT)
8*7c3d14c8STreehugger Robot# set ProjObjRoot appropriately
9*7c3d14c8STreehugger Robotifdef OBJROOT
10*7c3d14c8STreehugger Robot  ProjObjRoot := $(OBJROOT)
11*7c3d14c8STreehugger Robotelse
12*7c3d14c8STreehugger Robot  ProjObjRoot := $(ProjSrcRoot)
13*7c3d14c8STreehugger Robotendif
14*7c3d14c8STreehugger Robot
15*7c3d14c8STreehugger Robotifeq (,$(RC_PURPLE))
16*7c3d14c8STreehugger Robot	INSTALL_TARGET = install-MacOSX
17*7c3d14c8STreehugger Robotelse
18*7c3d14c8STreehugger Robot  ifeq (,$(RC_INDIGO))
19*7c3d14c8STreehugger Robot    INSTALL_TARGET = install-iOS
20*7c3d14c8STreehugger Robot  else
21*7c3d14c8STreehugger Robot    INSTALL_TARGET = install-iOS-Simulator
22*7c3d14c8STreehugger Robot  endif
23*7c3d14c8STreehugger Robotendif
24*7c3d14c8STreehugger Robot
25*7c3d14c8STreehugger Robot
26*7c3d14c8STreehugger Robot
27*7c3d14c8STreehugger Robot# Log full compile lines in B&I logs and omit summary lines.
28*7c3d14c8STreehugger RobotVerb :=
29*7c3d14c8STreehugger RobotSummary := @true
30*7c3d14c8STreehugger Robot
31*7c3d14c8STreehugger Robot# List of functions needed for each architecture.
32*7c3d14c8STreehugger Robot
33*7c3d14c8STreehugger Robot# Copies any public headers to DSTROOT.
34*7c3d14c8STreehugger Robotinstallhdrs:
35*7c3d14c8STreehugger Robot
36*7c3d14c8STreehugger Robot
37*7c3d14c8STreehugger Robot# Copies source code to SRCROOT.
38*7c3d14c8STreehugger Robotinstallsrc:
39*7c3d14c8STreehugger Robot	cp -r . $(SRCROOT)
40*7c3d14c8STreehugger Robot
41*7c3d14c8STreehugger Robot
42*7c3d14c8STreehugger Robotinstall:  $(INSTALL_TARGET)
43*7c3d14c8STreehugger Robot
44*7c3d14c8STreehugger Robot# Copy results to DSTROOT.
45*7c3d14c8STreehugger Robotinstall-MacOSX : $(SYMROOT)/libcompiler_rt.dylib \
46*7c3d14c8STreehugger Robot                 $(SYMROOT)/libcompiler_rt-dyld.a
47*7c3d14c8STreehugger Robot	mkdir -p $(DSTROOT)/usr/local/lib/dyld
48*7c3d14c8STreehugger Robot	cp $(SYMROOT)/libcompiler_rt-dyld.a  \
49*7c3d14c8STreehugger Robot				    $(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
50*7c3d14c8STreehugger Robot	mkdir -p $(DSTROOT)/usr/lib/system
51*7c3d14c8STreehugger Robot	$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
52*7c3d14c8STreehugger Robot	    -o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
53*7c3d14c8STreehugger Robot	cd $(DSTROOT)/usr/lib/system; \
54*7c3d14c8STreehugger Robot	    ln -s libcompiler_rt.dylib libcompiler_rt_profile.dylib; \
55*7c3d14c8STreehugger Robot	    ln -s libcompiler_rt.dylib libcompiler_rt_debug.dylib
56*7c3d14c8STreehugger Robot
57*7c3d14c8STreehugger Robot# Rule to make each dylib slice
58*7c3d14c8STreehugger Robot$(OBJROOT)/libcompiler_rt-%.dylib : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
59*7c3d14c8STreehugger Robot	echo "const char vers[] = \"@(#) $(RC_ProjectName)-$(RC_ProjectSourceVersion)\"; " > $(OBJROOT)/version.c
60*7c3d14c8STreehugger Robot	$(call GetCNAVar,CC,Platform.darwin_bni,Release,$*) \
61*7c3d14c8STreehugger Robot	   $(OBJROOT)/version.c -arch $* -dynamiclib \
62*7c3d14c8STreehugger Robot	   -install_name /usr/lib/system/libcompiler_rt.dylib \
63*7c3d14c8STreehugger Robot	   -compatibility_version 1 -current_version $(RC_ProjectSourceVersion) \
64*7c3d14c8STreehugger Robot	   -nodefaultlibs -umbrella System -dead_strip \
65*7c3d14c8STreehugger Robot	   -Wl,-upward-lunwind \
66*7c3d14c8STreehugger Robot	   -Wl,-upward-lsystem_m \
67*7c3d14c8STreehugger Robot	   -Wl,-upward-lsystem_c \
68*7c3d14c8STreehugger Robot	   -Wl,-upward-lsystem_kernel \
69*7c3d14c8STreehugger Robot	   -Wl,-upward-lsystem_platform \
70*7c3d14c8STreehugger Robot	   -Wl,-ldyld \
71*7c3d14c8STreehugger Robot	   -L$(SDKROOT)/usr/lib/system \
72*7c3d14c8STreehugger Robot	   $(DYLIB_FLAGS) -Wl,-force_load,$^ -o $@
73*7c3d14c8STreehugger Robot
74*7c3d14c8STreehugger Robot# Rule to make fat dylib
75*7c3d14c8STreehugger Robot$(SYMROOT)/libcompiler_rt.dylib: $(foreach arch,$(filter-out armv4t,$(RC_ARCHS)), \
76*7c3d14c8STreehugger Robot                                        $(OBJROOT)/libcompiler_rt-$(arch).dylib)
77*7c3d14c8STreehugger Robot	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
78*7c3d14c8STreehugger Robot	$(call GetCNAVar,DSYMUTIL,Platform.darwin_bni,Release,) $@
79*7c3d14c8STreehugger Robot
80*7c3d14c8STreehugger Robot
81*7c3d14c8STreehugger Robot# Copy results to DSTROOT.
82*7c3d14c8STreehugger Robotinstall-iOS: $(SYMROOT)/libcompiler_rt-static.a \
83*7c3d14c8STreehugger Robot             $(SYMROOT)/libcompiler_rt-dyld.a \
84*7c3d14c8STreehugger Robot             $(SYMROOT)/libcompiler_rt.dylib
85*7c3d14c8STreehugger Robot	mkdir -p $(DSTROOT)/usr/local/lib
86*7c3d14c8STreehugger Robot	cp $(SYMROOT)/libcompiler_rt-static.a  \
87*7c3d14c8STreehugger Robot				    $(DSTROOT)/usr/local/lib/libcompiler_rt-static.a
88*7c3d14c8STreehugger Robot	mkdir -p $(DSTROOT)/usr/local/lib/dyld
89*7c3d14c8STreehugger Robot	cp $(SYMROOT)/libcompiler_rt-dyld.a  \
90*7c3d14c8STreehugger Robot				    $(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
91*7c3d14c8STreehugger Robot	mkdir -p $(DSTROOT)/usr/lib/system
92*7c3d14c8STreehugger Robot	$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
93*7c3d14c8STreehugger Robot	    -o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
94*7c3d14c8STreehugger Robot
95*7c3d14c8STreehugger Robot# Rule to make fat archive
96*7c3d14c8STreehugger Robot$(SYMROOT)/libcompiler_rt-static.a : $(foreach arch,$(RC_ARCHS), \
97*7c3d14c8STreehugger Robot                         $(OBJROOT)/darwin_bni/Static/$(arch)/libcompiler_rt.a)
98*7c3d14c8STreehugger Robot	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
99*7c3d14c8STreehugger Robot
100*7c3d14c8STreehugger Robot# rule to make each archive slice for dyld (which removes a few archive members)
101*7c3d14c8STreehugger Robot$(OBJROOT)/libcompiler_rt-dyld-%.a : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
102*7c3d14c8STreehugger Robot	cp $^ $@
103*7c3d14c8STreehugger Robot	DEL_LIST=`$(AR)  -t $@ | egrep 'apple_versioning|gcc_personality_v0|eprintf' | xargs echo` ; \
104*7c3d14c8STreehugger Robot	if [ -n "$${DEL_LIST}" ] ; \
105*7c3d14c8STreehugger Robot	then  \
106*7c3d14c8STreehugger Robot		$(call GetCNAVar,AR,Platform.darwin_bni,Release,) -d $@ $${DEL_LIST}; \
107*7c3d14c8STreehugger Robot		$(call GetCNAVar,RANLIB,Platform.darwin_bni,Release,) $@ ; \
108*7c3d14c8STreehugger Robot	fi
109*7c3d14c8STreehugger Robot
110*7c3d14c8STreehugger Robot# rule to make make archive for dyld
111*7c3d14c8STreehugger Robot$(SYMROOT)/libcompiler_rt-dyld.a : $(foreach arch,$(RC_ARCHS), \
112*7c3d14c8STreehugger Robot                         $(OBJROOT)/libcompiler_rt-dyld-$(arch).a)
113*7c3d14c8STreehugger Robot	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
114*7c3d14c8STreehugger Robot
115*7c3d14c8STreehugger Robot
116*7c3d14c8STreehugger Robot
117*7c3d14c8STreehugger Robot# Copy results to DSTROOT.
118*7c3d14c8STreehugger Robotinstall-iOS-Simulator: $(SYMROOT)/libcompiler_rt_sim.dylib \
119*7c3d14c8STreehugger Robot                       $(SYMROOT)/libcompiler_rt-dyld.a
120*7c3d14c8STreehugger Robot	mkdir -p $(DSTROOT)/$(SDKROOT)/usr/lib/system
121*7c3d14c8STreehugger Robot	$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt_sim.dylib \
122*7c3d14c8STreehugger Robot	    -o $(DSTROOT)/$(SDKROOT)/usr/lib/system/libcompiler_rt_sim.dylib
123*7c3d14c8STreehugger Robot	mkdir -p $(DSTROOT)/$(SDKROOT)/usr/local/lib/dyld
124*7c3d14c8STreehugger Robot	cp $(SYMROOT)/libcompiler_rt-dyld.a  \
125*7c3d14c8STreehugger Robot				    $(DSTROOT)/$(SDKROOT)/usr/local/lib/dyld/libcompiler_rt.a
126*7c3d14c8STreehugger Robot
127*7c3d14c8STreehugger Robot# Rule to make fat dylib
128*7c3d14c8STreehugger Robot$(SYMROOT)/libcompiler_rt_sim.dylib: $(foreach arch,$(RC_ARCHS), \
129*7c3d14c8STreehugger Robot                                        $(OBJROOT)/libcompiler_rt_sim-$(arch).dylib)
130*7c3d14c8STreehugger Robot	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
131*7c3d14c8STreehugger Robot	$(call GetCNAVar,DSYMUTIL,Platform.darwin_bni,Release,) $@
132*7c3d14c8STreehugger Robot
133*7c3d14c8STreehugger Robot# Rule to make each dylib slice
134*7c3d14c8STreehugger Robot$(OBJROOT)/libcompiler_rt_sim-%.dylib : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
135*7c3d14c8STreehugger Robot	echo "const char vers[] = \"@(#) $(RC_ProjectName)-$(RC_ProjectSourceVersion)\"; " > $(OBJROOT)/version.c
136*7c3d14c8STreehugger Robot	$(call GetCNAVar,CC,Platform.darwin_bni,Release,$*) \
137*7c3d14c8STreehugger Robot	   $(OBJROOT)/version.c -arch $* -dynamiclib \
138*7c3d14c8STreehugger Robot	   -install_name /usr/lib/system/libcompiler_rt_sim.dylib \
139*7c3d14c8STreehugger Robot	   -compatibility_version 1 -current_version $(RC_ProjectSourceVersion) \
140*7c3d14c8STreehugger Robot     -Wl,-unexported_symbol,___enable_execute_stack \
141*7c3d14c8STreehugger Robot	   -nostdlib \
142*7c3d14c8STreehugger Robot	   -Wl,-upward-lunwind_sim \
143*7c3d14c8STreehugger Robot	   -Wl,-upward-lsystem_sim_m \
144*7c3d14c8STreehugger Robot	   -Wl,-upward-lsystem_sim_c \
145*7c3d14c8STreehugger Robot	   -ldyld_sim \
146*7c3d14c8STreehugger Robot	   -Wl,-upward-lSystem \
147*7c3d14c8STreehugger Robot	   -umbrella System -Wl,-no_implicit_dylibs -L$(SDKROOT)/usr/lib/system -dead_strip \
148*7c3d14c8STreehugger Robot	   $(DYLIB_FLAGS) -Wl,-force_load,$^ -o $@
149*7c3d14c8STreehugger Robot
150