@@ -27,6 +27,10 @@ ResourceIncludeDir := $(ResourceDir)/include
27
27
PROJ_resources_lib := $(PROJ_resources ) /lib
28
28
PROJ_resources_include := $(PROJ_resources ) /include
29
29
30
+ # Initialize a variable to use for extra flags to pass to the
31
+ # compiler-rt make process.
32
+ COMPILERRT_MAKE_FLAGS :=
33
+
30
34
# Expect compiler-rt to be in llvm/projects/compiler-rt
31
35
COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT ) /projects/compiler-rt
32
36
@@ -80,6 +84,17 @@ RuntimeLibrary.darwin.Configs := \
80
84
asan_osx_dynamic.dylib \
81
85
profile_osx.a profile_ios.a \
82
86
ubsan_osx.a
87
+
88
+ # Support building compiler-rt with relocatable SDKs.
89
+ #
90
+ # This will cause make to put SDKROOT in the environment, and since we
91
+ # are using the built Clang to build compiler-rt, it to pick up that
92
+ # location as the default value for the include system root.
93
+ ACTIVE_SDK_PATH := $(shell xcrun --show-sdk-path 2> /dev/null)
94
+ ifneq ($(ACTIVE_SDK_PATH ) ,)
95
+ COMPILERRT_MAKE_FLAGS := SDKROOT=$(ACTIVE_SDK_PATH )
96
+ endif
97
+
83
98
endif
84
99
85
100
# On Linux, include a library which has all the runtime functions.
@@ -144,12 +159,14 @@ BuildRuntimeLibraries:
144
159
ProjObjRoot=$(PROJ_OBJ_DIR ) \
145
160
CC=" $( ToolDir) /clang" \
146
161
LLVM_ANDROID_TOOLCHAIN_DIR=" $( LLVM_ANDROID_TOOLCHAIN_DIR) " \
162
+ $(COMPILERRT_MAKE_FLAGS ) \
147
163
$(RuntimeDirs:%=clang_% )
148
164
.PHONY : BuildRuntimeLibraries
149
165
CleanRuntimeLibraries :
150
166
$(Verb ) $(MAKE ) -C $(COMPILERRT_SRC_ROOT ) \
151
167
ProjSrcRoot=$(COMPILERRT_SRC_ROOT ) \
152
168
ProjObjRoot=$(PROJ_OBJ_DIR ) \
169
+ $(COMPILERRT_MAKE_FLAGS ) \
153
170
clean
154
171
.PHONY : CleanRuntimeLibraries
155
172
RuntimeHeader : $(ResourceIncludeDir ) /sanitizer
0 commit comments