Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,8 +1534,6 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
addPrimaryInputsOfType(Arguments, context.Inputs, types::TY_Object);
addInputsOfType(Arguments, context.InputActions, types::TY_Object);

context.Args.AddAllArgs(Arguments, options::OPT_Xlinker);
context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group);
for (const Arg *arg : context.Args.filtered(options::OPT_F,
options::OPT_Fsystem)) {
if (arg->getOption().matches(options::OPT_Fsystem))
Expand Down Expand Up @@ -1609,6 +1607,9 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
}

context.Args.AddAllArgs(Arguments, options::OPT_Xlinker);
context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group);

// Just before the output option, allow GenericUnix toolchains to add
// additional inputs.
auto PostInputObjectPath = getPostInputObjectPath(ObjectLibPath);
Expand Down
11 changes: 11 additions & 0 deletions test/Driver/linker-args-order-linux.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Statically link a "hello world" program
// REQUIRES: OS=linux-gnu
// REQUIRES: static_stdlib
print("hello world!")
// RUN: %empty-directory(%t)
// RUN: %target-swiftc_driver -v -static-stdlib -o %t/static-stdlib %s -Xlinker --no-allow-multiple-definition 2>&1| %FileCheck %s
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to actually run the linker here. Instead, you can use -### (or -driver-print-jobs) to show what would be run. That way we can run the test on other platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want me to update the test? The argument reordering change is only for Linux (actually GenericUnix) so I don't think it will make any difference on other platforms.

Copy link
Contributor

@jrose-apple jrose-apple Jul 13, 2017

Choose a reason for hiding this comment

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

Yes, please. GenericUnix is still used in other places, and it's useful to be able to run the test even on Darwin. (Also, not actually compiling and linking would run faster.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jrose-apple Ive added the -driver-print-jobs and removed the linux requirement. It tested ok on Linux and macOS. If the commit looks ok could you rerun the tests please.

// CHECK: Swift version
// CHECK: Target: x86_64-unknown-linux-gnu
// CHECK: {{.*}}/swift -frontend -c -primary-file {{.*}}/linker-args-order-linux.swift -target x86_64-unknown-linux-gnu -disable-objc-interop
// CHECK: {{.*}}/swift-autolink-extract{{.*}}
// CHECK: {{.*}}swift_begin.o /{{.*}}/linker-args-order-linux-{{[a-z0-9]+}}.o @/{{.*}}/linker-args-order-linux-{{[a-z0-9]+}}.autolink {{.*}} @{{.*}}/static-stdlib-args.lnk {{.*}} -Xlinker --no-allow-multiple-definition {{.*}}/swift_end.o