Skip to content

Add -no-toolchain-stdlib-rpath flag. #27207

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

Merged
merged 3 commits into from
Sep 21, 2019
Merged
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
3 changes: 3 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ def no_static_stdlib: Flag<["-"], "no-static-stdlib">,
def toolchain_stdlib_rpath: Flag<["-"], "toolchain-stdlib-rpath">,
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
HelpText<"Add an rpath entry for the toolchain's standard library, rather than the OS's">;
def no_toolchain_stdlib_rpath: Flag<["-"], "no-toolchain-stdlib-rpath">,
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
HelpText<"Do not add an rpath entry for the toolchain's standard library (default)">;
def no_stdlib_rpath: Flag<["-"], "no-stdlib-rpath">,
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
HelpText<"Don't add any rpath entries.">;
Expand Down
3 changes: 2 additions & 1 deletion lib/Driver/DarwinToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ toolchains::Darwin::addArgsToLinkStdlib(ArgStringList &Arguments,
Arguments.push_back(context.Args.MakeArgString(path));
}

if (context.Args.hasArg(options::OPT_toolchain_stdlib_rpath)) {
if (context.Args.hasFlag(options::OPT_toolchain_stdlib_rpath,
options::OPT_no_toolchain_stdlib_rpath, false)) {
// If the user has explicitly asked for a toolchain stdlib, we should
// provide one using -rpath. This used to be the default behaviour but it
// was considered annoying in at least the SwiftPM scenario (see
Expand Down
4 changes: 4 additions & 0 deletions test/Driver/linker-rpath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
// RUN: %swiftc_driver_plain -driver-print-jobs -toolchain-stdlib-rpath -target x86_64-apple-macosx10.9 %S/../Inputs/empty.swift -resource-dir garbage/ | %FileCheck -check-prefix TOOLCHAIN-RPATH -DPLATFORM=%target-sdk-name %s
// RUN: %swiftc_driver_plain -driver-print-jobs -toolchain-stdlib-rpath -target x86_64-apple-macosx10.15 %S/../Inputs/empty.swift -resource-dir garbage/ | %FileCheck -check-prefix TOOLCHAIN-RPATH -DPLATFORM=%target-sdk-name %s

// ### Test with -no-toolchain-stdlib-rpath
// RUN: %swiftc_driver_plain -driver-print-jobs -no-toolchain-stdlib-rpath -target x86_64-apple-macosx10.9 %S/../Inputs/empty.swift | %FileCheck -check-prefix RPATH %s
// RUN: %swiftc_driver_plain -driver-print-jobs -no-toolchain-stdlib-rpath -target x86_64-apple-macosx10.15 %S/../Inputs/empty.swift | %FileCheck -check-prefix NO-RPATH %s

// TOOLCHAIN-RPATH: bin/ld{{"? }}
// TOOLCHAIN-RPATH-SAME: -rpath garbage/[[PLATFORM]]{{ }}
// TOOLCHAIN-RPATH-SAME: -o {{[^ ]+}}