Skip to content

Commit f6b2ddb

Browse files
committed
[compiler-rt] Use ld64 flag -lto_library instead of DYLD_LIBRARY_PATH
Makes bin/llvm-lit \ projects/compiler-rt/test/profile/Profile-arm64/instrprof-darwin-dead-strip.c pass on my machine. Without this change, ld64 complains that the bitcode was generated by LLVM 15 while the reader is 13.1 -- the version of Xcode on my machine. Looks like the DYLD_LIBRARY_PATH technique isn't working. -lto_library was added back in ld64-136, which was in Xcode 4.6, which was released over 10 years ago. So relying on it should be safe by now. Differential Revision: https://reviews.llvm.org/D124018
1 parent 83892d7 commit f6b2ddb

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

compiler-rt/test/lit.common.cfg.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,11 @@ def get_macos_aligned_version(macos_vers):
520520
config.available_features.add("has_sancovcc")
521521
config.substitutions.append( ("%sancovcc ", sancovcc_path) )
522522

523+
def liblto_path():
524+
return os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')
525+
523526
def is_darwin_lto_supported():
524-
return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib'))
527+
return os.path.exists(liblto_path())
525528

526529
def is_binutils_lto_supported():
527530
if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
@@ -543,8 +546,7 @@ def is_windows_lto_supported():
543546

544547
if config.host_os == 'Darwin' and is_darwin_lto_supported():
545548
config.lto_supported = True
546-
config.lto_launch = ["env", "DYLD_LIBRARY_PATH=" + config.llvm_shlib_dir]
547-
config.lto_flags = []
549+
config.lto_flags = [ '-Wl,-lto_library,' + liblto_path() ]
548550
elif config.host_os in ['Linux', 'FreeBSD', 'NetBSD']:
549551
config.lto_supported = False
550552
if config.use_lld:
@@ -554,14 +556,12 @@ def is_windows_lto_supported():
554556
config.lto_supported = True
555557

556558
if config.lto_supported:
557-
config.lto_launch = []
558559
if config.use_lld:
559560
config.lto_flags = ["-fuse-ld=lld"]
560561
else:
561562
config.lto_flags = ["-fuse-ld=gold"]
562563
elif config.host_os == 'Windows' and is_windows_lto_supported():
563564
config.lto_supported = True
564-
config.lto_launch = []
565565
config.lto_flags = ["-fuse-ld=lld"]
566566
else:
567567
config.lto_supported = False
@@ -692,7 +692,6 @@ def is_windows_lto_supported():
692692
extra_cflags = []
693693

694694
if config.use_lto and config.lto_supported:
695-
run_wrapper += config.lto_launch
696695
extra_cflags += config.lto_flags
697696
elif config.use_lto and (not config.lto_supported):
698697
config.unsupported = True

compiler-rt/test/profile/lit.cfg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ def get_required_attr(config, attr_name):
4444

4545
def build_invocation(compile_flags, with_lto = False):
4646
lto_flags = []
47-
lto_prefix = []
4847
if with_lto and config.lto_supported:
4948
lto_flags += config.lto_flags
50-
lto_prefix += config.lto_launch
51-
return " " + " ".join(lto_prefix + [config.clang] + lto_flags + compile_flags) + " "
49+
return " " + " ".join([config.clang] + lto_flags + compile_flags) + " "
5250

5351
def exclude_unsupported_files_for_aix(dirname):
5452
for filename in os.listdir(dirname):

compiler-rt/test/safestack/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
config.substitutions.append( ("%clang_safestack ", config.clang + " -O0 -fsanitize=safe-stack ") )
1717

1818
if config.lto_supported:
19-
config.substitutions.append((r"%clang_lto_safestack ", ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-fsanitize=safe-stack '])))
19+
config.substitutions.append((r"%clang_lto_safestack ", ' '.join([config.clang] + config.lto_flags + ['-fsanitize=safe-stack '])))
2020

2121
if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD']:
2222
config.unsupported = True

0 commit comments

Comments
 (0)