Skip to content

Commit c573a7a

Browse files
DougGregorrintaro
authored andcommitted
[CMake] Fix host library builds and rpaths for testing macros
This enables running macro tests on Linux.
1 parent 277619a commit c573a7a

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

cmake/modules/AddPureSwift.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,15 @@ function(add_pure_swift_host_tool name)
267267
add_executable(${name} ${APSHT_SOURCES})
268268
_add_host_swift_compile_options(${name})
269269

270-
set_property(TARGET ${name}
271-
APPEND PROPERTY INSTALL_RPATH
272-
"@executable_path/../lib/swift/host")
270+
if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
271+
set_property(TARGET ${name}
272+
APPEND PROPERTY INSTALL_RPATH
273+
"@executable_path/../lib/swift/host")
274+
else()
275+
set_property(TARGET ${name}
276+
APPEND PROPERTY INSTALL_RPATH
277+
"$ORIGIN/../lib/swift/host")
278+
endif()
273279

274280
set_property(TARGET ${name}
275281
PROPERTY BUILD_WITH_INSTALL_RPATH YES)

test/Macros/macro_swiftdeps.swift

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

88
// RUN: split-file %s %t/src
99

10-
//#-- Prepare the macro dylib plugin.
10+
//#-- Prepare the macro shared library plugin.
1111
// RUN: %host-build-swift \
1212
// RUN: -swift-version 5 \
1313
// RUN: -emit-library -o %t/plugin/%target-library-name(MacroDefinition) \
@@ -76,7 +76,7 @@
7676
// RUN: %FileCheck --check-prefix WITHOUT_PLUGIN %s < %t/with_macro_nonprimary.swiftdeps.processed
7777

7878
// WITH_PLUGIN: externalDepend interface '' 'BUILD_DIR{{.*}}mock-plugin' false
79-
// WITH_PLUGIN: externalDepend interface '' 'BUILD_DIR{{.*}}libMacroDefinition.dylib' false
79+
// WITH_PLUGIN: externalDepend interface '' 'BUILD_DIR{{.*}}libMacroDefinition.{{(dylib|so|dll)}}' false
8080

8181
// WITHOUT_PLUGIN-NOT: MacroDefinition
8282
// WITHOUT_PLUGIN-NOT: mock-plugin

test/lit.cfg

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,16 @@ else:
544544
"env SDKROOT=%s %r -toolchain-stdlib-rpath -Xlinker -rpath -Xlinker /usr/lib/swift %s %s %s"
545545
% (shell_quote(config.host_sdkroot), config.swiftc, mcp_opt, config.swift_test_options, config.swift_driver_test_options))
546546

547+
# Parse the host triple.
548+
(host_cpu, host_vendor, host_os, host_vers) = re.match('([^-]+)-([^-]+)-([^0-9-]+)(.*)', config.host_triple).groups()
549+
550+
if platform.system() == 'Darwin':
551+
host_build_extra_rpath=""
552+
else:
553+
host_build_extra_rpath="-Xlinker -rpath -Xlinker %s" % (make_path(config.swift_lib_dir, 'swift', host_os))
554+
547555
config.host_build_swift = (
548-
"%s -sdk %s -target %s -I %s -L %s" % (config.swiftc_driver, config.host_sdkroot, config.host_triple, config.swift_host_lib_dir, config.swift_host_lib_dir)
549-
)
556+
"%s -sdk %s -target %s -I %s -L %s %s" % (config.swiftc_driver, config.host_sdkroot, config.host_triple, config.swift_host_lib_dir, config.swift_host_lib_dir, host_build_extra_rpath))
550557

551558
config.substitutions.append( ('%llvm_obj_root', config.llvm_obj_root) )
552559
config.substitutions.append( ('%swift-lib-dir', config.swift_lib_dir) )

0 commit comments

Comments
 (0)