Skip to content

Commit a3c7d6c

Browse files
authored
Use the just-built Darwin libLTO.dylib in lit tests (swiftlang#39208)
1 parent 9162575 commit a3c7d6c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

test/Interpreter/llvm_link_time_opt.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// REQUIRES: lld_lto
55

66
// RUN: %empty-directory(%t)
7-
// RUN: %target-swiftc_driver -emit-library -static -lto=llvm-full -emit-module %S/Inputs/lto/module1.swift -working-directory %t
8-
// RUN: %target-swiftc_driver -lto=llvm-full %s -I%t -L%t -lmodule1 -module-name main -o %t/main
7+
// RUN: %target-swiftc_driver -emit-library -static -lto=llvm-full %lto_flags -emit-module %S/Inputs/lto/module1.swift -working-directory %t
8+
// RUN: %target-swiftc_driver -lto=llvm-full %lto_flags %s -I%t -L%t -lmodule1 -module-name main -o %t/main
99
// RUN: %llvm-nm --defined-only %t/main | %FileCheck %s
1010

1111
// CHECK-NOT: _$s7module120unusedPublicFunctionyyF

test/lit.cfg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,22 @@ lit_config.note('Using cmake: ' + config.cmake)
219219
config.llvm_src_root = getattr(config, 'llvm_src_root', None)
220220
config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)
221221

222+
lto_flags = ""
223+
222224
if platform.system() == 'OpenBSD':
223225
llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
224226
if not llvm_libs_dir:
225227
lit_config.fatal('No LLVM libs dir set.')
226228
config.environment['LD_LIBRARY_PATH'] = llvm_libs_dir
227229

230+
elif platform.system() == 'Darwin':
231+
llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
232+
if not llvm_libs_dir:
233+
lit_config.fatal('No LLVM libs dir set.')
234+
lto_flags = "-Xlinker -lto_library -Xlinker %s/libLTO.dylib" % llvm_libs_dir
235+
236+
config.substitutions.append( ('%lto_flags', lto_flags) )
237+
228238
def append_to_env_path(directory):
229239
config.environment['PATH'] = \
230240
os.path.pathsep.join((directory, config.environment['PATH']))

0 commit comments

Comments
 (0)