Skip to content

Commit 1f94705

Browse files
author
Nick Kledzik
committed
<rdar://problem/9624306> clean up darwin platform to use xcrun. Set up variables in darwin_bni.mk. Use GetCNAVar in AppleBI.mk
llvm-svn: 133487
1 parent b4a791f commit 1f94705

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

compiler-rt/make/AppleBI.mk

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,12 @@ endif
1414

1515
ifeq (,$(SDKROOT))
1616
INSTALL_TARGET = install-MacOSX
17-
LD_OTHER_FLAGS =
1817
else
1918
INSTALL_TARGET = install-iOS
20-
CFLAGS.Release.armv6 := $(CFLAGS) -Wall -Os -fomit-frame-pointer -g -isysroot $(SDKROOT)
21-
CFLAGS.Release.armv7 := $(CFLAGS) -Wall -Os -fomit-frame-pointer -g -isysroot $(SDKROOT)
22-
CFLAGS.Static.armv6 := $(CFLAGS) -Wall -Os -fomit-frame-pointer -g -isysroot $(SDKROOT) -static
23-
CFLAGS.Static.armv7 := $(CFLAGS) -Wall -Os -fomit-frame-pointer -g -isysroot $(SDKROOT) -static
24-
LD_OTHER_FLAGS = -Wl,-alias_list,$(SRCROOT)/lib/arm/softfloat-alias.list -isysroot $(SDKROOT)
2519
endif
2620

2721

22+
2823
# Log full compile lines in B&I logs and omit summary lines.
2924
Verb :=
3025
Summary := @true
@@ -49,7 +44,7 @@ install-MacOSX : $(SYMROOT)/libcompiler_rt.dylib \
4944
cp $(SYMROOT)/libcompiler_rt-dyld.a \
5045
$(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
5146
mkdir -p $(DSTROOT)/usr/lib/system
52-
strip -S $(SYMROOT)/libcompiler_rt.dylib \
47+
$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
5348
-o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
5449
cd $(DSTROOT)/usr/lib/system; \
5550
ln -s libcompiler_rt.dylib libcompiler_rt_profile.dylib; \
@@ -58,16 +53,17 @@ install-MacOSX : $(SYMROOT)/libcompiler_rt.dylib \
5853
# Rule to make each dylib slice
5954
$(OBJROOT)/libcompiler_rt-%.dylib : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
6055
echo "const char vers[] = \"@(#) $(RC_ProjectName)-$(RC_ProjectSourceVersion)\"; " > $(OBJROOT)/version.c
61-
$(CC.Release) $(OBJROOT)/version.c -arch $* -dynamiclib \
56+
$(call GetCNAVar,CC,Platform.darwin_bni,Release,$*) \
57+
$(OBJROOT)/version.c -arch $* -dynamiclib \
6258
-install_name /usr/lib/system/libcompiler_rt.dylib \
6359
-compatibility_version 1 -current_version $(RC_ProjectSourceVersion) \
6460
-nodefaultlibs -lSystem -umbrella System -dead_strip \
65-
$(LD_OTHER_FLAGS) -Wl,-force_load,$^ -o $@
61+
$(DYLIB_FLAGS) -Wl,-force_load,$^ -o $@
6662

6763
# Rule to make fat dylib
6864
$(SYMROOT)/libcompiler_rt.dylib: $(foreach arch,$(RC_ARCHS), \
6965
$(OBJROOT)/libcompiler_rt-$(arch).dylib)
70-
lipo -create $^ -o $@
66+
$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o $@
7167

7268

7369

@@ -83,25 +79,27 @@ install-iOS: $(SYMROOT)/libcompiler_rt-static.a \
8379
cp $(SYMROOT)/libcompiler_rt-dyld.a \
8480
$(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
8581
mkdir -p $(DSTROOT)/usr/lib/system
86-
strip -S $(SYMROOT)/libcompiler_rt.dylib \
82+
$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
8783
-o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
8884

8985

9086
# Rule to make fat archive
9187
$(SYMROOT)/libcompiler_rt-static.a : $(foreach arch,$(RC_ARCHS), \
9288
$(OBJROOT)/darwin_bni/Static/$(arch)/libcompiler_rt.a)
93-
lipo -create $^ -o $@
89+
$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o $@
9490

95-
# rule to make each archive slice for dyld
91+
# rule to make each archive slice for dyld (which removes a few archive members)
9692
$(OBJROOT)/libcompiler_rt-dyld-%.a : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
9793
cp $^ $@
98-
ar -d $@ apple_versioning.o
99-
ar -d $@ gcc_personality_v0.o
100-
ar -d $@ eprintf.o
101-
ranlib $@
94+
DEL_LIST=`$(AR) -t $@ | egrep 'apple_versioning|gcc_personality_v0|eprintf' | xargs echo` ; \
95+
if [ -n "$${DEL_LIST}" ] ; \
96+
then \
97+
$(call GetCNAVar,AR,Platform.darwin_bni,Release,) -d $@ $${DEL_LIST}; \
98+
$(call GetCNAVar,RANLIB,Platform.darwin_bni,Release,) $@ ; \
99+
fi
102100

103101
# rule to make make archive for dyld
104102
$(SYMROOT)/libcompiler_rt-dyld.a : $(foreach arch,$(RC_ARCHS), \
105103
$(OBJROOT)/libcompiler_rt-dyld-$(arch).a)
106-
lipo -create $^ -o $@
104+
$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o $@
107105

compiler-rt/make/platform/darwin_bni.mk

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,30 @@ Configs := Debug Release Profile Static
88
# and the resulting lib will just have generic versions for anything unknown.
99
UniversalArchs := $(RC_ARCHS)
1010

11-
ifeq (,$(SDKROOT))
12-
CC.Release := $(CC)
13-
CC.Static := $(CC)
11+
ifneq (,$(SDKROOT))
12+
override CC := $(shell xcrun -sdk $(SDKROOT) -find clang)
13+
AR := $(shell xcrun -sdk $(SDKROOT) -find ar)
14+
RANLIB := $(shell xcrun -sdk $(SDKROOT) -find ranlib)
15+
STRIP := $(shell xcrun -sdk $(SDKROOT) -find strip)
16+
LIPO := $(shell xcrun -sdk $(SDKROOT) -find lipo)
17+
endif
18+
19+
ifneq ($(IPHONEOS_DEPLOYMENT_TARGET),)
20+
DEPLOYMENT_FLAGS := -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)
1421
else
15-
CC.Release := /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cc
16-
CC.Static := /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cc
22+
ifneq ($(MACOSX_DEPLOYMENT_TARGET),)
23+
DEPLOYMENT_FLAGS := -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
24+
endif
1725
endif
1826

27+
ifneq (,$(SDKROOT))
28+
DEPLOYMENT_FLAGS += -isysroot $(SDKROOT)
29+
endif
1930

20-
CFLAGS := -Wall -Os -fomit-frame-pointer -g
21-
CFLAGS.Static := $(CFLAGS) -static
31+
CFLAGS := -Wall -Os -fomit-frame-pointer -g $(DEPLOYMENT_FLAGS)
32+
CFLAGS.Static := $(CFLAGS) -static
33+
DYLIB_FLAGS := $(DEPLOYMENT_FLAGS) \
34+
-Xarch_arm -Wl,-alias_list,$(SRCROOT)/lib/arm/softfloat-alias.list
2235

2336
VISIBILITY_HIDDEN := 0
2437
VISIBILITY_HIDDEN.Static := 1

0 commit comments

Comments
 (0)