Skip to content

Bug: rust_binary linking fails for linux_aarch64_score_gcc_12_2_0_posix with non-PIC and missing outline atomic symbols #27

Description

@bharatGoswami8

Description

Building any rust_binary that depends on C++ static libraries fails when using --config linux_aarch64_score_gcc_12_2_0_posix.

Root Causes (two distinct issues):

  1. Non-PIC static libraries + PIE linker default

The score_gcc_aarch64_toolchain (GCC 12.2.0) is built without --enable-default-pie, meaning its static C++ and system libraries (e.g. libacl) are compiled without -fPIC
The Rust linker defaults to -pie (Position Independent Executable) on Linux for security
Linking non-PIC objects with -pie causes relocation errors against symbols.

  1. Missing aarch64 outline atomic helpers

GCC 12.2.0 generates calls to outline atomic helper functions (__aarch64_ldadd4_acq_rel, __aarch64_cas2_acq_rel, __aarch64_swp4_acq_rel, __aarch64_ldset4_acq_rel) for aarch64.

Analysis results

No response

Solution

We need to add - --@rules_rust//:extra_rustc_flags=-Clink-arg=-no-pie, -Clink-arg=-lgcc

Error Occurrence Rate

None

How to reproduce

bazel build //score/mw/com/example/com-api-example --config linux_aarch64_score_gcc_12_2_0_posix

Supporting Information

No response

Classification

Minor

First Affected Release

not released (main)

Last Affected Release

not released (main)

Expected Fixed Release

before release (main)

Category

  • Safety Relevant
  • Security Relevant

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions