Skip to content

Commit c74605b

Browse files
authored
Merge pull request #2 from nerfur/openbsd
Openbsd
2 parents 77ea912 + f72c847 commit c74605b

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
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
@@ -497,6 +497,7 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public OSTargetInfo<Target> {
497497
this->MCountName = "_mcount";
498498
break;
499499
case llvm::Triple::riscv64:
500+
case llvm::Triple::loongarch64:
500501
break;
501502
}
502503
}

clang/lib/Driver/ToolChains/OpenBSD.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
167167
CmdArgs.push_back("--no-relax");
168168
}
169169

170+
if (Triple.isLoongArch64()) {
171+
CmdArgs.push_back("-X");
172+
if (Args.hasArg(options::OPT_mno_relax))
173+
CmdArgs.push_back("--no-relax");
174+
}
175+
170176
assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
171177
if (Output.isFilename()) {
172178
CmdArgs.push_back("-o");

clang/test/Driver/openbsd.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@
2929
// CHECK-MIPS64-CPU: "-target-cpu" "mips3"
3030
// CHECK-MIPS64EL-CPU: "-target-cpu" "mips3"
3131

32+
// Check that LoongArch passes the correct linker emulation.
33+
//
34+
// RUN: %clang --target=loongarch64-unknown-openbsd -### %s %s 2>&1 \
35+
// RUN: | FileCheck --check-prefix=CHECK-LA64-LD %s
36+
// CHECK-LA64-LD: ld{{.*}}" {{.*}} "-m" "elf64loongarch"
37+
//
38+
// Check options passed to the linker on LoongArch
39+
//
40+
// RUN: %clang --target=loongarch64-unknown-openbsd -mno-relax -### %s %s 2>&1 \
41+
// RUN: | FileCheck --check-prefix=CHECK-LA64-LD-OPTS %s
42+
// CHECK-LA64-LD-OPTS: ld{{.*}}" {{.*}} "-X" "--no-relax"
43+
//
44+
3245
// Check that the new linker flags are passed to OpenBSD
3346
// RUN: %clang --target=i686-pc-openbsd -r -### %s 2>&1 \
3447
// RUN: | FileCheck --check-prefix=CHECK-LD-R %s

0 commit comments

Comments
 (0)