Skip to content

Commit 70323dd

Browse files
committed
Link _CompilerPluginSupport into the compiler and SourceKit.
Ensure that we link `swift_CompilerPluginSupport` into the compiler and SourceKit, and set the rpath appropriately to find the library in its installed location. A number of driver tests copy the driver executable into a temporary directory to isolate it from the build tree. Also copy the plugin support library into its appropriate place near the driver executable to ensure these tests keep working. To help with this, add a `swift_swift_parser` lit feature, which we can use in tests that involve the new parser's capabilities.
1 parent c1e0ed6 commit 70323dd

File tree

10 files changed

+45
-1
lines changed

10 files changed

+45
-1
lines changed

lib/CompilerPluginSupport/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,6 @@ if(SWIFT_SWIFT_PARSER)
8080
swift_install_in_component(DIRECTORY "${module_base}"
8181
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift"
8282
COMPONENT compiler)
83+
84+
set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${library_name})
8385
endif()

test/Driver/driver-compile.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545

4646
// RUN: %swiftc_driver -driver-print-jobs -c -target x86_64-apple-macosx10.9 %s %S/../Inputs/empty.swift -module-name main -driver-filelist-threshold=0 2>&1 | %FileCheck -check-prefix=FILELIST %s
4747

48-
// RUN: %empty-directory(%t)/DISTINCTIVE-PATH/usr/bin/
48+
// RUN: %empty-directory(%t/DISTINCTIVE-PATH/usr/bin/)
49+
// RUN: %empty-directory(%t/DISTINCTIVE-PATH/usr/lib/)
4950
// RUN: %hardlink-or-copy(from: %swift_frontend_plain, to: %t/DISTINCTIVE-PATH/usr/bin/swiftc)
51+
// RUN: %copy-plugin-support-library(%t/DISTINCTIVE-PATH/usr/lib/)
5052
// RUN: ln -s "swiftc" %t/DISTINCTIVE-PATH/usr/bin/swift-update
5153
// RUN: %t/DISTINCTIVE-PATH/usr/bin/swiftc -driver-print-jobs -c -update-code -target x86_64-apple-macosx10.9 %s 2>&1 > %t.upd.txt
5254
// RUN: %FileCheck -check-prefix UPDATE-CODE %s < %t.upd.txt

test/Driver/linker-clang_rt.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
// RUN: rm -rf %t
88
// RUN: %empty-directory(%t/bin)
9+
// RUN: %empty-directory(%t/lib)
910
// RUN: %hardlink-or-copy(from: %swift_frontend_plain, to: %t/bin/swiftc)
11+
// RUN: %copy-plugin-support-library(%t/lib/)
1012
// RUN: %empty-directory(%t/lib/swift/clang/lib/darwin/)
1113

1214
// RUN: %t/bin/swiftc -driver-print-jobs -target x86_64-apple-macosx10.9 %S/../Inputs/empty.swift | %FileCheck -check-prefix CHECK -check-prefix CHECK-NO-RUNTIME %s

test/Driver/options-repl-darwin.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// the Swift driver really thinks it's been moved.
66

77
// RUN: %empty-directory(%t/usr/bin/)
8+
// RUN: %empty-directory(%t/usr/lib/)
89
// RUN: %hardlink-or-copy(from: %swift_driver_plain, to: %t/usr/bin/swift)
10+
// RUN: %copy-plugin-support-library(%t/usr/lib/)
911

1012
// RUN: %t/usr/bin/swift -repl -### | %FileCheck -check-prefix=INTEGRATED %s
1113
// RUN: %t/usr/bin/swift -### | %FileCheck -check-prefix=INTEGRATED %s
@@ -16,7 +18,9 @@
1618
// RUN: %t/usr/bin/swift -### | %FileCheck -check-prefix=LLDB %s
1719

1820
// RUN: %empty-directory(%t/Toolchains/Test.xctoolchain/usr/bin)
21+
// RUN: %empty-directory(%t/Toolchains/Test.xctoolchain/usr/lib)
1922
// RUN: mv %t/usr/bin/swift %t/Toolchains/Test.xctoolchain/usr/bin/swift
23+
// RUN: %copy-plugin-support-library(%t/Toolchains/Test.xctoolchain/usr/lib/)
2024
// RUN: %t/Toolchains/Test.xctoolchain/usr/bin/swift -repl -### | %FileCheck -check-prefix=LLDB %s
2125

2226
// Clean up the test executable because hard links are expensive.

test/Driver/options-repl.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
// RUN: %empty-directory(%t)
99
// RUN: mkdir -p %t/usr/bin
10+
// RUN: mkdir -p %t/usr/lib
11+
// RUN: %copy-plugin-support-library(%t/usr/lib/)
1012
// RUN: %hardlink-or-copy(from: %swift_frontend_plain, to: %t/usr/bin/swift)
1113

1214
// RUN: %t/usr/bin/swift -sdk "" -deprecated-integrated-repl -### | %FileCheck -check-prefix=INTEGRATED %s

test/Driver/subcommands.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
// RUN: rm -rf %t.dir
55
// RUN: mkdir -p %t.dir/usr/bin
6+
// RUN: mkdir -p %t.dir/usr/lib
67
// RUN: %hardlink-or-copy(from: %swift_frontend_plain, to: %t.dir/usr/bin/swift)
8+
// RUN: %copy-plugin-support-library(%t.dir/usr/lib/)
79

810
// RUN: %t.dir/usr/bin/swift -### 2>&1 | %FileCheck -check-prefix=CHECK-SWIFT-INVOKES-REPL %s
911
// RUN: %t.dir/usr/bin/swift repl -### 2>&1 | %FileCheck -check-prefix=CHECK-SWIFT-INVOKES-REPL %s

test/Driver/windows-link-job.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %empty-directory(%t/DISTINCTIVE-WINDOWS-PATH/usr/bin)
2+
// RUN: %empty-directory(%t/DISTINCTIVE-WINDOWS-PATH/usr/lib)
23
// RUN: %hardlink-or-copy(from: %swift_frontend_plain, to: %t/DISTINCTIVE-WINDOWS-PATH/usr/bin/swiftc)
4+
// RUN: %copy-plugin-support-library(%t/DISTINCTIVE-WINDOWS-PATH/usr/lib/)
35
// RUN: env PATH= %t/DISTINCTIVE-WINDOWS-PATH/usr/bin/swiftc -target x86_64-unknown-windows-msvc -### -module-name link -emit-library %s 2>&1 | %FileCheck %s
46

57
// swift-frontend cannot be copied to another location with bootstrapping because

test/lit.cfg

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ lit_config.note("Using code completion cache: " + completion_cache_path)
469469

470470
config.substitutions.append( ('%validate-incrparse', '%{python} %utils/incrparse/validate_parse.py --temp-dir %t --swift-syntax-test %swift-syntax-test') )
471471
config.substitutions.append( ('%llvm_obj_root', config.llvm_obj_root) )
472+
config.substitutions.append( ('%swift-lib-dir', config.swift_lib_dir) )
472473
config.substitutions.append( ('%llvm_src_root', config.llvm_src_root) )
473474
config.substitutions.append( ('%swift_obj_root', config.swift_obj_root) )
474475
config.substitutions.append( ('%swift_src_root', config.swift_src_root) )
@@ -2472,6 +2473,25 @@ config.substitutions.append(('%target-resilience-test', config.target_resilience
24722473
config.substitutions.append(('%llvm-profdata', config.llvm_profdata))
24732474
config.substitutions.append(('%llvm-cov', config.llvm_cov))
24742475

2476+
# Name of the compiler plugin support library.
2477+
plugin_support_shared_lib_name = ("%sswift_CompilerPluginSupport%s" %
2478+
(config.target_shared_library_prefix, config.target_shared_library_suffix))
2479+
plugin_support_shared_lib = make_path(config.swift_lib_dir, plugin_support_shared_lib_name)
2480+
config.substitutions.append(('%compiler_plugin_library',
2481+
plugin_support_shared_lib))
2482+
2483+
if "swift_swift_parser" in config.available_features:
2484+
config.substitutions.append(
2485+
(r'%copy-plugin-support-library\(*(.*)\)',
2486+
SubstituteCaptures(
2487+
r'cp %s \1' %
2488+
(escape_for_substitute_captures(plugin_support_shared_lib)))))
2489+
else:
2490+
config.substitutions.append(
2491+
(r'%copy-plugin-support-library\(*(.*)\)',
2492+
r'echo "No plugin support library to copy"'))
2493+
2494+
24752495
if hasattr(config, 'otool_classic'):
24762496
config.substitutions.append(('%otool-classic', config.otool_classic))
24772497

test/lit.site.cfg.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ config.freestanding_sdk_name = "@SWIFT_SDK_FREESTANDING_LIB_SUBDIR@"
152152
if "@BOOTSTRAPPING_MODE@" != "OFF":
153153
config.available_features.add('swift_in_compiler')
154154

155+
if "@SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR@" != "":
156+
config.available_features.add('swift_swift_parser')
157+
155158
if "@BOOTSTRAPPING_MODE@" == 'HOSTTOOLS':
156159
config.available_features.add('hosttools_mode')
157160
elif "@BOOTSTRAPPING_MODE@" == 'BOOTSTRAPPING':

tools/SourceKit/lib/SwiftLang/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@ target_link_libraries(SourceKitSwiftLang PRIVATE
6767
clangAPINotes
6868
clangBasic)
6969
add_dependencies(SourceKitSwiftLang clang-tablegen-targets)
70+
71+
if (SWIFT_SWIFT_PARSER)
72+
target_link_libraries(SourceKitSwiftLang
73+
PRIVATE swift_CompilerPluginSupport)
74+
endif()

0 commit comments

Comments
 (0)