Skip to content

Commit

Permalink
[Driver] Replace usage of -Bshareable linker flag with -shared (#65842)
Browse files Browse the repository at this point in the history
The two flags mean the same thing for the bfd / lld linkers so just use
the same flag consistently everywhere.
  • Loading branch information
brad0 committed Sep 10, 2023
1 parent cbd6ac6 commit 18b6e21
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/DragonFly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
if (Args.hasArg(options::OPT_shared))
CmdArgs.push_back("-Bshareable");
CmdArgs.push_back("-shared");
else if (!Args.hasArg(options::OPT_r)) {
CmdArgs.push_back("-dynamic-linker");
CmdArgs.push_back("/usr/libexec/ld-elf.so.2");
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/FreeBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
if (Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back("-Bshareable");
CmdArgs.push_back("-shared");
} else if (!Args.hasArg(options::OPT_r)) {
CmdArgs.push_back("-dynamic-linker");
CmdArgs.push_back("/libexec/ld-elf.so.1");
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/NetBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
if (Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back("-Bshareable");
CmdArgs.push_back("-shared");
} else if (!Args.hasArg(options::OPT_r)) {
Args.AddAllArgs(CmdArgs, options::OPT_pie);
CmdArgs.push_back("-dynamic-linker");
Expand Down
1 change: 1 addition & 0 deletions clang/test/Driver/freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
// RUN: %clang --target=x86_64-pc-freebsd -shared %s \
// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-SHARED %s
// CHECK-SHARED: ld{{.*}}" "--eh-frame-hdr" "-shared"
// CHECK-SHARED: crti.o
// CHECK-SHARED: crtbeginS.o

Expand Down
12 changes: 6 additions & 6 deletions clang/test/Driver/netbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@

// STATIC: ld{{.*}}" "--eh-frame-hdr"
// STATIC-NOT: "-pie"
// STATIC-NOT: "-Bshareable"
// STATIC-NOT: "-shared"
// STATIC: "-dynamic-linker" "/libexec/ld.elf_so"
// STATIC-NOT: "-pie"
// STATIC-NOT: "-Bshareable"
// STATIC-NOT: "-shared"
// STATIC: "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
// STATIC: "{{.*}}/usr/lib{{/|\\\\}}crti.o" "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o"
// STATIC: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"

// STATIC-PIE: ld{{.*}}" "--eh-frame-hdr"
// STATIC-PIE-NOT: "-dynamic-linker" "/libexec/ld.elf_so"
// STATIC-PIE-NOT: "-Bshareable"
// STATIC-PIE-NOT: "-shared"
// STATIC-PIE: "-pie"
// STATIC-PIE-NOT: "-dynamic-linker" "/libexec/ld.elf_so"
// STATIC-PIE-NOT: "-Bshareable"
// STATIC-PIE-NOT: "-shared"
// STATIC-PIE: "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
// STATIC-PIE: "{{.*}}/usr/lib{{/|\\\\}}crti.o" "{{.*}}/usr/lib{{/|\\\\}}crtbeginS.o"
// STATIC-PIE: "{{.*}}/usr/lib{{/|\\\\}}crtendS.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
Expand All @@ -142,9 +142,9 @@
// SHARED: "{{.*}}/usr/lib{{/|\\\\}}crtendS.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"

// PIE: ld{{.*}}" "--eh-frame-hdr"
// PIE-NOT: "-Bshareable"
// PIE-NOT: "-shared"
// PIE: "-pie" "-dynamic-linker" "/libexec/ld.elf_so"
// PIE-NOT: "-Bshareable"
// PIE-NOT: "-shared"
// PIE: "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
// PIE: "{{.*}}/usr/lib{{/|\\\\}}crtbeginS.o"
// PIE: "{{.*}}/usr/lib{{/|\\\\}}crtendS.o"
Expand Down

0 comments on commit 18b6e21

Please sign in to comment.