Bug#1107858: libc++-19-dev: Can't link libc++.a to large binaries like chromium on loong64

Jianfeng Liu liujianfeng1994 at gmail.com
Mon Jun 16 03:13:43 BST 2025


Package: libc++-19-dev
Version: 1:19.1.7-3+b1
Severity: normal
Tags: patch
X-Debbugs-Cc: debian-loongarch at lists.debian.org
User: debian-loongarch at lists.debian.org
Usertags: loong64

Chromium is linking libc++ staticly since 137.0.7151.103-1. While on 
LoongArch64 platform
the default code model normal provides 256MiB PC-relative addressing 
space[1], which is not
enough for chromium. I will get following errors like:

ld.lld-19: error: 
/lib/loongarch64-linux-gnu/libc++.a(cxa_demangle.cpp.o):(function 
(anonymous 
namespace)::itanium_demangle::AbstractManglingParser<(anonymous 
namespace)::itanium_demangle::ManglingParser<(anonymous 
namespace)::DefaultAllocator>, (anonymous 
namespace)::DefaultAllocator>::parseEncoding(bool): 
.text._ZN12_GLOBAL__N_116itanium_demangle22AbstractManglingParserINS0_14ManglingParserINS_16DefaultAllocatorEEES3_E13parseEncodingEb+0x910): 
relocation R_LARCH_B26 out of range: 239992688 is not in [-134217728, 
134217727]; references 'memmove'

After recompiling llvm with code model medium, chromium can get linked
fine.

Here is my patch setting medium code model:

diff --git a/debian/rules b/debian/rules
index b3909dc2..6b7f1a77 100755
--- a/debian/rules
+++ b/debian/rules
@@ -155,6 +155,11 @@ CFLAGS_EXTRA = -Wno-unused-command-line-argument
CXXFLAGS_EXTRA = -Wno-unused-command-line-argument
LDFLAGS_EXTRA = -Wl,--build-id

+ifeq (loong64,$(DEB_HOST_ARCH))
+ CFLAGS_EXTRA += -mcmodel=medium
+ CXXFLAGS_EXTRA += -mcmodel=medium
+endif
+
# collect all flags for stage 1 toolchain build only
STAGE_1_CFLAGS = $(CFLAGS) $(CFLAGS_EXTRA) $(CPPFLAGS)
STAGE_1_CXXFLAGS = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(CPPFLAGS)
@@ -1031,8 +1036,8 @@ endif
touch $@

# Remove some new flags introduced by dpkg 1.22.0;
-STAGE_2_WASM_CFLAGS := $(filter-out -march=% -mfpu=% -fcf-protection% 
-mbranch-protection%, $(STAGE_2_CFLAGS))
-STAGE_2_WASM_CXXFLAGS := $(filter-out -march=% -mfpu=% -fcf-protection% 
-mbranch-protection%, $(STAGE_2_CXXFLAGS))
+STAGE_2_WASM_CFLAGS := $(filter-out -march=% -mfpu=% -fcf-protection% 
-mbranch-protection% -mcmodel=%, $(STAGE_2_CFLAGS))
+STAGE_2_WASM_CXXFLAGS := $(filter-out -march=% -mfpu=% -fcf-protection% 
-mbranch-protection% -mcmodel=%, $(STAGE_2_CXXFLAGS))

build-wasm/compiler-rt-%: cpu = $(@:build-wasm/compiler-rt-%=%)
build-wasm/compiler-rt-%:

[1] 
https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#code_models


-- System Information:
Debian Release: 13.0
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: loong64 (loongarch64)
Foreign Architectures: amd64

Kernel: Linux 6.15-loong64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=zh_CN.UTF-8, LC_CTYPE=zh_CN.UTF-8 (charmap=UTF-8), 
LANGUAGE=zh_CN:zh
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libc++-19-dev depends on:
ii libc++1-19 1:19.1.7-3+b1
ii libc++abi-19-dev 1:19.1.7-3+b1
ii libunwind-19-dev 1:19.1.7-3+b1

libc++-19-dev recommends no packages.

libc++-19-dev suggests no packages.

-- no debconf information



More information about the Pkg-llvm-team mailing list