Skip to content

Fix multi-arch cross-compiling #13108

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

Closed
wants to merge 2 commits 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
206 changes: 153 additions & 53 deletions cmake/modules/AddSwift.cmake

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions cmake/modules/SwiftConfigureSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function(_report_sdk prefix)
message(STATUS " ${arch} LIB: ${${arch}_LIB}")
endforeach()
else()
message(STATUS " Path: ${SWIFT_SDK_${prefix}_PATH}")
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
message(STATUS " ${arch} Path: ${SWIFT_SDK_${prefix}_ARCH_${ARCH}_PATH}")
endforeach()
endif()
message(STATUS " Version: ${SWIFT_SDK_${prefix}_VERSION}")
message(STATUS " Build number: ${SWIFT_SDK_${prefix}_BUILD_NUMBER}")
Expand Down Expand Up @@ -122,6 +124,9 @@ macro(configure_sdk_darwin
set(SWIFT_SDK_${prefix}_OBJECT_FORMAT "MACHO")

foreach(arch ${architectures})
# On Darwin, all archs share the same SDK path.
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "${SWIFT_SDK_${prefix}_PATH}")

set(SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE
"${arch}-apple-${SWIFT_SDK_${prefix}_TRIPLE_NAME}${SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION}")
endforeach()
Expand All @@ -137,8 +142,10 @@ macro(configure_sdk_unix
# Note: this has to be implemented as a macro because it sets global
# variables.

# Todo: this only supports building an SDK for one target arch only.

set(SWIFT_SDK_${prefix}_NAME "${name}")
set(SWIFT_SDK_${prefix}_PATH "${sdkpath}")
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "${sdkpath}")
set(SWIFT_SDK_${prefix}_VERSION "don't use")
set(SWIFT_SDK_${prefix}_BUILD_NUMBER "don't use")
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "don't use")
Expand Down Expand Up @@ -186,6 +193,7 @@ macro(configure_sdk_windows prefix sdk_name environment architectures)
set(SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE
"${arch}-unknown-windows-${environment}")
endif()
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "/")
endforeach()

# Add this to the list of known SDKs.
Expand Down
38 changes: 31 additions & 7 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,17 @@ static void getRuntimeLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
getPlatformNameForTriple(TC.getTriple()));
}

/// Get the runtime library link path with the target triple's specific arch
/// library folder.
static void getRuntimeLibraryPathWithArch(SmallVectorImpl<char> &runtimeLibPath,
Copy link
Member

Choose a reason for hiding this comment

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

Can you call this getRuntimeSharedLibraryPathWithArch to match getRuntimeStaticLibraryPathWithArch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the non "WithArch" variant above this one calls doesn't use the "Shared" prefix. I could rename everything but it seemed more invasive.

const llvm::opt::ArgList &args,
const ToolChain &TC) {
getRuntimeLibraryPath(runtimeLibPath, args, TC);
llvm::sys::path::append(runtimeLibPath,
swift::getMajorArchitectureName(TC.getTriple()));

}

static void getClangLibraryPathOnDarwin(SmallVectorImpl<char> &libPath,
const ArgList &args,
const ToolChain &TC) {
Expand All @@ -1037,8 +1048,8 @@ static void getClangLibraryPathOnLinux(SmallVectorImpl<char> &libPath,
/// Get the runtime library link path for static linking,
/// which is platform-specific and found relative to the compiler.
static void getRuntimeStaticLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
const llvm::opt::ArgList &args,
const ToolChain &TC) {
const llvm::opt::ArgList &args,
const ToolChain &TC) {
// FIXME: Duplicated from CompilerInvocation, but in theory the runtime
// library link path and the standard library module import path don't
// need to be the same.
Expand All @@ -1056,6 +1067,18 @@ static void getRuntimeStaticLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
getPlatformNameForTriple(TC.getTriple()));
}

/// Get the runtime library path with the target triple's arch specific
/// directory.
static void getRuntimeStaticLibraryPathWithArch(
SmallVectorImpl<char> &runtimeLibPath,
const llvm::opt::ArgList &args,
const ToolChain &TC) {
getRuntimeStaticLibraryPath(runtimeLibPath, args, TC);
llvm::sys::path::append(runtimeLibPath,
swift::getMajorArchitectureName(TC.getTriple()));

}

ToolChain::InvocationInfo
toolchains::Darwin::constructInvocation(const InterpretJobAction &job,
const JobContext &context) const {
Expand Down Expand Up @@ -1477,7 +1500,7 @@ toolchains::GenericUnix::constructInvocation(const InterpretJobAction &job,
InvocationInfo II = ToolChain::constructInvocation(job, context);

SmallString<128> runtimeLibraryPath;
getRuntimeLibraryPath(runtimeLibraryPath, context.Args, *this);
getRuntimeLibraryPathWithArch(runtimeLibraryPath, context.Args, *this);

addPathEnvironmentVariableIfNeeded(II.ExtraEnvironment, "LD_LIBRARY_PATH",
":", options::OPT_L, context.Args,
Expand Down Expand Up @@ -1610,10 +1633,10 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
}

SmallString<128> SharedRuntimeLibPath;
getRuntimeLibraryPath(SharedRuntimeLibPath, context.Args, *this);
getRuntimeLibraryPathWithArch(SharedRuntimeLibPath, context.Args, *this);

SmallString<128> StaticRuntimeLibPath;
getRuntimeStaticLibraryPath(StaticRuntimeLibPath, context.Args, *this);
getRuntimeStaticLibraryPathWithArch(StaticRuntimeLibPath, context.Args, *this);

// Add the runtime library link path, which is platform-specific and found
// relative to the compiler.
Expand All @@ -1627,8 +1650,6 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
}

SmallString<128> swiftrtPath = SharedRuntimeLibPath;
llvm::sys::path::append(swiftrtPath,
swift::getMajorArchitectureName(getTriple()));
llvm::sys::path::append(swiftrtPath, "swiftrt.o");
Arguments.push_back(context.Args.MakeArgString(swiftrtPath));

Expand Down Expand Up @@ -1664,6 +1685,7 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
Arguments.push_back(context.Args.MakeArgString(StaticRuntimeLibPath));

SmallString<128> linkFilePath = StaticRuntimeLibPath;
llvm::sys::path::remove_filename(linkFilePath); // remove arch name
llvm::sys::path::append(linkFilePath, "static-executable-args.lnk");
auto linkFile = linkFilePath.str();

Expand All @@ -1677,6 +1699,7 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
Arguments.push_back(context.Args.MakeArgString(StaticRuntimeLibPath));

SmallString<128> linkFilePath = StaticRuntimeLibPath;
llvm::sys::path::remove_filename(linkFilePath); // remove arch name
llvm::sys::path::append(linkFilePath, "static-stdlib-args.lnk");
auto linkFile = linkFilePath.str();
if (llvm::sys::fs::is_regular_file(linkFile)) {
Expand Down Expand Up @@ -1711,6 +1734,7 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,

if (context.Args.hasArg(options::OPT_profile_generate)) {
SmallString<128> LibProfile(SharedRuntimeLibPath);
llvm::sys::path::remove_filename(LibProfile); // remove arch name
llvm::sys::path::remove_filename(LibProfile); // remove platform name
llvm::sys::path::append(LibProfile, "clang", "lib");

Expand Down
11 changes: 10 additions & 1 deletion lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ static void updateRuntimeLibraryPath(SearchPathOptions &SearchPathOpts,
llvm::SmallString<128> LibPath(SearchPathOpts.RuntimeResourcePath);

llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
if (Triple.isOSDarwin()) {
// On Darwin the library search path is where we store fat binaries.
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
}

llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
SearchPathOpts.RuntimeLibraryImportPath = LibPath.str();
if (!Triple.isOSDarwin()) {
// On platforms without fat binaries, we use the arch specific
// directory for searching for binaries. This is the same as the import
// path for modules.
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Why not sink the LibPath calculation into the Triple.isOSDarwin() or else case respectively?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I'll look at writing this be more clear with one branch instead of two. I was over optimizing trying to avoid creating two string allocs for the non-Darwin path at the sake of some clarity.

Basically:

if Darwin:
  RuntimeLibraryPath = /lib/swift/(platform)
else:
  RuntimeLibraryPath = /lib/swift/(platform)/(arch)

RuntimeLibraryImportPath = /lib/swift/(platform)/(arch)

void CompilerInvocation::setRuntimeResourcePath(StringRef Path) {
Expand Down
26 changes: 15 additions & 11 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,24 @@ foreach(sdk ${SWIFT_SDKS})
set(GLIBC_INCLUDE_PATH "/system/develop/headers/posix")
set(GLIBC_ARCH_INCLUDE_PATH "/system/develop/headers/posix")
set(GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH "/system/develop/headers/")
set(GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH "/system/develop/headers/")
else()
# Determine the location of glibc headers based on the target.
set(GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH "/usr/include")
set(GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH ${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH})
endif()
set(GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}")

# Some SDKs place their headers in architecture-specific subfolders.
if((${sdk} STREQUAL "LINUX" OR ${sdk} STREQUAL "FREEBSD") AND CMAKE_LIBRARY_ARCHITECTURE)
set(GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()
# Some SDKs place their headers in architecture-specific subfolders.
if(("${sdk}" STREQUAL "LINUX" OR "${sdk}" STREQUAL "FREEBSD") AND CMAKE_LIBRARY_ARCHITECTURE)
set(GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()

set(GLIBC_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}")
set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}")

if(NOT "${sdk}" STREQUAL "HAIKU")
set(GLIBC_INCLUDE_PATH "${SWIFT_SDK_${sdk}_PATH}/${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}")
set(GLIBC_ARCH_INCLUDE_PATH "${SWIFT_SDK_${sdk}_PATH}/${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}")
if(NOT "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}" STREQUAL "/")
set(GLIBC_INCLUDE_PATH "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}${GLIBC_INCLUDE_PATH}")
set(GLIBC_ARCH_INCLUDE_PATH "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}${GLIBC_ARCH_INCLUDE_PATH}")
endif()
endif()

set(glibc_modulemap_source "glibc.modulemap.gyb")
Expand All @@ -88,7 +92,7 @@ foreach(sdk ${SWIFT_SDKS})

# If this SDK is a target for a non-native host, create a native modulemap
# without a sysroot prefix. This is the one we'll install instead.
if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_PATH}" STREQUAL "/")
if(NOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}" STREQUAL "/")

set(glibc_sysroot_relative_modulemap_out "${module_dir}/sysroot-relative-modulemaps/glibc.modulemap")
handle_gyb_source_single(glibc_modulemap_native_target
Expand All @@ -106,7 +110,7 @@ foreach(sdk ${SWIFT_SDKS})
# FIXME: When SDK is a cross-compile target (SDK != Host), the generated
# modulemap will be relative to the Host, with hardcoded paths.
# It is not relocatable to the target platform itself.
# This only affects ANDROID right now, but could affect cross-compiled LINUX targets
# This affects any cross-compiled targets that use glibc.modulemap

swift_install_in_component(sdk-overlay
FILES "${glibc_modulemap_out}"
Expand Down
16 changes: 9 additions & 7 deletions stdlib/public/Platform/glibc.modulemap.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ module SwiftGlibc [system] {

// C standard library
module C {
% if CMAKE_SDK in ["LINUX", "ANDROID", "CYGWIN"]:
module features {
% if CMAKE_SDK == "LINUX":
header "${GLIBC_INCLUDE_PATH}/stdc-predef.h"
% end
header "${GLIBC_INCLUDE_PATH}/features.h"
export *
}
% end
% if CMAKE_SDK in ["LINUX", "FREEBSD", "CYGWIN", "HAIKU"]:
module complex {
header "${GLIBC_INCLUDE_PATH}/complex.h"
Expand Down Expand Up @@ -71,13 +80,6 @@ module SwiftGlibc [system] {
}
% end

% if CMAKE_SDK in ["LINUX", "ANDROID", "CYGWIN"]:
module features {
header "${GLIBC_INCLUDE_PATH}/features.h"
export *
}
% end

module ctype {
header "${GLIBC_INCLUDE_PATH}/ctype.h"
export *
Expand Down
6 changes: 0 additions & 6 deletions stdlib/public/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,6 @@ if(SWIFT_CHECK_ESSENTIAL_STDLIB)
endif()


set(shared_only_libs)
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
list(APPEND shared_only_libs swiftImageInspectionShared)
endif()

add_swift_library(swiftCore ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STDLIB_CORE
${SWIFTLIB_SOURCES}
# The copy_shim_headers target dependency is required to let the
Expand All @@ -257,6 +252,5 @@ add_swift_library(swiftCore ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STD
LINK_FLAGS ${swift_core_link_flags}
PRIVATE_LINK_LIBRARIES ${swift_core_private_link_libraries}
INCORPORATE_OBJECT_LIBRARIES swiftRuntime swiftStdlibStubs
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY ${shared_only_libs}
FRAMEWORK_DEPENDS ${swift_core_framework_depends}
INSTALL_IN_COMPONENT stdlib)
59 changes: 25 additions & 34 deletions stdlib/public/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,43 +80,34 @@ set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags})
list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS)
list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/include)

set(sdk "${SWIFT_HOST_VARIANT_SDK}")
if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
list(REMOVE_ITEM swift_runtime_sources ImageInspectionELF.cpp)
if(SWIFT_BUILD_STATIC_STDLIB)
set(static_binary_lnk_file_list)
string(TOLOWER "${sdk}" lowercase_sdk)
foreach(sdk ${SWIFT_SDKS})
if(NOT "${sdk}" STREQUAL "LINUX" AND
NOT "${sdk}" STREQUAL "FREEBSD" AND
NOT "${sdk}" STREQUAL "ANDROID")
continue()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe only these SDKs will work with the static-executable-args.lnk file we have now. The arguments in that file are linux specific. We should in theory dynamically generate it like we do with the gen-static-stdlib script instead.

endif()

# These two libraries are only used with the static swiftcore
add_swift_library(swiftImageInspectionShared STATIC
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
LINK_FLAGS ${swift_runtime_linker_flags})
set_target_properties(swiftImageInspectionShared PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}")

# Generate the static-executable-args.lnk file used for ELF systems (eg linux)
set(linkfile "${lowercase_sdk}/static-executable-args.lnk")
add_custom_command_target(swift_static_binary_${sdk}_args
COMMAND
"${CMAKE_COMMAND}" -E copy
"${SWIFT_SOURCE_DIR}/utils/static-executable-args.lnk"
"${SWIFTSTATICLIB_DIR}/${linkfile}"
OUTPUT
"${SWIFTSTATICLIB_DIR}/${linkfile}"
DEPENDS
"${SWIFT_SOURCE_DIR}/utils/static-executable-args.lnk")

list(APPEND static_binary_lnk_file_list ${swift_static_binary_${sdk}_args})
swift_install_in_component(stdlib
FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
DESTINATION "lib/swift_static/${lowercase_sdk}")
string(TOLOWER "${sdk}" lowercase_sdk)
# Generate the static-executable-args.lnk file used for ELF systems (eg linux)
set(linkfile "${lowercase_sdk}/static-executable-args.lnk")
add_custom_command_target(swift_static_binary_${sdk}_args
COMMAND
"${CMAKE_COMMAND}" -E copy
"${SWIFT_SOURCE_DIR}/utils/static-executable-args.lnk"
"${SWIFTSTATICLIB_DIR}/${linkfile}"
OUTPUT
"${SWIFTSTATICLIB_DIR}/${linkfile}"
DEPENDS
"${SWIFT_SOURCE_DIR}/utils/static-executable-args.lnk")

list(APPEND static_binary_lnk_file_list ${swift_static_binary_${sdk}_args})
swift_install_in_component(stdlib
FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
DESTINATION "lib/swift_static/${lowercase_sdk}")
endforeach()
add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list})

add_swift_library(swiftImageInspectionShared OBJECT_LIBRARY TARGET_LIBRARY
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
LINK_FLAGS ${swift_runtime_linker_flags}
INSTALL_IN_COMPONENT never_install)
endif()

add_swift_library(swiftRuntime OBJECT_LIBRARY TARGET_LIBRARY
Expand Down
11 changes: 10 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,18 @@ foreach(SDK ${SWIFT_SDKS})
list(APPEND test_dependencies "touch-covering-tests")
endif()

set(validation_test_dependencies
is_darwin_based_sdk("${SDK}" IS_DARWIN)
if (IS_DARWIN)
# use lipo targets as dependencies
set(validation_test_dependencies
"swiftStdlibCollectionUnittest-${SWIFT_SDK_${SDK}_LIB_SUBDIR}"
"swiftStdlibUnicodeUnittest-${SWIFT_SDK_${SDK}_LIB_SUBDIR}")
else()
# use arch specific targets as dependencies on platforms without fat binaries
set(validation_test_dependencies
"swiftStdlibCollectionUnittest${VARIANT_SUFFIX}"
"swiftStdlibUnicodeUnittest${VARIANT_SUFFIX}")
endif()

set(command_upload_stdlib)
set(command_upload_swift_reflection_test)
Expand Down
4 changes: 2 additions & 2 deletions test/Driver/environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

// RUN: %swift_driver -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 -### -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 -### -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($| )}}

// RUN: %swift_driver -### -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/($|:)}}
Loading