diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp --- a/clang/lib/Driver/ToolChains/Fuchsia.cpp +++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -65,6 +65,12 @@ 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 --- 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 --- 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"