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):
- 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.
- 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
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):
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.
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