Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unix] Move all ELF SDK runtime libraries into their own architecture-specific directories #63782

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,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}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this preserve compatibility with existing toolchains?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, no, it will not on these ELF platforms. I always build with the latest Swift compiler though, so if others do the same, it will work fine. There may be a way to keep compatibility, but as I noted above about continuing to keep these libraries in the module directory when bootstrapping, I am not about to dig through the CMake config to add that for a usecase that almost nobody is likely using (I currently have bootstrapping turned off on Android because of #60272).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently have bootstrapping turned off on Android because of #60272

Out of curiosity, won’t this make Regex literal (which should be an official Swift 5.7 feature) unsupported? I suppose (at least the Swift piece of) bootstrapping is mandatory now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, regex literals don't work for the upcoming Swift 5.8 that I have been testing out natively on Android, finagolfin/termux-packages@a1befe6, but they should work on the current 5.7.3 release with bootstrapping enabled, as 5.7 was branched before those LLVM issues discussed in that bug.


target_link_libraries(${target} PRIVATE ${swiftrt})
target_link_libraries(${target} PRIVATE "swiftCore")
Expand All @@ -548,7 +548,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 @@ -563,7 +563,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
3 changes: 3 additions & 0 deletions cmake/modules/SwiftUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ function(get_bootstrapping_swift_lib_dir bs_lib_dir bootstrapping)
if(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
set(lib_dir
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
if(NOT ${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
set(lib_dir "${lib_dir}/${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 @@ -1452,6 +1452,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()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in if (!Triple.isOSDarwin())? I would prefer to turn these lines into a single if, eg:

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this last line applies to Darwin, as there it simply does not add the architecture, so it is the same as LibPath before. Your code leaves out the SearchPathOpts.RuntimeLibraryPaths.clear(), which is needed because this function is run multiple times.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(runtimeLibPath.str()));
SearchPathOpts.RuntimeLibraryPaths.push_back(runtimeLibPath.str().str());

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@compnerd, just seeing this suggestion now, missed this when you wrote it a week back. Since this is changing unrelated behavior to my simple renaming, can we get your change in in a subsequent pull? I just don't want to start another hours-long CI run for this unrelated update.

if (Triple.isOSDarwin())
SearchPathOpts.RuntimeLibraryPaths.push_back(DARWIN_OS_LIBRARY_PATH);

Expand Down
31 changes: 22 additions & 9 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -803,11 +803,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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be possible to continue placing the bootstrapping libraries in a non-architecture-specific directory like on Darwin, then only link the rpath for the final bootstrapped Swift compiler against the architecture-specific directory, but I'm not interested in digging into all the CMake config to make that happen.

It is easier to simply place the bootstrapping libraries in architecture-specific directories too on ELF platforns. I don't check for Windows here because my understanding is that bootstrapping the compiler doesn't work on Windows: @compnerd, correct me if I'm wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, bootstrapping isn't enabled yet on Windows.

# (avoiding to lipo/copy the library).
set(output_sub_dir ${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR})
endif()
Expand Down Expand Up @@ -1257,11 +1257,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}")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused, so I removed it.

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 @@ -1487,8 +1488,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 @@ -2377,8 +2380,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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally kept things the same on Windows, even though it already moved to architecture-specific directories. @compnerd, if you want me to consolidate Windows more, as I did in the compiler, let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a fan of having fewer cases, as long as things continue to work, I don't mind seeing things becoming uniform :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe Windows is no different from Generic Unix here, so let’s make Darwin the only special case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what Windows needs, which is why I mentioned this. Before, all three of Windows, Darwin, and Unix were installing here to toolchain-os-arch/usr/lib/swift/os, which is only done when cross-compiling the stdlib for Windows because the first block above is invoked instead when natively compiling the stdlib on Windows.

Now that I'm moving Unix to this architecture-specific install directory, I wasn't sure if the same would work when cross-compiling the Windows stdlib, so I left it the same. If you think that will work for cross-compiling the Windows stdlib too, I will change it, but it will be untested, unless one of you tries it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should assume that it will be the same and should be safe to make this elseif (sdk IN_LIST SWIFT_DARWIN_PLATFORMS).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, can you add that later for Windows? I don't want to kick off another whole CI run for this unimportant change, would rather just get these pulls in first.

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 @@ -2454,6 +2459,10 @@ 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}")
set(install_dest "lib${LLVM_LIBDIR_SUFFIX}/${install_subdir}/${resource_dir_sdk_subdir}")
if(NOT sdk STREQUAL WINDOWS AND NOT sdk IN_LIST SWIFT_DARWIN_PLATFORMS)
set(install_dest "${install_dest}/${SWIFT_PRIMARY_VARIANT_ARCH}")
endif()
_add_swift_lipo_target(SDK
${sdk}
TARGET
Expand All @@ -2463,7 +2472,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 @@ -2542,6 +2551,10 @@ function(_add_swift_target_executable_single name)
# Prepare linker search directories.
set(library_search_directories
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
if(NOT ${SWIFTEXE_SINGLE_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS AND NOT ${SWIFTEXE_SINGLE_SDK} STREQUAL WINDOWS)
set(library_search_directories
"${library_search_directories}/${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 @@ -59,9 +59,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
Copy link
Member Author

@finagolfin finagolfin Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the platform-dylib-dir is different from the platform-module-dir, this is the right path. Most tests use this platform-dylib-dir/%target-library-name formulation, except for two more mac-only tests added in recent years.

@artemcm or @al45tair, let me know if I should change those two also.


// 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
Loading