[llvm-branch-commits] [clang] 2150816 - [Driver][OpenBSD] -r: imply -nostdlib like GCC
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 7 10:54:48 PST 2022
Author: Brad Smith
Date: 2022-02-07T10:54:39-08:00
New Revision: 2150816e666ac0e7f9545f016457e82af83bcad2
URL: https://github.com/llvm/llvm-project/commit/2150816e666ac0e7f9545f016457e82af83bcad2
DIFF: https://github.com/llvm/llvm-project/commit/2150816e666ac0e7f9545f016457e82af83bcad2.diff
LOG: [Driver][OpenBSD] -r: imply -nostdlib like GCC
Similar to D116843 for Gnu.cpp
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D119071
(cherry picked from commit 1831cbd9d4174a93d4017e510ecf0f840af5f7d6)
Added:
Modified:
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/test/Driver/openbsd.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 96abac57764f7..bcd54bedfa897 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -160,7 +160,8 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
assert(Output.isNothing() && "Invalid output.");
}
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+ options::OPT_r)) {
const char *crt0 = nullptr;
const char *crtbegin = nullptr;
if (!Args.hasArg(options::OPT_shared)) {
@@ -191,7 +192,8 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+ options::OPT_r)) {
// Use the static OpenMP runtime with -static-openmp
bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
!Args.hasArg(options::OPT_static);
@@ -234,7 +236,8 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-lcompiler_rt");
}
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+ options::OPT_r)) {
const char *crtend = nullptr;
if (!Args.hasArg(options::OPT_shared))
crtend = "crtend.o";
diff --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index c2ffe2a0397cd..d6d5ae994e67e 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -40,8 +40,9 @@
// RUN: | FileCheck --check-prefix=CHECK-MIPS64-LD %s
// RUN: %clang -no-canonical-prefixes -target mips64el-unknown-openbsd %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
-// CHECK-LD-R: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-LD-R: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-r" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-LD-R: "-r"
+// CHECK-LD-R-NOT: "-l
+// CHECK-LD-R-NOT: crt{{[^.]+}}.o
// CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
// CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
// CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
More information about the llvm-branch-commits
mailing list