I'm trying to cross-compile a rust project for arm-linux-musleabihf and am hitting a linker error when using musl-cross-make. The rust project has a dependency on libgit2 and this is the dependency that seems to be causing the problem.
Using:
- the latest rust (1.43.1 via
rustup) - the
arm-unknown-linux-musleabihftarget - the latest
musl-cross-makewithTARGET=arm-linux-musleabihf - pointing
TARGET_CC_linux_arm-unknown-linux-musleabihfandCARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKERat/opt/musl-cross-make/output/bin/arm-linux-musleabihf-gcc
I get an error when building:
error: linking with `/opt/musl-cross-make/output/bin/arm-linux-musleabihf-gcc` failed: exit code: 1
...
= note: /opt/musl-cross-make/output/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /tmp/rustcvSvGAJ/liblibgit2_sys-e56c2f9bd024a0a9.rlib(odb.o): in function `git_odb__add_default_backends':
odb.c:(.text.git_odb__add_default_backends+0x24): undefined reference to `__stat_time64'
/opt/musl-cross-make/output/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /tmp/rustcvSvGAJ/liblibgit2_sys-e56c2f9bd024a0a9.rlib(config.o): in function `git_config_add_file_ondisk':
config.c:(.text.git_config_add_file_ondisk+0x34): undefined reference to `__stat_time64'
/opt/musl-cross-make/output/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /tmp/rustcvSvGAJ/liblibgit2_sys-e56c2f9bd024a0a9.rlib(config_file.o): in function `config_file_read':
config_file.c:(.text.config_file_read+0x48): undefined reference to `__stat_time64'
...etc...
It looks like the linker is having difficulty resolving the musl-specific time64 symbols, and it's not clear why.
This works fine if:
- I use the
x86_64-linux-musltarget on both rust andmusl-cross-make - I build
musl-cross-makewithMUSL_VER=1.1.24
I also wrote a little C program that uses both time and stat, and this builds on musl 1.2.0 on the cross compiler without any issue.
What's going on here? What's special about libgit2 which means that it can't find the right __time64 symbols?