Skip to content

Commit aae69e9

Browse files
nerfurtru
authored andcommitted
Adding Loongarch64 to OpenBSD parts (#149737)
Adding Loongarch64 to OpenBSD parts (cherry picked from commit 5eecbc0)
1 parent ee86ae0 commit aae69e9

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

clang/lib/Basic/Targets.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
769769
case llvm::Triple::FreeBSD:
770770
return std::make_unique<FreeBSDTargetInfo<LoongArch64TargetInfo>>(Triple,
771771
Opts);
772+
case llvm::Triple::OpenBSD:
773+
return std::make_unique<OpenBSDTargetInfo<LoongArch64TargetInfo>>(Triple,
774+
Opts);
772775
default:
773776
return std::make_unique<LoongArch64TargetInfo>(Triple, Opts);
774777
}

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public OSTargetInfo<Target> {
496496
case llvm::Triple::sparcv9:
497497
this->MCountName = "_mcount";
498498
break;
499+
case llvm::Triple::loongarch64:
499500
case llvm::Triple::riscv64:
500501
break;
501502
}

clang/lib/Driver/ToolChains/OpenBSD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
161161
if (Nopie || Profiling)
162162
CmdArgs.push_back("-nopie");
163163

164-
if (Triple.isRISCV64()) {
164+
if (Triple.isLoongArch64() || Triple.isRISCV64()) {
165165
CmdArgs.push_back("-X");
166166
if (Args.hasArg(options::OPT_mno_relax))
167167
CmdArgs.push_back("--no-relax");

clang/test/Driver/openbsd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@
127127
// UNWIND-TABLES: "-funwind-tables=2"
128128
// NO-UNWIND-TABLES-NOT: "-funwind-tables=2"
129129

130-
// Check that the -X and --no-relax flags are passed to the linker on riscv64
130+
// Check that the -X and --no-relax flags are passed to the linker
131+
// RUN: %clang --target=loongarch64-unknown-openbsd -mno-relax -### %s 2>&1 \
132+
// RUN: | FileCheck --check-prefix=LA64-FLAGS %s
131133
// RUN: %clang --target=riscv64-unknown-openbsd -mno-relax -### %s 2>&1 \
132134
// RUN: | FileCheck -check-prefix=RISCV64-FLAGS %s
135+
// LA64-FLAGS: "-X" "--no-relax"
133136
// RISCV64-FLAGS: "-X" "--no-relax"
134137

135138
// Check passing LTO flags to the linker

0 commit comments

Comments
 (0)