Skip to content

Commit 184687b

Browse files
committed
[build] Update runtime library and tests to work with relocatable SDKs on OS X 10.9.
llvm-svn: 194168
1 parent e34182f commit 184687b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

clang/runtime/compiler-rt/Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ ResourceIncludeDir := $(ResourceDir)/include
2727
PROJ_resources_lib := $(PROJ_resources)/lib
2828
PROJ_resources_include := $(PROJ_resources)/include
2929

30+
# Initialize a variable to use for extra flags to pass to the
31+
# compiler-rt make process.
32+
COMPILERRT_MAKE_FLAGS :=
33+
3034
# Expect compiler-rt to be in llvm/projects/compiler-rt
3135
COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt
3236

@@ -80,6 +84,17 @@ RuntimeLibrary.darwin.Configs := \
8084
asan_osx_dynamic.dylib \
8185
profile_osx.a profile_ios.a \
8286
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+
8398
endif
8499

85100
# On Linux, include a library which has all the runtime functions.
@@ -144,12 +159,14 @@ BuildRuntimeLibraries:
144159
ProjObjRoot=$(PROJ_OBJ_DIR) \
145160
CC="$(ToolDir)/clang" \
146161
LLVM_ANDROID_TOOLCHAIN_DIR="$(LLVM_ANDROID_TOOLCHAIN_DIR)" \
162+
$(COMPILERRT_MAKE_FLAGS) \
147163
$(RuntimeDirs:%=clang_%)
148164
.PHONY: BuildRuntimeLibraries
149165
CleanRuntimeLibraries:
150166
$(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
151167
ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
152168
ProjObjRoot=$(PROJ_OBJ_DIR) \
169+
$(COMPILERRT_MAKE_FLAGS) \
153170
clean
154171
.PHONY: CleanRuntimeLibraries
155172
RuntimeHeader: $(ResourceIncludeDir)/sanitizer

clang/test/lit.cfg

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,18 @@ else:
353353
# Will default to '/usr/lib/libgmalloc.dylib' if not set.
354354
gmalloc_path_str = lit_config.params.get('gmalloc_path',
355355
'/usr/lib/libgmalloc.dylib')
356-
357356
if use_gmalloc:
358357
config.environment.update({'DYLD_INSERT_LIBRARIES' : gmalloc_path_str})
358+
359+
# On Darwin, support relocatable SDKs by providing Clang with a
360+
# default system root path.
361+
if 'darwin' in config.target_triple:
362+
cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
363+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
364+
out, err = cmd.communicate()
365+
out = out.strip()
366+
res = cmd.wait()
367+
if res == 0 and out:
368+
sdk_path = out
369+
lit_config.note('using SDKROOT: %r' % sdk_path)
370+
config.environment['SDKROOT'] = sdk_path

0 commit comments

Comments
 (0)