Skip to content

Commit 2b70dcc

Browse files
committed
[Test] Add linker_overridden feature.
When testing different linkers, it's sometimes useful to run the tests with `SWIFT_DRIVER_TEST_OPTIONS=" -use-ld=<linker>"`. If we do this, it will break a handful of tests because they expect the compiler driver to choose an appropriate linker automatically. To avoid having these fail, detect when someone has done this, and set a new feature, `linker_overridden`, then mark the tests in question with `UNSUPPORTED: linker_overridden`. rdar://123504095
1 parent aa5458e commit 2b70dcc

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

test/Driver/link-time-opt.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// UNSUPPORTED: linker_overridden
2+
13
// RUN: %swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -lto=llvm-thin -target x86_64-unknown-linux-gnu | %FileCheck %s --check-prefix=CHECK-SIMPLE-THIN --check-prefix=CHECK-SIMPLE-THIN-linux-gnu
24
// RUN: %swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -lto=llvm-thin -target x86_64-unknown-windows-msvc | %FileCheck %s --check-prefix=CHECK-SIMPLE-THIN --check-prefix=CHECK-SIMPLE-THIN-windows-msvc
35

test/Driver/static-archive.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// UNSUPPORTED: linker_overridden
2+
13
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 -emit-library %s -module-name ARCHIVER -static 2>&1 | %FileCheck -check-prefix CHECK-MACOS %s
24

35
// CHECK-MACOS: swift

test/Interpreter/llvm_link_time_opt.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// loaded too late").
1111
// REQUIRES: no_asan
1212

13+
// UNSUPPORTED: linker_overridden
14+
1315
// RUN: %empty-directory(%t)
1416
// RUN: %use_just_built_liblto %target-swiftc_driver -emit-library -static -lto=llvm-full %lto_flags -emit-module %S/Inputs/lto/module1.swift -working-directory %t
1517
// RUN: %use_just_built_liblto %target-swiftc_driver -lto=llvm-full %lto_flags %s -I%t -L%t -lmodule1 -module-name main -o %t/main

test/embedded/once.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// REQUIRES: executable_test
77
// REQUIRES: optimized_stdlib
88
// REQUIRES: OS=macosx || OS=linux-gnu
9+
// UNSUPPORTED: linker_overridden
910

1011
// For LTO, the linker dlopen()'s the libLTO library, which is a scenario that
1112
// ASan cannot work in ("Interceptors are not working, AddressSanitizer is

test/lit.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,11 @@ config.swift_driver_test_options += os.environ.get('SWIFT_DRIVER_TEST_OPTIONS',
547547
config.swift_ide_test_test_options += os.environ.get('SWIFT_IDE_TEST_TEST_OPTIONS', '')
548548
config.sil_test_options = os.environ.get('SIL_TEST_OPTIONS', '')
549549

550+
# Check if we overrode the linker; if we do, set a feature to say that, which
551+
# lets us disable tests that rely on the driver choosing the linker.
552+
if re.search(r'(?:^|[ \t])-use-ld=[^ \t]*', config.swift_driver_test_options):
553+
config.available_features.add('linker_overridden')
554+
550555
config.clang_module_cache_path = make_path(config.swift_test_results_dir, "clang-module-cache")
551556
shutil.rmtree(config.clang_module_cache_path, ignore_errors=True)
552557
mcp_opt = "-module-cache-path %s" % shell_quote(config.clang_module_cache_path)

0 commit comments

Comments
 (0)