[clang] 5dfc8eb - [Driver][Fuchsia] Add default linker flags
Alex Brachet via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 30 07:07:51 PDT 2022
Author: Alex Brachet
Date: 2022-09-30T14:07:41Z
New Revision: 5dfc8ebee5d688ee94607ccce655672c1a198b82
URL: https://github.com/llvm/llvm-project/commit/5dfc8ebee5d688ee94607ccce655672c1a198b82
DIFF: https://github.com/llvm/llvm-project/commit/5dfc8ebee5d688ee94607ccce655672c1a198b82.diff
LOG: [Driver][Fuchsia] Add default linker flags
Differential Revision: https://reviews.llvm.org/D132416
Added:
Modified:
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c
clang/test/Driver/fuchsia.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 6f4fa2ce7c40a..2e47a96bcfe3f 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -65,6 +65,12 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-z");
CmdArgs.push_back("rel");
CmdArgs.push_back("--pack-dyn-relocs=relr");
+ } else {
+ // The following are already the default in lld
+ CmdArgs.push_back("-z");
+ CmdArgs.push_back("combreloc");
+ CmdArgs.push_back("-z");
+ CmdArgs.push_back("text");
}
if (!D.SysRoot.empty())
diff --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 099a88c2e4e36..00c763a140c30 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -1,27 +1,35 @@
// RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --sysroot=%S/platform 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --sysroot=%S/platform -fuse-ld=gold 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LD,CHECK-X86_64 %s
// RUN: %clang -### %s --target=aarch64-unknown-fuchsia \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
// RUN: %clang -### %s --target=riscv64-unknown-fuchsia \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
// RUN: %clang -### %s --target=x86_64-fuchsia \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
// RUN: %clang -### %s --target=aarch64-fuchsia \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
// RUN: %clang -### %s --target=riscv64-fuchsia \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
// CHECK: "-cc1"
// CHECK-X86_64: "-triple" "x86_64-unknown-fuchsia"
// CHECK-AARCH64: "-triple" "aarch64-unknown-fuchsia"
@@ -36,7 +44,8 @@
// CHECK: "-stack-protector" "2"
// CHECK-AARCH64: "-target-feature" "+outline-atomics"
// CHECK-NOT: "-fcommon"
-// CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr"
+// CHECK-LLD: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr"
+// CHECK-LD: {{.*}}ld.gold{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "combreloc" "-z" "text"
// CHECK: "--sysroot=[[SYSROOT]]"
// CHECK: "-pie"
// CHECK: "--build-id"
diff --git a/clang/test/Driver/fuchsia.cpp b/clang/test/Driver/fuchsia.cpp
index e5640f5826271..e247c76dabdd7 100644
--- a/clang/test/Driver/fuchsia.cpp
+++ b/clang/test/Driver/fuchsia.cpp
@@ -2,32 +2,42 @@
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --sysroot=%S/platform 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --sysroot=%S/platform -fuse-ld=gold 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LD,CHECK-X86_64 %s
// RUN: %clangxx -### %s --target=aarch64-unknown-fuchsia \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
// RUN: %clangxx -### %s --target=riscv64-unknown-fuchsia \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
// RUN: %clangxx -### %s --target=x86_64-fuchsia \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
// RUN: %clangxx -### %s --target=aarch64-fuchsia \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
// RUN: %clangxx -### %s --target=riscv64-fuchsia \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
// CHECK: "-cc1"
// CHECK-X86_64: "-triple" "x86_64-unknown-fuchsia"
// CHECK-AARCH64: "-triple" "aarch64-unknown-fuchsia"
@@ -40,7 +50,8 @@
// CHECK-RISCV64: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}riscv64-unknown-fuchsia{{/|\\\\}}c++{{/|\\\\}}v1"
// CHECK: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}c++{{/|\\\\}}v1"
// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|\\\\}}include"
-// CHECK: {{.*}}ld.lld{{.*}}" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments"
+// CHECK-LLD: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr"
+// CHECK-LD: {{.*}}ld.gold{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "combreloc" "-z" "text"
// CHECK: "--sysroot=[[SYSROOT]]"
// CHECK: "-pie"
// CHECK: "--build-id"
More information about the cfe-commits
mailing list