[clang] [clang][Driver] Don't force a linker emulation on FreeBSD/LoongArch (PR #249442)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 6 08:21:15 PST 2026
https://github.com/hitmoon created https://github.com/llvm/llvm-project/pull/249442
The FreeBSD LoongArch driver passes -m elf64loongarch, which overrides lld's inference of the target OSABI from the input objects. Native shared libraries are tagged ELFOSABI_NONE (System V); pkg treats them as non-native and skips their shlibs_provided, breaking dependency installation (e.g. "Missing shlib libintl.so.8").
>From 5d947f86595e4b5b7f02884e0a9a3e12afb44652 Mon Sep 17 00:00:00 2001
From: xiaoqiang zhao <zxq_yx_007 at 163.com>
Date: Sun, 6 Dec 2026 10:57:12 +0800
Subject: [PATCH] [clang][Driver] Don't force a linker emulation on
FreeBSD/LoongArch
The FreeBSD LoongArch driver passes -m elf64loongarch, which overrides
lld's inference of the target OSABI from the input objects. Native
shared libraries are tagged ELFOSABI_NONE (System V); pkg treats them as
non-native and skips their shlibs_provided, breaking dependency
installation (e.g. "Missing shlib libintl.so.8").
Signed-off-by: xiaoqiang zhao <zxq_yx_007 at 163.com>
---
clang/lib/Driver/ToolChains/FreeBSD.cpp | 4 ----
clang/test/Driver/freebsd.c | 7 +++++--
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index dbcb74bf017f63..26c01c3ad239a1 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -191,10 +191,6 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-m");
CmdArgs.push_back("elf64lriscv");
break;
- case llvm::Triple::loongarch64:
- CmdArgs.push_back("-m");
- CmdArgs.push_back("elf64loongarch");
- break;
default:
break;
}
diff --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c
index 08498d98e61dec..2d3a2787069340 100644
--- a/clang/test/Driver/freebsd.c
+++ b/clang/test/Driver/freebsd.c
@@ -89,11 +89,14 @@
// RUN: | FileCheck --check-prefix=CHECK-RV64I-LD %s
// CHECK-RV64I-LD: ld{{.*}}" {{.*}} "-m" "elf64lriscv"
//
-// Check that LoongArch passes the correct linker emulation.
+// Check that LoongArch does not force a linker emulation: lld infers the
+// target and OSABI from the input objects.
//
// RUN: %clang --target=loongarch64-freebsd -### %s %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-LA64-LD %s
-// CHECK-LA64-LD: ld{{.*}}" {{.*}} "-m" "elf64loongarch"
+// CHECK-LA64-LD: ld{{.*}}" "--eh-frame-hdr"
+// CHECK-LA64-LD-NOT: "-m" "elf64loongarch"
+// CHECK-LA64-LD-SAME: "-X"
//
// Check options passed to the linker on LoongArch
//
More information about the cfe-commits
mailing list