You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ xargo rustc --target thumbv6m-none-eabi -- -C link-args=-nostartfiles
error: linking with `arm-none-eabi-gcc` failed: exit code: 1
|
= note: "arm-none-eabi-gcc" "-L" "/home/japaric/.xargo/lib/rustlib/thumbv6m-none-eabi/lib" "/home/japaric/tmp/app/target/thumbv6m-none-eabi/debug/deps/app-6d9087d3fe6b93f5.0.o" "-o" "/home/japaric/tmp/app/target/thumbv6m-none-eabi/debug/deps/app-6d9087d3fe6b93f5" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/home/japaric/tmp/app/target/thumbv6m-none-eabi/debug/deps" "-L" "/home/japaric/tmp/app/target/debug/deps" "-L" "/home/japaric/.xargo/lib/rustlib/thumbv6m-none-eabi/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/japaric/tmp/app/target/thumbv6m-none-eabi/debug/deps/librlibc-ca4e4855ef16b6a5.rlib" "/home/japaric/.xargo/lib/rustlib/thumbv6m-none-eabi/lib/libcore-539305ece2e53820.rlib" "/home/japaric/tmp/app/target/thumbv6m-none-eabi/debug/deps/libcompiler_builtins-71942e6a7f812dde.rlib" "-nostartfiles"
= note: /home/japaric/tmp/app/target/thumbv6m-none-eabi/debug/deps/libcompiler_builtins-71942e6a7f812dde.rlib(compiler_builtins-71942e6a7f812dde.0.o): In function `compiler_builtins::arm::__aeabi_memcpy4':
/home/japaric/.cargo/git/checkouts/compiler-builtins-299ea7fa6d11e5d0/b59c789/src/arm.rs:117: undefined reference to `memcpy'
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: /home/japaric/tmp/app/target/thumbv6m-none-eabi/debug/deps/app-6d9087d3fe6b93f5: hidden symbol `memcpy' isn't defined
/usr/lib/gcc/arm-none-eabi/6.2.0/../../../../arm-none-eabi/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Note the order of the linker arguments:
app.0.o
librlibc.rlib
libcore.rlib
libcompiler_builtins.rlib
And the relevant bits of running nm over these object files:
$ arm-none-eabi-nm -g **/app*.0.o
U __aeabi_memcpy4
$ arm-none-eabi-nm -g **/librlibc*.rlib
00000000 W memcmp
00000000 W memcpy
00000000 W memmove
00000000 W memset
$ arm-none-eabi-nm -g ~/.xargo/lib/rustlib/thumbv6m-none-eabi/lib/libcore*.rlib
U __aeabi_memclr4
U __aeabi_memcpy
U __aeabi_memcpy4
U __aeabi_memset
$ arm-none-eabi-nm -g **/libcompiler_builtins*.rlib
U memcpy
U memmove
U memset
00000000 T __aeabi_memclr
00000000 T __aeabi_memclr4
00000000 T __aeabi_memclr8
00000000 T __aeabi_memcpy
00000000 T __aeabi_memcpy4
00000000 T __aeabi_memcpy8
00000000 T __aeabi_memmove
00000000 T __aeabi_memmove4
00000000 T __aeabi_memmove8
00000000 T __aeabi_memset
00000000 T __aeabi_memset4
00000000 T __aeabi_memset8
For this to actually work, librlibc.rlib should be passed to the linker afterlibcompiler_builtins.rlib but that's not possible because compiler-builtins is marked as #![compiler_builtins] and will always be the last rlib to be passed to the linker.
Not quite sure how to solve this other than copy paste rlibc's mem* functions into compiler-builtins or special case rlibc in rustc ...
May be worth to mention that this is not a problem in no_std programs that link to libc and not use the "weak" Cargo feature as the linker arguments would look look like: libcore.rlib .. libcompiler_builtins.rlib -lc. In that case -lc would provide memcpy et al.
STR
Note the order of the linker arguments:
app.0.o
librlibc.rlib
libcore.rlib
libcompiler_builtins.rlib
And the relevant bits of running
nm
over these object files:For this to actually work,
librlibc.rlib
should be passed to the linker afterlibcompiler_builtins.rlib
but that's not possible becausecompiler-builtins
is marked as#![compiler_builtins]
and will always be the last rlib to be passed to the linker.Not quite sure how to solve this other than copy paste rlibc's mem* functions into compiler-builtins or special case rlibc in rustc ...
May be worth to mention that this is not a problem in no_std programs that link to libc and not use the "weak" Cargo feature as the linker arguments would look look like:
libcore.rlib .. libcompiler_builtins.rlib -lc
. In that case-lc
would providememcpy
et al.cc @alexcrichton
The text was updated successfully, but these errors were encountered: