Skip to content

Commit

Permalink
[Driver] Use ld.lld directly for Fuchsia rather than passing flavor
Browse files Browse the repository at this point in the history
Passing a flavor to LLD requires command line argument, but if these
are being passed through a response file, this will fail because LLD
needs to know which driver to use before processing the response file.
Use ld.lld directly instead to avoid this issue.

Differential Revision: https://reviews.llvm.org/D39176

llvm-svn: 316379
  • Loading branch information
petrhosek committed Oct 23, 2017
1 parent 089dac7 commit 3e199ec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions clang/lib/Driver/ToolChains/Fuchsia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Args.ClaimAllArgs(options::OPT_w);

const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
if (llvm::sys::path::stem(Exec).equals_lower("lld")) {
CmdArgs.push_back("-flavor");
CmdArgs.push_back("gnu");

if (llvm::sys::path::filename(Exec).equals_lower("ld.lld") ||
llvm::sys::path::stem(Exec).equals_lower("ld.lld")) {
CmdArgs.push_back("-z");
CmdArgs.push_back("rodynamic");
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Fuchsia.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain {
llvm::opt::ArgStringList &CmdArgs) const override;

const char *getDefaultLinker() const override {
return "lld";
return "ld.lld";
}

protected:
Expand Down
7 changes: 3 additions & 4 deletions clang/test/Driver/fuchsia.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// RUN: %clang %s -### -no-canonical-prefixes --target=x86_64-unknown-fuchsia \
// RUN: --sysroot=%S/platform -fuse-ld=ld 2>&1 \
// RUN: --sysroot=%S/platform 2>&1 \
// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
// RUN: %clang %s -### -no-canonical-prefixes --target=aarch64-unknown-fuchsia \
// RUN: --sysroot=%S/platform -fuse-ld=ld 2>&1 \
// RUN: --sysroot=%S/platform 2>&1 \
// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
// CHECK: {{.*}}clang{{.*}}" "-cc1"
// CHECK: "-munwind-tables"
// CHECK: "-fuse-init-array"
// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|\\\\}}include"
// CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
// CHECK: "-z" "rodynamic"
// CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic"
// CHECK: "--sysroot=[[SYSROOT]]"
// CHECK: "-pie"
// CHECK: "--build-id"
Expand Down
5 changes: 2 additions & 3 deletions clang/test/Driver/fuchsia.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// RUN: %clangxx %s -### -no-canonical-prefixes --target=x86_64-unknown-fuchsia \
// RUN: --sysroot=%S/platform 2>&1 -fuse-ld=ld | FileCheck %s
// RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
// CHECK: {{.*}}clang{{.*}}" "-cc1"
// CHECK: "-triple" "x86_64-fuchsia"
// CHECK: "-fuse-init-array"
// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK: "-internal-isystem" "{{.*[/\\]}}x86_64-fuchsia{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|\\\\}}include"
// CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
// CHECK: "-z" "rodynamic"
// CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic"
// CHECK: "--sysroot=[[SYSROOT]]"
// CHECK: "-pie"
// CHECK: "--build-id"
Expand Down

0 comments on commit 3e199ec

Please sign in to comment.