GCC linking fails due to incorrect `libgcc` link order

未关闭
#53 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@nradakovic 已经在做这个了。

开始于 2026年4月29日。

评估

这个 Issue 还没有评估数据。

描述

bug feature p3 template wip

Description

We are encountering linker failures on AArch64 builds caused by unresolved outlined atomic helper symbols such as:

__aarch64_ldadd4_acq_rel
__aarch64_cas2_acq_rel
__aarch64_swp4_acq_rel

These symbols are emitted by GCC when compiling with outlined atomics (default on AArch64) and are expected to be resolved from libgcc.

We verified that the toolchain-provided libgcc.a does contain these symbols, so the issue is not missing runtime support.

Root Cause

Root Cause

The problem appears to be link order / link grouping when using static libraries:

  • The link uses a large number of static archives (-Wl,-Bstatic)
  • -nodefaultlibs is enabled, so runtime libraries must be added explicitly
  • libgcc is either:
    • added too early, or
    • not grouped with dependent static libraries

Because of this, the linker does not pull in the required objects from libgcc.a when resolving references originating from later static libraries.

This is a standard static linking behavior: archives are only searched once, left-to-right.

Proposed Fix

Ensure that libgcc (and related runtime libs) are linked after all static libraries that may reference them.
Two valid approaches:

Option 1Late linkage
Add at the end of the link command:

-lgcc
-lgcc_eh

Option 2Link group (more robust for large static graphs)

-Wl,--start-group
<all static libraries>
-lgcc
-lgcc_eh
-Wl,--end-group
Expected Changes ot work products
  • Requirements
  • Architecture
  • Safety Analysis
  • Security Analysis
  • Detailed Design
  • Implementation and Testing
  • all
Impact analysis

NA

Safety or Security relevance
  • none
  • Safety relevant
  • Security relevant
Expected required ASIL classification

QM

Expected Implementation Version (Release)

1.0

主要语言
Starlark
星标
2
派生
11
平均合并
1 天 14 小时
30 天内合并 PR
10

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

eclipse-score/bazel_cpp_toolchains 的其他 Issue

查看 eclipse-score/bazel_cpp_toolchains 的全部 Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。