From b4773902a53fa0de70bae8f770aa423fb0905c61 Mon Sep 17 00:00:00 2001 From: bharatgoswami Date: Mon, 27 Apr 2026 14:06:33 +0200 Subject: [PATCH] Rust::com fix for aarche64 gcc build for rust example file * Added rustc flag --- score/mw/com/example/com-api-example/BUILD | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/score/mw/com/example/com-api-example/BUILD b/score/mw/com/example/com-api-example/BUILD index 91bfb1091..cda0aeca0 100644 --- a/score/mw/com/example/com-api-example/BUILD +++ b/score/mw/com/example/com-api-example/BUILD @@ -18,6 +18,20 @@ rust_binary( srcs = ["basic-consumer-producer.rs"], data = ["etc/mw_com_config.json"], features = ["link_std_cpp_lib"], + # The score GCC toolchains (e.g. linux_aarch64_score_gcc_12_2_0_posix) are built without + # --enable-default-pie, so their static C++ and system libs (e.g. libacl) are non-PIC. + # The Rust linker defaults to PIE and rejects non-PIC objects. + # -no-pie disables PIE, -lstdc++ is needed when link_std_cpp_lib CC feature is not activated + # (e.g. exec config builds). -lgcc is needed on aarch64: GCC emits outline atomic helper + # calls (__aarch64_ldadd4_acq_rel etc.) and these live in the toolchain's libgcc.a, not in + # the sysroot's libgcc_s.so linked by Rust by default. + rustc_flags = select({ + "@platforms//cpu:aarch64": [ + "-Clink-arg=-no-pie", + "-Clink-arg=-lgcc", + ], + "//conditions:default": [], + }), visibility = ["//visibility:public"], deps = [ "//score/mw/com/example/com-api-example/com-api-gen", @@ -30,6 +44,13 @@ rust_test( name = "com-api-example-test", crate = ":com-api-example", data = ["etc/mw_com_config.json"], + rustc_flags = select({ + "@platforms//cpu:aarch64": [ + "-Clink-arg=-no-pie", + "-Clink-arg=-lgcc", + ], + "//conditions:default": [], + }), tags = ["manual"], deps = [ ":com-api-example",