Bug founded on the new ARM Compiler 6.11 release, not before.
a.cpp:
[[gnu::weak]] int var_a = 0; int main(int argc, char const *argv[]) { return var_a; }
b.cpp:
int var_a = 1;
build with command:
armclang.exe --target=arm-arm-none-eabi -mcpu=Cortex-M3 -g a.cpp b.cpp
then output:
Error: L6743E: Relocation #REL:7 in a-a2e9fa.o(.debug_info) with respect to var_a that has an alternate def. Internal consistency check failed Finished: 0 information, 0 warning and 1 error messages. armclang: error: linker command failed with exit code 1 (use -v to see invocation)
using '__attribute__((weak)) instead of '[[gnu::weak]]' gets same result.
Only build without '-g' flag:
armclang.exe --target=arm-arm-none-eabi -mcpu=Cortex-M3 a.cpp b.cpp
then no error happens.
Hi,
Many thanks for highlighting this - we will investigate and get back to you.
Paul.
Thank you for flagging this issue. We have a workaround, which is to add a dummy assembly source file such as the below. Note that you will get a warning that the feature is deprecated, but this can safely be ignored.
.section .gnu.linkonce .end