cross: Compiling sqlx-macros v0.5.9 error.
Maintainer’s Note: I believe this is a broader issue with proc macros in general, as the proc macro is compiled for the host I believe while any dependencies (or crates using the proc macro) are compiled for the target. If you can create a valid test case, or ideally submit a fix, any help is greatly appreciated. The original message is below.
my env: Ubuntu-18 x86_64 cargo 1.56.0 rustc 1.56.1 cross 0.2.1 gcc version 9.3.0
after installed cross, execute following command:
cd /home/xxx/my_app
cross build --target aarch64-unknown-linux-gnu
got error:
Compiling sqlx-macros v0.5.9
error: linking with cc
failed: exit status: 1
|
= note: “cc” “-m64” “/target/debug/deps/sqlx_macros-xxx.sqlx_macros.xxx-cgu.0.rcgu.o” "/target/debug/deps/sqlx_macros-xxx.sqlx_ma … “/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-xxx.rlib” “/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-xxx.rlib” “-Wl,–end-group” “/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-xxx.rlib” “-Wl,-Bdynamic” “-lgcc_s” “-lutil” “-lrt” “-lpthread” “-lm” “-ldl” “-lc” “-Wl,–eh-frame-hdr” “-Wl,-znoexecstack” “-L” “/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib” “-o” “/target/debug/deps/libsqlx_macros-xxx.so” “-Wl,–gc-sections” “-shared” “-Wl,-zrelro” “-Wl,-znow” “-nodefaultlibs”
= note: collect2: fatal error: ld terminated with signal 9 [Killed]
compilation terminated.
error: could not compile sqlx-macros
due to previous error
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (13 by maintainers)
The following reproduces and solves the issue, and so although this is different than the example in the original case (which I believe has been fixed), remember that proc macros run on the host, and therefore
libssl-dev
or whatever dependencies need to be installed for the host that are needed for the proc macro, and not the target. I’ll add this to the wiki.https://github.com/wiryfuture/cross-sqlx-test
Can anyone else reproduce this with another example, and the necessary dependencies installed for the host?
I believe this has been fully documented on the wiki now, including a full example to a working project. If this is still an issue, let me know and I will re-open this. I’d like to thank wiryfuture for the solution.
@Alexhuszagh Thanks a lot for fixing it.
One odd thing about this issue is I only seem to have it with
aarch64-unknown-linux-gnu
if I use thearmv7-unknown-linux-gnueabihf
target everything appears to compile successfully.I believe this is an issue with proc macros compiling for the host, and any dependencies or crates using the proc macro compile for the target, and is a more general issue with cross compilation in Rust. That would also explain why adding symbols causes the above issue.
So this would be a good example of this: it tries to build it for the host, in this case it fails to find an external dependency, but the symbol errors would occur regardless.