Skip to content

Commit

Permalink
[Unix] Move all ELF SDK runtime libraries into their own architecture…
Browse files Browse the repository at this point in the history
…-specific directories

This is needed for all platforms that don't have multi-architecture libraries like Darwin.

Resolves #63645
  • Loading branch information
finagolfin committed Feb 20, 2023
1 parent 815e8cc commit 119f295
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 50 deletions.
6 changes: 3 additions & 3 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
# installed host toolchain.
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}")

target_link_libraries(${target} PRIVATE ${swiftrt})
target_link_libraries(${target} PRIVATE "swiftCore")
Expand All @@ -543,7 +543,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
if(ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
set(swift_runtime_rpath "${host_lib_dir}")
else()
set(swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
set(swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}")
endif()

elseif(ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
Expand All @@ -558,7 +558,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)

# At runtime link against the built swift libraries from the current
# bootstrapping stage.
set(swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
set(swift_runtime_rpath "$ORIGIN/${relpath_to_lib_dir}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}")

elseif(ASRLF_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
message(FATAL_ERROR "BOOTSTRAPPING_MODE 'BOOTSTRAPPING-WITH-HOSTLIBS' not supported on Linux")
Expand Down
8 changes: 0 additions & 8 deletions cmake/modules/Libdispatch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ foreach(sdk ${DISPATCH_SDKS})
${CMAKE_COMMAND} -E copy
<INSTALL_DIR>/${LIBDISPATCH_RUNTIME_DIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}BlocksRuntime${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}BlocksRuntime${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
COMMAND
${CMAKE_COMMAND} -E copy
<INSTALL_DIR>/${LIBDISPATCH_RUNTIME_DIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}dispatch${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}dispatch${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
COMMAND
${CMAKE_COMMAND} -E copy
<INSTALL_DIR>/${LIBDISPATCH_RUNTIME_DIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}BlocksRuntime${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}BlocksRuntime${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
STEP_TARGETS
install
BUILD_BYPRODUCTS
Expand Down
9 changes: 7 additions & 2 deletions cmake/modules/SwiftUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ endfunction()
function(get_bootstrapping_swift_lib_dir bs_lib_dir bootstrapping)
set(bs_lib_dir "")
if(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
set(lib_dir
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
set(lib_dir
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
else()
set(lib_dir
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}")
endif()
# If building the stdlib with bootstrapping, the compiler has to pick up
# the swift libraries of the previous bootstrapping level (because in the
# current lib-directory they are not built yet.
Expand Down
14 changes: 7 additions & 7 deletions docs/Android.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ listed when you run the `adb devices` command - **currently this example works o
commands to copy the Swift Android stdlib:

```
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftCore.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftGlibc.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftSwiftOnoneSupport.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_Concurrency.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libdispatch.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlocksRuntime.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/aarch64/libswiftCore.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/aarch64/libswiftGlibc.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/aarch64/libswiftSwiftOnoneSupport.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/aarch64/libswiftRemoteMirror.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/aarch64/libswift_Concurrency.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/aarch64/libdispatch.so /data/local/tmp
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/aarch64/libBlocksRuntime.so /data/local/tmp
```

In addition, you'll also need to copy the Android NDK's libc++:
Expand Down
5 changes: 5 additions & 0 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,11 @@ void ToolChain::getRuntimeLibraryPaths(SmallVectorImpl<std::string> &runtimeLibP
StringRef SDKPath, bool shared) const {
SmallString<128> scratchPath;
getResourceDirPath(scratchPath, args, shared);
// Since only Darwin doesn't have separate libraries per architecture, link
// against the architecture-specific version of the library everywhere else.
if (!getTriple().isOSDarwin())
llvm::sys::path::append(scratchPath,
swift::getMajorArchitectureName(getTriple()));
runtimeLibPaths.push_back(std::string(scratchPath.str()));

// If there's a secondary resource dir, add it too.
Expand Down
5 changes: 1 addition & 4 deletions lib/Driver/WindowsToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ toolchains::Windows::constructInvocation(const DynamicLinkJobAction &job,

for (auto path : RuntimeLibPaths) {
Arguments.push_back("-L");
// Since Windows has separate libraries per architecture, link against the
// architecture specific version of the static library.
Arguments.push_back(context.Args.MakeArgString(path + "/" +
getTriple().getArchName()));
Arguments.push_back(context.Args.MakeArgString(path));
}

SmallString<128> SharedResourceDirPath;
Expand Down
5 changes: 4 additions & 1 deletion lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
LibSubDir = "maccatalyst";

llvm::sys::path::append(LibPath, LibSubDir);
llvm::SmallString<128> runtimeLibPath = LibPath;
if (!Triple.isOSDarwin())
llvm::sys::path::append(runtimeLibPath, swift::getMajorArchitectureName(Triple));
SearchPathOpts.RuntimeLibraryPaths.clear();
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(LibPath.str()));
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(runtimeLibPath.str()));
if (Triple.isOSDarwin())
SearchPathOpts.RuntimeLibraryPaths.push_back(DARWIN_OS_LIBRARY_PATH);

Expand Down
37 changes: 26 additions & 11 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,11 @@ function(add_swift_target_library_single target name)
"${SWIFT_SDK_MACCATALYST_LIB_SUBDIR}/${SWIFTLIB_SINGLE_ARCHITECTURE}")
endif()

if ("${SWIFTLIB_SINGLE_BOOTSTRAPPING}" STREQUAL "")
if ("${SWIFTLIB_SINGLE_BOOTSTRAPPING}" STREQUAL "" OR NOT SWIFTLIB_SINGLE_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
set(output_sub_dir ${SWIFTLIB_SINGLE_SUBDIR})
else()
# In the bootstrapping builds, we only have the single host architecture.
# So generated the library directly in the parent SDK specific directory
# So generate the Darwin library directly in the parent SDK specific directory
# (avoiding to lipo/copy the library).
set(output_sub_dir ${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR})
endif()
Expand Down Expand Up @@ -1253,11 +1253,12 @@ function(add_swift_target_library_single target name)
${SWIFTLIB_SINGLE_C_COMPILE_FLAGS} "-DSWIFT_TARGET_LIBRARY_NAME=${name}")
set(link_flags ${SWIFTLIB_SINGLE_LINK_FLAGS})

set(library_search_subdir "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
set(library_search_directories
"${lib_dir}/${output_sub_dir}"
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}")
if("${SWIFTLIB_SINGLE_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS)
list(APPEND library_search_directories "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
endif()

# In certain cases when building, the environment variable SDKROOT is set to override
# where the sdk root is located in the system. If that environment variable has been
Expand Down Expand Up @@ -1483,8 +1484,10 @@ function(add_swift_target_library_single target name)
endif()
set(library_search_directories
"${search_base_dir}/${SWIFTLIB_SINGLE_SUBDIR}"
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}")
if("${SWIFTLIB_SINGLE_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS)
list(APPEND library_search_directories "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
endif()
target_link_directories(${target_static} PRIVATE
${library_search_directories})
target_link_libraries("${target_static}" PRIVATE
Expand Down Expand Up @@ -2373,8 +2376,10 @@ function(add_swift_target_library name)
if (SWIFTLIB_BACK_DEPLOYMENT_LIBRARY)
# Back-deployment libraries get installed into a versioned directory.
set(install_dest "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}-${SWIFTLIB_BACK_DEPLOYMENT_LIBRARY}/${resource_dir_sdk_subdir}")
else()
elseif(sdk STREQUAL WINDOWS OR sdk IN_LIST SWIFT_DARWIN_PLATFORMS)
set(install_dest "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}")
else()
set(install_dest "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${SWIFT_PRIMARY_VARIANT_ARCH}")
endif()

swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
Expand Down Expand Up @@ -2450,6 +2455,11 @@ function(add_swift_target_library name)
"${name}-${library_subdir}-static")
set(UNIVERSAL_LIBRARY_NAME
"${universal_subdir}/${library_subdir}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
if(sdk STREQUAL WINDOWS OR sdk IN_LIST SWIFT_DARWIN_PLATFORMS)
set(install_dest "lib${LLVM_LIBDIR_SUFFIX}/${install_subdir}/${resource_dir_sdk_subdir}")
else()
set(install_dest "lib${LLVM_LIBDIR_SUFFIX}/${install_subdir}/${resource_dir_sdk_subdir}/${SWIFT_PRIMARY_VARIANT_ARCH}")
endif()
_add_swift_lipo_target(SDK
${sdk}
TARGET
Expand All @@ -2459,7 +2469,7 @@ function(add_swift_target_library name)
${THIN_INPUT_TARGETS_STATIC})
add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${lipo_target_static})
swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${install_subdir}/${resource_dir_sdk_subdir}"
DESTINATION "${install_dest}"
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
Expand Down Expand Up @@ -2531,8 +2541,13 @@ function(_add_swift_target_executable_single name)
set(link_flags)

# Prepare linker search directories.
set(library_search_directories
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
if(${SWIFTEXE_SINGLE_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS OR ${SWIFTEXE_SINGLE_SDK} STREQUAL WINDOWS)
set(library_search_directories
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
else()
set(library_search_directories
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}/${SWIFTEXE_SINGLE_ARCHITECTURE}")
endif()

# Add variant-specific flags.
_add_target_variant_c_compile_flags(
Expand Down
4 changes: 2 additions & 2 deletions test/Driver/environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

// RUN: %swift_driver_plain -sdk "" -target x86_64-unknown-gnu-linux -L/foo/ -driver-use-frontend-path %S/Inputs/print-var.sh %s LD_LIBRARY_PATH | %FileCheck -check-prefix=CHECK${LD_LIBRARY_PATH+_LAX} %s

// CHECK: {{^/foo/:[^:]+/lib/swift/linux$}}
// CHECK_LAX: {{^/foo/:[^:]+/lib/swift/linux}}
// CHECK: {{^/foo/:[^:]+/lib/swift/linux/x86_64$}}
// CHECK_LAX: {{^/foo/:[^:]+/lib/swift/linux/x86_64}}
12 changes: 6 additions & 6 deletions test/Driver/options-interpreter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
// CHECK-RESOURCE-DIR-ONLY: # DYLD_LIBRARY_PATH=/RSRC/macosx{{$}}

// RUN: %swift_driver_plain -sdk "" -### -target x86_64-unknown-linux-gnu -resource-dir /RSRC/ %s | %FileCheck -check-prefix=CHECK-RESOURCE-DIR-ONLY-LINUX${LD_LIBRARY_PATH+_LAX} %s
// CHECK-RESOURCE-DIR-ONLY-LINUX: # LD_LIBRARY_PATH=/RSRC/linux{{$}}
// CHECK-RESOURCE-DIR-ONLY-LINUX_LAX: # LD_LIBRARY_PATH=/RSRC/linux{{$|:}}
// CHECK-RESOURCE-DIR-ONLY-LINUX: # LD_LIBRARY_PATH=/RSRC/linux/x86_64{{$}}
// CHECK-RESOURCE-DIR-ONLY-LINUX_LAX: # LD_LIBRARY_PATH=/RSRC/linux/x86_64{{$|:}}

// RUN: %swift_driver_plain -sdk "" -### -target x86_64-apple-macosx10.9 -L/foo/ %s | %FileCheck -check-prefix=CHECK-L %s
// CHECK-L: # DYLD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/macosx$}}
Expand Down Expand Up @@ -61,9 +61,9 @@
// CHECK-COMPLEX-DAG: DYLD_LIBRARY_PATH={{/foo2/:/bar2/:[^:]+/lib/swift/macosx:/sdkroot/usr/lib/swift($| )}}

// RUN: %swift_driver_plain -sdk "" -### -target x86_64-unknown-linux-gnu -L/foo/ %s | %FileCheck -check-prefix=CHECK-L-LINUX${LD_LIBRARY_PATH+_LAX} %s
// CHECK-L-LINUX: # LD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/linux$}}
// CHECK-L-LINUX_LAX: # LD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/linux($|:)}}
// CHECK-L-LINUX: # LD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/linux/x86_64$}}
// CHECK-L-LINUX_LAX: # LD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/linux/x86_64($|:)}}

// RUN: env LD_LIBRARY_PATH=/abc/ %swift_driver_plain -### -target x86_64-unknown-linux-gnu -L/foo/ -L/bar/ %s | %FileCheck -check-prefix=CHECK-LINUX-COMPLEX${LD_LIBRARY_PATH+_LAX} %s
// CHECK-LINUX-COMPLEX: # LD_LIBRARY_PATH={{/foo/:/bar/:[^:]+/lib/swift/linux:/abc/$}}
// CHECK-LINUX-COMPLEX_LAX: # LD_LIBRARY_PATH={{/foo/:/bar/:[^:]+/lib/swift/linux:/abc/($|:)}}
// CHECK-LINUX-COMPLEX: # LD_LIBRARY_PATH={{/foo/:/bar/:[^:]+/lib/swift/linux/x86_64:/abc/$}}
// CHECK-LINUX-COMPLEX_LAX: # LD_LIBRARY_PATH={{/foo/:/bar/:[^:]+/lib/swift/linux/x86_64:/abc/($|:)}}
2 changes: 1 addition & 1 deletion test/Reflection/conformance_descriptors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// RUN: %empty-directory(%t)

// RUN: %target-build-swift %S/Inputs/ConcreteTypes.swift %S/Inputs/GenericTypes.swift %S/Inputs/Protocols.swift %S/Inputs/Extensions.swift %S/Inputs/Closures.swift %S/Inputs/Conformances.swift -parse-as-library -emit-module -emit-library -module-name ConformanceCheck -o %t/Conformances
// RUN: %target-swift-reflection-dump %t/Conformances %platform-module-dir/%target-library-name(swiftCore) | %FileCheck %s
// RUN: %target-swift-reflection-dump %t/Conformances %platform-dylib-dir/%target-library-name(swiftCore) | %FileCheck %s

// CHECK: CONFORMANCES:
// CHECK: =============
Expand Down
4 changes: 2 additions & 2 deletions test/Reflection/typeref_lowering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// RUN: %target-build-swift -Xfrontend -disable-availability-checking %S/Inputs/TypeLowering.swift -parse-as-library -emit-module -emit-library -module-name TypeLowering -o %t/%target-library-name(TypesToReflect)
// RUN: %target-build-swift -Xfrontend -disable-availability-checking %S/Inputs/TypeLowering.swift %S/Inputs/main.swift -emit-module -emit-executable -module-name TypeLowering -o %t/TypesToReflect

// RUN: %target-swift-reflection-dump %t/%target-library-name(TypesToReflect) %platform-module-dir/%target-library-name(swiftCore) -dump-type-lowering < %s | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// RUN: %target-swift-reflection-dump %t/TypesToReflect %platform-module-dir/%target-library-name(swiftCore) -dump-type-lowering < %s | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// RUN: %target-swift-reflection-dump %t/%target-library-name(TypesToReflect) %platform-dylib-dir/%target-library-name(swiftCore) -dump-type-lowering < %s | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// RUN: %target-swift-reflection-dump %t/TypesToReflect %platform-dylib-dir/%target-library-name(swiftCore) -dump-type-lowering < %s | %FileCheck %s --check-prefix=CHECK-%target-ptrsize

12TypeLowering11BasicStructV
// CHECK-64: (struct TypeLowering.BasicStruct)
Expand Down
3 changes: 3 additions & 0 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,9 @@ if platform.system() != 'Darwin':
platform_module_dir = make_path(test_resource_dir, config.target_sdk_name)

platform_dylib_dir = platform_module_dir
if platform.system() != 'Darwin':
platform_dylib_dir = make_path(test_resource_dir, relative_platform_module_dir_prefix)

if run_os == 'maccatalyst' and config.darwin_maccatalyst_build_flavor == "ios-like":
# When using the ios-macabi triple, look for module files
# in the 'maccatalyst' compiler resource directory.
Expand Down
6 changes: 3 additions & 3 deletions tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES)
# installed host toolchain.
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}")

target_link_libraries(${target} PRIVATE ${swiftrt})
target_link_libraries(${target} PRIVATE "swiftCore")
Expand All @@ -132,7 +132,7 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES)
if(ASKD_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
list(APPEND RPATH_LIST "${host_lib_dir}")
else()
file(RELATIVE_PATH relative_rtlib_path "${path}" "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
file(RELATIVE_PATH relative_rtlib_path "${path}" "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}")
list(APPEND RPATH_LIST "$ORIGIN/${relative_rtlib_path}")
endif()

Expand All @@ -144,7 +144,7 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES)

# At runtime link against the built swift libraries from the current
# bootstrapping stage.
file(RELATIVE_PATH relative_rtlib_path "${path}" "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
file(RELATIVE_PATH relative_rtlib_path "${path}" "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH}")
list(APPEND RPATH_LIST "$ORIGIN/${relative_rtlib_path}")

elseif(ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
Expand Down

0 comments on commit 119f295

Please sign in to comment.