cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.66k stars 371 forks source link

Compiling sqlx-macros v0.5.9 error. #605

Closed RustChater closed 1 year ago

RustChater commented 2 years ago

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

Emilgardis commented 2 years ago

This seems to me to be a memory issue, e.g your memory is getting exhausted.

RustChater commented 2 years ago

This seems to me to be a memory issue, e.g your memory is getting exhausted.

OK, I'll try to increase the memory.

simao commented 2 years ago

I am getting a similar problem with the same crate:

$ cross build --target armv7-unknown-linux-musleabihf
d   Compiling sqlx-macros v0.5.11
derror: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.0.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.1.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.10.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.11.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.12.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.13.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.14.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.15.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.2.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.3.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.4.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.5.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.6.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.7.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.8.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.sqlx_macros.b518ac95-cgu.9.rcgu.o" "/target/debug/deps/sqlx_macros-a55e70d02407542a.2ka4z3l0dhdv8512.rcgu.rmeta" "/target/debug/deps/sqlx_macros-a55e70d02407542a.1y4o3lr7e309isd5.rcgu.o" "-Wl,--as-needed" "-L" "/target/debug/deps" "-L" "/target/debug/build/ring-8836b7e5b582514f/out" "-L" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/target/debug/deps/libdotenv-0fc5e8289431a71d.rlib" "/target/debug/deps/libheck-5fe8bc70a06ceb39.rlib" "/target/debug/deps/libunicode_segmentation-f00aadea21d27e49.rlib" "/target/debug/deps/libsyn-44e7f841c22afcde.rlib" "/target/debug/deps/libsqlx_core-23e61842d80d7cde.rlib" "/target/debug/deps/libhex-49936c98b71e5753.rlib" "/target/debug/deps/libwhoami-37bebb34cc16b380.rlib" "/target/debug/deps/libdirs-3904f5ed1516ed5e.rlib" "/target/debug/deps/libdirs_sys-5c1823b3acc7b7a2.rlib" "/target/debug/deps/libwebpki_roots-902be03c27a07d8d.rlib" "/target/debug/deps/libsqlformat-01b9736b3d5ac2d9.rlib" "/target/debug/deps/libunicode_categories-56cb2630151b8124.rlib" "/target/debug/deps/libnom-2e232bcd5e7d6040.rlib" "/target/debug/deps/libitertools-023ef750659551d1.rlib" "/target/debug/deps/libthiserror-8cf6bc40f7e5fb04.rlib" "/target/debug/deps/libbitflags-3f00cac518795a9a.rlib" "/target/debug/deps/liburl-e82c183658d4c117.rlib" "/target/debug/deps/libidna-f49cda824f0cc43c.rlib" "/target/debug/deps/libform_urlencoded-93c9805d7084043f.rlib" "/target/debug/deps/libmatches-79988a3a3f51c00d.rlib" "/target/debug/deps/libpercent_encoding-32dd5c1ab5974210.rlib" "/target/debug/deps/libmd5-e2349b49a8f560a0.rlib" "/target/debug/deps/libbyteorder-171238c466ed8e80.rlib" "/target/debug/deps/libatoi-e60a280e9ad4980e.rlib" "/target/debug/deps/libnum_traits-6392f8d501d3fcb7.rlib" "/target/debug/deps/libstringprep-b12d57e002a971b5.rlib" "/target/debug/deps/libunicode_normalization-e17b05c4e7220a4a.rlib" "/target/debug/deps/libtinyvec-6501298496e10bd1.rlib" "/target/debug/deps/libtinyvec_macros-c91e6deb587a6fa0.rlib" "/target/debug/deps/libunicode_bidi-c016094b93117d84.rlib" "/target/debug/deps/libsha2-474740e79e1da8b9.rlib" "/target/debug/deps/libcpufeatures-0ef26ea7855fdfe3.rlib" "/target/debug/deps/libopaque_debug-c1ffb6c246dc7985.rlib" "/target/debug/deps/libblock_buffer-f7a41407bdf843d7.rlib" "/target/debug/deps/librand-f7d8987d15c32ab1.rlib" "/target/debug/deps/librand_chacha-fde47af7d3012b27.rlib" "/target/debug/deps/libppv_lite86-f422879e062f51ad.rlib" "/target/debug/deps/librand_core-0ba4c55a9dd767dc.rlib" "/target/debug/deps/libhmac-68d15aab340b09e0.rlib" "/target/debug/deps/libdigest-99c51b36fdd6bb4d.rlib" "/target/debug/deps/libcrypto_mac-6d9acbaf601ca7b5.rlib" "/target/debug/deps/libsubtle-5983d9bb59bdcc94.rlib" "/target/debug/deps/libgeneric_array-31299215a58a208c.rlib" "/target/debug/deps/libtypenum-8dc0f9d8081d34a9.rlib" "/target/debug/deps/libbytes-15b4425b0ed3b764.rlib" "/target/debug/deps/libhashlink-510b4c716573000b.rlib" "/target/debug/deps/libhashbrown-33ec7517854cf905.rlib" "/target/debug/deps/libahash-b14d9873e195055d.rlib" "/target/debug/deps/libgetrandom-ed478396bc3cd8af.rlib" "/target/debug/deps/libserde_json-0559791d2b6f3b53.rlib" "/target/debug/deps/libryu-39bc98b0cd76173a.rlib" "/target/debug/deps/libitoa-3f48628b7ba2d408.rlib" "/target/debug/deps/libserde-a10cae9246d5efd6.rlib" "/target/debug/deps/libsqlx_rt-7308aab632d047b0.rlib" "/target/debug/deps/libasync_rustls-05e0fae5e5860027.rlib" "/target/debug/deps/librustls-222dd60a95003dd3.rlib" "/target/debug/deps/libbase64-416e1250c5cc634c.rlib" "/target/debug/deps/libsct-1cb4dcc5c5cd370f.rlib" "/target/debug/deps/libwebpki-865337ff4c9d445a.rlib" "/target/debug/deps/libring-dbd864def844b0b3.rlib" "/target/debug/deps/libspin-692faa7419677f8a.rlib" "/target/debug/deps/libuntrusted-66db759a5098ae3a.rlib" "/target/debug/deps/libasync_std-ae607a2e8eaf7f08.rlib" "/target/debug/deps/libasync_global_executor-f9b60cc384ef7255.rlib" "/target/debug/deps/libblocking-14aef625d1d99726.rlib" "/target/debug/deps/libatomic_waker-6fa44d9a4a76f4df.rlib" "/target/debug/deps/libnum_cpus-dc2b71f8baea5c63.rlib" "/target/debug/deps/libasync_mutex-6eb0037f9c7b166a.rlib" "/target/debug/deps/libasync_executor-8e82082613b5ebcd.rlib" "/target/debug/deps/libasync_task-bb0bbb4c3279c4c3.rlib" "/target/debug/deps/libasync_process-513a574a514b2eca.rlib" "/target/debug/deps/libsignal_hook-5e9e96dc15abfa2a.rlib" "/target/debug/deps/libsignal_hook_registry-4ff2d585a10a01da.rlib" "/target/debug/deps/libasync_io-aaa025a086aff4c8.rlib" "/target/debug/deps/libslab-67eab2dc94066b63.rlib" "/target/debug/deps/libpolling-a5485c61cfaf5298.rlib" "/target/debug/deps/libonce_cell-877d9c492c79d098.rlib" "/target/debug/deps/libsocket2-267fe8580cd90b96.rlib" "/target/debug/deps/libfutures_lite-43f1a65451ec530f.rlib" "/target/debug/deps/libmemchr-bc7103d2fd7c9396.rlib" "/target/debug/deps/libfastrand-6c6e62702e2d6590.rlib" "/target/debug/deps/libwaker_fn-4de703460d892bd7.rlib" "/target/debug/deps/libparking-99e4e26c1529b2b0.rlib" "/target/debug/deps/libfutures_io-ddffed7f26562b3d.rlib" "/target/debug/deps/libasync_channel-c3b0747bf9f5ec0e.rlib" "/target/debug/deps/libconcurrent_queue-55c310042a619115.rlib" "/target/debug/deps/libcache_padded-9caeea70b9c041d9.rlib" "/target/debug/deps/libasync_lock-a5bc326f35988788.rlib" "/target/debug/deps/libevent_listener-f9372f4c65b4dd8c.rlib" "/target/debug/deps/libkv_log_macro-07aefb8973412167.rlib" "/target/debug/deps/liblog-5d45a045b5676cf1.rlib" "/target/debug/deps/libvalue_bag-5ba6c7b6c0726e5d.rlib" "/target/debug/deps/libcrossbeam_queue-5ca38fc644ca55a8.rlib" "/target/debug/deps/libcrossbeam_utils-adac7f5623a5980a.rlib" "/target/debug/deps/liblazy_static-02ff0d0fbc57b9b4.rlib" "/target/debug/deps/libfutures_intrusive-857d8ce091ced4e9.rlib" "/target/debug/deps/libparking_lot-8c2db220b8c87daf.rlib" "/target/debug/deps/libparking_lot_core-ce9dcdfd122eda5a.rlib" "/target/debug/deps/liblibc-b6b6a8ed32c5ad1f.rlib" "/target/debug/deps/libsmallvec-30e0953ece083737.rlib" "/target/debug/deps/libinstant-dee24afb0140e38b.rlib" "/target/debug/deps/libcfg_if-0a04e74fc4f21d18.rlib" "/target/debug/deps/liblock_api-6b50e3b2abda035b.rlib" "/target/debug/deps/libscopeguard-d46e40bbd3136360.rlib" "/target/debug/deps/libeither-c5489414264d9d01.rlib" "/target/debug/deps/libfutures_util-53caffeb9321e058.rlib" "/target/debug/deps/libpin_project_lite-420daa249e18d18f.rlib" "/target/debug/deps/libfutures_task-1a7bed426fb3eaf8.rlib" "/target/debug/deps/libpin_utils-0029fcf5b57be1ee.rlib" "/target/debug/deps/libfutures_channel-6e2b4d382e8b0017.rlib" "/target/debug/deps/libfutures_sink-cd5cc9f7bdd2697a.rlib" "/target/debug/deps/libfutures_core-7d8219d4ed57fa6e.rlib" "/target/debug/deps/libquote-08790c2c5c8238dd.rlib" "/target/debug/deps/libproc_macro2-28557fc9e3e8765e.rlib" "/target/debug/deps/libunicode_xid-aeb18ec3bc792598.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-13adfcc16df86521.rlib" "-Wl,--start-group" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-a46a068050a12a4b.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-1df56095db9453cb.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-9062de483386e50b.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-b988ab269ff13602.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1bc822d886d4f7bd.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-963eca8df4c224a6.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-d805b480c9102e58.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-06dfdbc22b935051.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-d7523a4d118e6572.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-5d7898c7fac3a07d.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-8c2bdbab4845bf3d.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-d578639df0547b30.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-58bbb7b1efa3a5e2.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-4c9b082d197c16f8.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-70f9ed6d8e7a5ce6.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8c0a241d0360fa53.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-bad7ed93fdd31371.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-98b4d121af2b7335.rlib" "-Wl,--end-group" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-1d9f7e5920635d15.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-a55e70d02407542a.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: warning: /target/debug/deps/libring-dbd864def844b0b3.rlib(aesni-x86_64-elf.o): unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
          /usr/bin/ld: warning: /target/debug/deps/libring-dbd864def844b0b3.rlib(aesni-x86_64-elf.o): unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
          /usr/bin/ld: /target/debug/deps/libring-dbd864def844b0b3.rlib(aesni-x86_64-elf.o): unable to initialize decompress status for section .debug_line
          /usr/bin/ld: /target/debug/deps/libring-dbd864def844b0b3.rlib(aesni-x86_64-elf.o): unable to initialize decompress status for section .debug_line
          /target/debug/deps/libring-dbd864def844b0b3.rlib: error adding symbols: File format not recognized
          collect2: error: ld returned 1 exit status

error: could not compile `sqlx-macros` due to previous error
Alexhuszagh commented 2 years ago

@simao, that's a very different error than the first one, which seems to be memory exhaustion. Yours seems to be an issue with cross-compilation and proc macros, which I believe is a known issue and waiting an upstream change. I'll check this and debug it shortly.

Alexhuszagh commented 2 years ago

Proc Macros

Pretty sure this is an issue where proc macros are built for the host rather than the target. If I try to compile a simple crate that uses sqlx-macros, with the following Cargo.toml:

[package]
name = "sqlx_macros"
version = "0.1.0"
edition = "2021"

[dependencies]
sqlx-macros = "0.5.13"

Where my Cross.toml is:

[target.aarch64-unknown-linux-gnu]
image = "openssl:arm64"

And my Dockerfile for the custom image is:

FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge
RUN dpkg --add-architecture arm64
RUN apt-get update && apt-get install --assume-yes libssl-dev:arm64

I get the following when I try to build the crate:

process didn't exit successfully: `/target/debug/build/openssl-sys-b3a47352322f2aef/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rustc-link-search=native=/usr/lib/aarch64-linux-gnu
  cargo:rustc-link-lib=ssl
  cargo:rustc-link-lib=crypto
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-changed=build/expando.c
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-unknown-linux-gnu")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_x86_64-unknown-linux-gnu = None
  CC_x86_64_unknown_linux_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-unknown-linux-gnu = None
  CFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/usr/include" "-Wall" "-Wextra" "-E" "build/expando.c"
  cargo:warning=build/expando.c:2:33: fatal error: openssl/opensslconf.h: No such file or directory
  cargo:warning=compilation terminated.
  exit status: 1

Regular Crate

If I try to compile a regular crate however using open-ssl, it works. Here's Cargo.toml:

[package]
name = "openssl"
version = "0.1.0"
edition = "2021"

[dependencies]
openssl = "0.10.40"

This works fine. It seems it's trying to build the proc macro for the host, doesn't detect OpenSSL so it fails (which is a broader issue), which causes it to fail.

leshow commented 2 years ago

FYI, you can compile sqlx without openssl, it will still hit a similar error:

for example,

sqlx = { version = "0.5.13", features = ["sqlite", "runtime-tokio-rustls"] }
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.0.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.1.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.10.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.11.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.12.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.13.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.14.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.15.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.2.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.3.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.4.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.5.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.6.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.7.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.8.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.sqlx_macros.dedb3c2e-cgu.9.rcgu.o" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.m9w4vl4b9l8pryk.rcgu.rmeta" "/target/debug/deps/sqlx_macros-acfc5daaefd61630.1wwamz3qkc4ugn40.rcgu.o" "-Wl,--as-needed" "-L" "/target/debug/deps" "-L" "/target/debug/build/libsqlite3-sys-ddce93851cf98d6b/out" "-L" "/target/debug/build/ring-8836b7e5b582514f/out" "-L" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/target/debug/deps/libdotenv-0fc5e8289431a71d.rlib" "/target/debug/deps/libhex-49936c98b71e5753.rlib" "/target/debug/deps/libserde_json-4b9e21b6474e2737.rlib" "/target/debug/deps/libryu-42b44f497961fb04.rlib" "/target/debug/deps/libitoa-a2f7ee72340912dc.rlib" "/target/debug/deps/libheck-8f9294a1c64fd922.rlib" "/target/debug/deps/libunicode_segmentation-f00aadea21d27e49.rlib" "/target/debug/deps/libsyn-03ec26989ee84886.rlib" "/target/debug/deps/libsqlx_core-4013490d055bcdec.rlib" "/target/debug/deps/liburl-abadb3a5e602b633.rlib" "/target/debug/deps/libidna-cc2efc4d63c2aa6c.rlib" "/target/debug/deps/libunicode_normalization-25deb24ef1364858.rlib" "/target/debug/deps/libtinyvec-05ffef94e1b793bc.rlib" "/target/debug/deps/libtinyvec_macros-c91e6deb587a6fa0.rlib" "/target/debug/deps/libunicode_bidi-aa7bc80af7f37e6b.rlib" "/target/debug/deps/libform_urlencoded-93c9805d7084043f.rlib" "/target/debug/deps/libmatches-79988a3a3f51c00d.rlib" "/target/debug/deps/libfutures_executor-ed18cb27dfbe9c65.rlib" "/target/debug/deps/libflume-c82e347a826e0c64.rlib" "/target/debug/deps/libspin-6bd674afd3d87411.rlib" "/target/debug/deps/libpin_project-e2322f49f364be9d.rlib" "/target/debug/deps/libtokio_stream-d788218a46574541.rlib" "/target/debug/deps/libwebpki_roots-ad886f5cef044adc.rlib" "/target/debug/deps/libsqlformat-b92b6374cda866d4.rlib" "/target/debug/deps/libunicode_categories-56cb2630151b8124.rlib" "/target/debug/deps/libnom-f6bbc8f57b4cdae3.rlib" "/target/debug/deps/libitertools-92a70625dfe45c1a.rlib" "/target/debug/deps/libthiserror-e23f4f435473a281.rlib" "/target/debug/deps/libbitflags-1693f043aa7c36ab.rlib" "/target/debug/deps/libindexmap-cf2c731d24226e15.rlib" "/target/debug/deps/libhashbrown-c0079f5efc801cba.rlib" "/target/debug/deps/libpercent_encoding-32dd5c1ab5974210.rlib" "/target/debug/deps/liblibsqlite3_sys-6e2f1caa4c210023.rlib" "/target/debug/deps/libatoi-375726cc98ed394d.rlib" "/target/debug/deps/libsha2-8092043b29739f0f.rlib" "/target/debug/deps/libcpufeatures-0ef26ea7855fdfe3.rlib" "/target/debug/deps/libdigest-1dff5438e8376982.rlib" "/target/debug/deps/libblock_buffer-2d00540757a3ad1f.rlib" "/target/debug/deps/libcrypto_common-75f0922b7b71098c.rlib" "/target/debug/deps/libgeneric_array-4e9397dd5092f5cc.rlib" "/target/debug/deps/libtypenum-8dc0f9d8081d34a9.rlib" "/target/debug/deps/libhashlink-9f436721553758e8.rlib" "/target/debug/deps/libhashbrown-3ba0a116a7576e9a.rlib" "/target/debug/deps/libahash-6ddf0a4a1d3b3730.rlib" "/target/debug/deps/libgetrandom-64db14214ba32121.rlib" "/target/debug/deps/libchrono-493ca61b3cf483c4.rlib" "/target/debug/deps/libnum_integer-506f0b5916f1e70e.rlib" "/target/debug/deps/libnum_traits-98b2220409079793.rlib" "/target/debug/deps/libtime-9b7cce88cbf8a455.rlib" "/target/debug/deps/libsqlx_rt-a68e549a9af7e4c0.rlib" "/target/debug/deps/libtokio_rustls-c64927c63863c21f.rlib" "/target/debug/deps/librustls-380de8323c90a5e0.rlib" "/target/debug/deps/libbase64-416e1250c5cc634c.rlib" "/target/debug/deps/libsct-7125ca219b68d128.rlib" "/target/debug/deps/libwebpki-d8fcf700b3fde2b6.rlib" "/target/debug/deps/libring-adceac1a7c081490.rlib" "/target/debug/deps/libspin-692faa7419677f8a.rlib" "/target/debug/deps/libuntrusted-66db759a5098ae3a.rlib" "/target/debug/deps/libtokio-a580a32f7a61e8ac.rlib" "/target/debug/deps/libsignal_hook_registry-260f5af2208b16e0.rlib" "/target/debug/deps/libnum_cpus-a719a93404b7ebd6.rlib" "/target/debug/deps/libsocket2-947b0a4266ad4960.rlib" "/target/debug/deps/libbytes-15b4425b0ed3b764.rlib" "/target/debug/deps/libmio-3102f2d66a596a43.rlib" "/target/debug/deps/liblog-f855c67ca87a1dfd.rlib" "/target/debug/deps/libparking_lot-1010425b999ebbf0.rlib" "/target/debug/deps/libparking_lot_core-41915f1747d4e3f2.rlib" "/target/debug/deps/libcrossbeam_queue-c69a9cee911614e4.rlib" "/target/debug/deps/libcrossbeam_utils-46d05cf69ccd0d49.rlib" "/target/debug/deps/libonce_cell-a8d943d2b102d2cb.rlib" "/target/debug/deps/libfutures_intrusive-12fe409c25cd32a3.rlib" "/target/debug/deps/libparking_lot-5b9c75aa7698bf4b.rlib" "/target/debug/deps/libparking_lot_core-d209cf22ca4d1b66.rlib" "/target/debug/deps/liblibc-3b7e61598529b6ad.rlib" "/target/debug/deps/libsmallvec-30e0953ece083737.rlib" "/target/debug/deps/libinstant-dee24afb0140e38b.rlib" "/target/debug/deps/libcfg_if-0a04e74fc4f21d18.rlib" "/target/debug/deps/liblock_api-6b50e3b2abda035b.rlib" "/target/debug/deps/libscopeguard-d46e40bbd3136360.rlib" "/target/debug/deps/libeither-3a13a0364200b246.rlib" "/target/debug/deps/libserde-4b8dc7f8239db0dc.rlib" "/target/debug/deps/libevent_listener-f9372f4c65b4dd8c.rlib" "/target/debug/deps/libfutures_util-798e4ad7bace9492.rlib" "/target/debug/deps/libmemchr-73597034f89f8d61.rlib" "/target/debug/deps/libfutures_io-80156a1303cb1cfa.rlib" "/target/debug/deps/libslab-67eab2dc94066b63.rlib" "/target/debug/deps/libpin_project_lite-527ce2b7938b9c42.rlib" "/target/debug/deps/libfutures_task-7d3a049d02ce8b73.rlib" "/target/debug/deps/libpin_utils-0029fcf5b57be1ee.rlib" "/target/debug/deps/libfutures_channel-6f2858b163c500e2.rlib" "/target/debug/deps/libfutures_sink-e10ea0e7e7fbe990.rlib" "/target/debug/deps/libfutures_core-7d8219d4ed57fa6e.rlib" "/target/debug/deps/libquote-1afd8c71e07392a6.rlib" "/target/debug/deps/libproc_macro2-c377f89c7cd9ba2e.rlib" "/target/debug/deps/libunicode_ident-5e2bf7216112fbcf.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-13adfcc16df86521.rlib" "-Wl,--start-group" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-a46a068050a12a4b.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-1df56095db9453cb.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-9062de483386e50b.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-b988ab269ff13602.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1bc822d886d4f7bd.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-963eca8df4c224a6.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-d805b480c9102e58.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-06dfdbc22b935051.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-d7523a4d118e6572.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-5d7898c7fac3a07d.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-8c2bdbab4845bf3d.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-d578639df0547b30.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-58bbb7b1efa3a5e2.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-4c9b082d197c16f8.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-70f9ed6d8e7a5ce6.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8c0a241d0360fa53.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-bad7ed93fdd31371.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-98b4d121af2b7335.rlib" "-Wl,--end-group" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-1d9f7e5920635d15.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-acfc5daaefd61630.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /target/debug/deps/libring-adceac1a7c081490.rlib(aesni-x86_64-elf.o): unable to initialize decompress status for section .debug_line
          /usr/bin/ld: /target/debug/deps/libring-adceac1a7c081490.rlib(aesni-x86_64-elf.o): unable to initialize decompress status for section .debug_line
          /target/debug/deps/libring-adceac1a7c081490.rlib: error adding symbols: File format not recognized
          collect2: error: ld returned 1 exit status
Alexhuszagh commented 2 years ago

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.

It seems it's trying to build the proc macro for the host, doesn't detect OpenSSL so it fails (which is a broader issue), which causes it to fail.

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.

leshow commented 2 years ago

One odd thing about this issue is I only seem to have it with aarch64-unknown-linux-gnu if I use the armv7-unknown-linux-gnueabihf target everything appears to compile successfully.

Alexhuszagh commented 2 years ago

This no longer reproduces as of the latest main, using this sample project.

$ cross build --target aarch64-unknown-linux-gnu
....
   Compiling futures-intrusive v0.4.0                                                                                                                                                       [50/923]
   Compiling tokio-stream v0.1.9                                                                                                                                                                    
   Compiling digest v0.10.3                                                                                                                                                                         
   Compiling hashlink v0.7.0                                                                                                                                                                        
   Compiling webpki-roots v0.21.1                                                                                                                                                                   
   Compiling rustls v0.19.1                                                                                                                                                                         
   Compiling sha2 v0.10.2                                                                                                                                                                           
   Compiling pin-project-internal v1.0.11                                                                                                                                                           
   Compiling thiserror-impl v1.0.31                                                                                                                                                                 
   Compiling tokio-rustls v0.22.0                                                                                                                                                                   
   Compiling pin-project v1.0.11                                                                                                                                                                    
   Compiling sqlx-rt v0.5.13                                                                                                                                                                        
   Compiling flume v0.10.13                                                                                                                                                                         
   Compiling thiserror v1.0.31                                                                                                                                                                      
   Compiling sqlx-core v0.5.13                                                                                                                                                                      
   Compiling sqlx-macros v0.5.13                                                                                                                                                                    
   Compiling sqlx v0.5.13                                                                                                                                                                           
   Compiling sqlx v0.1.0 (/project)                                                                                                                                                                 
    Finished dev [unoptimized + debuginfo] target(s) in 1m 41s                                                                                                                                      

Let me know if this still reproduces on your end with the 0.2.2 or the latest main and I'll reopen this. Make sure you check your system profiler (top) to ensure it isn't a memory issue,

simao commented 2 years ago

@Alexhuszagh Thanks a lot for fixing it.

Madoshakalaka commented 2 years ago

@Alexhuszagh I met the same problem on my project, neither 0.2.4 nor the main branch (59ec530 2022-07-16) :

❯ cross build -p server --target aarch64-unknown-linux-gnu
   Compiling sqlx-macros v0.6.0
   Compiling bevy_render v0.7.0
   Compiling bevy_scene v0.7.0
   Compiling bevy_animation v0.7.0
   Compiling bevy_audio v0.7.0
   Compiling bevy_rhai v0.3.0
error: linking with `clang` failed: exit status: 1
  |
  = note: "clang" "-m64" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.0.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.1.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.10.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.11.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.12.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.13.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.14.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.15.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.2.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.3.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.4.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.5.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.6.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.7.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.8.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.sqlx_macros.d2282df6-cgu.9.rcgu.o" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.25gqk83dwgwjmuhl.rcgu.rmeta" "/target/debug/deps/sqlx_macros-d767a42d4786fdc4.38byycp97qgs1sb7.rcgu.o" "-Wl,--as-needed" "-L" "/target/debug/deps" "-L" "/target/debug/build/libsqlite3-sys-32cc39f7cf032b30/out" "-L" "/target/debug/build/ring-cfe4dad9e4e90f9f/out" "-L" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/target/debug/deps/libdotenv-700445d3d22bfbe4.rlib" "/target/debug/deps/libheck-1e78977c58d6ca11.rlib" "/target/debug/deps/libunicode_segmentation-9603a48f7d2a6a8a.rlib" "/target/debug/deps/libsyn-54f2face745becd8.rlib" "/target/debug/deps/libsqlx_core-df2ba8d07a7e7337.rlib" "/target/debug/deps/liburl-0011768a44ab7863.rlib" "/target/debug/deps/libidna-c8e8eaa5821b251d.rlib" "/target/debug/deps/libunicode_normalization-7f15f9a7ed791153.rlib" "/target/debug/deps/libtinyvec-32c6f9102bb2f7e8.rlib" "/target/debug/deps/libtinyvec_macros-ef06cf556416b731.rlib" "/target/debug/deps/libunicode_bidi-96858afa72c3ee66.rlib" "/target/debug/deps/libform_urlencoded-1a48ab4b6760ee48.rlib" "/target/debug/deps/libmatches-a104dd362fa85146.rlib" "/target/debug/deps/libfutures_executor-342d5c327c6feb82.rlib" "/target/debug/deps/libflume-2347ee912d7754b7.rlib" "/target/debug/deps/libspin-548d6285493de54e.rlib" "/target/debug/deps/libpin_project-c173cc15795421b8.rlib" "/target/debug/deps/librustls_pemfile-3b7f790271e49bcb.rlib" "/target/debug/deps/libbase64-4563507a4eb0b4b2.rlib" "/target/debug/deps/libwebpki_roots-fbd6922bce68bfbc.rlib" "/target/debug/deps/libsqlformat-f2b634a4389b6344.rlib" "/target/debug/deps/libunicode_categories-b93fcdce8a408a43.rlib" "/target/debug/deps/libnom-c4f9fd4189d248f8.rlib" "/target/debug/deps/libitertools-ca228c02c0c5d3aa.rlib" "/target/debug/deps/libthiserror-ed2d2ae6896dbaf3.rlib" "/target/debug/deps/libbitflags-af33bc88ca937323.rlib" "/target/debug/deps/libindexmap-b70e05febf96b2e4.rlib" "/target/debug/deps/libpercent_encoding-b196e1663297fef1.rlib" "/target/debug/deps/liblibsqlite3_sys-017fa5221e60e53f.rlib" "/target/debug/deps/libatoi-b231ae59e350d6c8.rlib" "/target/debug/deps/libsha2-de24737d04263138.rlib" "/target/debug/deps/libcpufeatures-a89a9bdc17782d08.rlib" "/target/debug/deps/libdigest-17528919b8679fbb.rlib" "/target/debug/deps/libblock_buffer-d7d5f41b71548fac.rlib" "/target/debug/deps/libcrypto_common-938c7de718e62d53.rlib" "/target/debug/deps/libgeneric_array-39ab557ac561349d.rlib" "/target/debug/deps/libtypenum-ae91be759e5f8db3.rlib" "/target/debug/deps/libsqlx_rt-945bc559b9834a41.rlib" "/target/debug/deps/libfutures_rustls-8b72669db35d96e2.rlib" "/target/debug/deps/librustls-7f15eb693da7e2a9.rlib" "/target/debug/deps/libsct-e972e5b98857d892.rlib" "/target/debug/deps/libwebpki-0e1767dd806bc7bf.rlib" "/target/debug/deps/libring-b1f6eab169e4093a.rlib" "/target/debug/deps/libspin-2c2d0e97c8363747.rlib" "/target/debug/deps/libuntrusted-bae7ad9dbbebb2b7.rlib" "/target/debug/deps/libasync_std-0702d671fb749e94.rlib" "/target/debug/deps/libasync_global_executor-79935308fc90b6b2.rlib" "/target/debug/deps/libblocking-408178c3eb28e8f7.rlib" "/target/debug/deps/libatomic_waker-c78f6b92b9e93ae5.rlib" "/target/debug/deps/libnum_cpus-6af46bc12ef6c04a.rlib" "/target/debug/deps/libasync_executor-d189684a0132c91b.rlib" "/target/debug/deps/libasync_task-27f79bd33f840eb6.rlib" "/target/debug/deps/libasync_process-8b850ce6ed9502a8.rlib" "/target/debug/deps/libsignal_hook-186b5c386ec9546c.rlib" "/target/debug/deps/libsignal_hook_registry-0d4928671b7c0853.rlib" "/target/debug/deps/libasync_io-eb8bfcbe4a5f37c6.rlib" "/target/debug/deps/libpolling-2729f795a1a9efd2.rlib" "/target/debug/deps/libsocket2-76b71fda6a1e62df.rlib" "/target/debug/deps/libfutures_lite-0a77c3797c96d33c.rlib" "/target/debug/deps/libfastrand-2765520c777de4dc.rlib" "/target/debug/deps/libwaker_fn-3314a20b781ed1a0.rlib" "/target/debug/deps/libparking-3342abdc29b74b75.rlib" "/target/debug/deps/libfutures_io-f2495b3b3db32d28.rlib" "/target/debug/deps/libasync_channel-655a191c063730e8.rlib" "/target/debug/deps/libconcurrent_queue-14b40c64933a5278.rlib" "/target/debug/deps/libcache_padded-7bc2dbe282e10eed.rlib" "/target/debug/deps/libasync_lock-ade57426eeeef8a6.rlib" "/target/debug/deps/libkv_log_macro-1c7963fec4aa8fd2.rlib" "/target/debug/deps/libmemchr-4fce41623cec2314.rlib" "/target/debug/deps/libbytes-5e8424a0f7103369.rlib" "/target/debug/deps/libhashlink-4bba62a74673724a.rlib" "/target/debug/deps/libhashbrown-8ff3d20e2dd4dcba.rlib" "/target/debug/deps/libahash-ad173a593c93d137.rlib" "/target/debug/deps/libgetrandom-0b03f300238e98ee.rlib" "/target/debug/deps/librust_decimal-5cfb381afdeb7626.rlib" "/target/debug/deps/libarrayvec-f032d4b97223866f.rlib" "/target/debug/deps/libtime-70946e2932413f87.rlib" "/target/debug/deps/libchrono-146dd2399b81d8d8.rlib" "/target/debug/deps/libnum_integer-6b30072b9ff9be88.rlib" "/target/debug/deps/libnum_traits-3f0549f1f4c73647.rlib" "/target/debug/deps/libuuid-f14cba9afb8c5774.rlib" "/target/debug/deps/libserde_json-e2fcabc95d1f88a3.rlib" "/target/debug/deps/libryu-6250ccc1b3da0647.rlib" "/target/debug/deps/libitoa-7622618995ab5a56.rlib" "/target/debug/deps/libserde-b1d6191c9a4e5762.rlib" "/target/debug/deps/liblog-04a6378eb1407e6f.rlib" "/target/debug/deps/libvalue_bag-64fa716d337e4dc7.rlib" "/target/debug/deps/libcrossbeam_queue-9c9204cde362f042.rlib" "/target/debug/deps/libcrossbeam_utils-0259cc4b70b86053.rlib" "/target/debug/deps/libonce_cell-3548c506bfdf571b.rlib" "/target/debug/deps/libfutures_intrusive-da8d97aa38c950df.rlib" "/target/debug/deps/libparking_lot-fd691e98c6814f7d.rlib" "/target/debug/deps/libparking_lot_core-dc939884d4b38da6.rlib" "/target/debug/deps/liblibc-f7cc4e82b538969b.rlib" "/target/debug/deps/libsmallvec-1bab1a7cb55a60d2.rlib" "/target/debug/deps/libinstant-e762c784f8da740e.rlib" "/target/debug/deps/libcfg_if-90e3626e3c41eec3.rlib" "/target/debug/deps/liblock_api-5df3ec707f3ec46c.rlib" "/target/debug/deps/libscopeguard-ff2bb1f39834214d.rlib" "/target/debug/deps/libeither-656f04c82a594d13.rlib" "/target/debug/deps/libevent_listener-caf303f350ccf135.rlib" "/target/debug/deps/libfutures_util-89a8e15be671ef58.rlib" "/target/debug/deps/libslab-bda603b4c4e76b4a.rlib" "/target/debug/deps/libpin_project_lite-f2671a56a138cdc1.rlib" "/target/debug/deps/libfutures_task-fc22affba0d30485.rlib" "/target/debug/deps/libpin_utils-b7ff504f33cec58a.rlib" "/target/debug/deps/libfutures_channel-d50dc5c74c65dffd.rlib" "/target/debug/deps/libfutures_sink-beff7cc8408399e6.rlib" "/target/debug/deps/libfutures_core-49530b2602be9735.rlib" "/target/debug/deps/libquote-d763dfdef863cc4b.rlib" "/target/debug/deps/libproc_macro2-5eb32b6c8ff372e5.rlib" "/target/debug/deps/libunicode_ident-2cbb51649654f2cb.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-58ab9d2d09b07bb0.rlib" "-Wl,--start-group" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-1aab30bac2090a15.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-9cdaf64f7570f7ff.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-7d64cc870c011631.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-a0a88b78deed3a16.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-315eac6a3174b13c.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-778610d63efc39ce.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-11737b9eef3e285d.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-8165420a20fe4548.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-db4c499f2074199d.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-1a230f9a19aa3698.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-605ec4e87a2c9d10.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-5f171797b6654b84.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-990f92fdff457c3a.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-66ccc5a2fa17d637.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-9dba3f083c9eb142.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-dfc71beee59013ce.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "-Wl,--end-group" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-6f7f4877ee9c613e.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/maa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/target/debug/deps/libsqlx_macros-d767a42d4786fdc4.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /target/debug/deps/libring-b1f6eab169e4093a.rlib(aesni-x86_64-elf.o): unable to initialize decompress status for section .debug_line
          /usr/bin/ld: /target/debug/deps/libring-b1f6eab169e4093a.rlib(aesni-x86_64-elf.o): unable to initialize decompress status for section .debug_line
          /target/debug/deps/libring-b1f6eab169e4093a.rlib: error adding symbols: File format not recognized
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: could not compile `sqlx-macros` due to previous error
warning: build failed, waiting for other jobs to finish...

My project uses sqlx-macro 0.6.0.

Interestingly I tried your sample project and it works for me. I then changed the sqlx dependency in the sample project from 0.5.x to 0.6 and cross compilation still works.

Alexhuszagh commented 2 years ago

Can you post reproducing sample code? Is your project open source? Re-opening this because it only seems the fix was partial.

Madoshakalaka commented 2 years ago

The project is not open source, here is the docker file:

FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu
RUN apt-get update
RUN apt-get install -y clang pkg-config libx11-dev libasound2-dev libudev-dev
Alexhuszagh commented 2 years ago

That's going to make it difficult to debug without a reproducing example, so fixing this might take a while. If anyone has a minimum, reproducing example or open-source code that fails with sqlx-macros, I'd be more than happy to solve this if possible.

Emilgardis commented 2 years ago

I'm trying to replicate this with the following Cargo.toml deps

[dependencies]
sqlx = {version = "0.6", features = ["runtime-async-std-rustls"]}
ring = "0.16.20"

but not able to, can you do cargo tree -p ring -p sqlx --format "{p} {f}" --depth 2 or provide the Cargo.toml dependencies section (dev-dependencies & build-dependencies also if this is a rust 2018/2015 crate)

xie-zheng commented 1 year ago

This no longer reproduces as of the latest main, using this sample project.

$ cross build --target aarch64-unknown-linux-gnu
....
   Compiling futures-intrusive v0.4.0                                                                                                                                                       [50/923]
   Compiling tokio-stream v0.1.9                                                                                                                                                                    
   Compiling digest v0.10.3                                                                                                                                                                         
   Compiling hashlink v0.7.0                                                                                                                                                                        
   Compiling webpki-roots v0.21.1                                                                                                                                                                   
   Compiling rustls v0.19.1                                                                                                                                                                         
   Compiling sha2 v0.10.2                                                                                                                                                                           
   Compiling pin-project-internal v1.0.11                                                                                                                                                           
   Compiling thiserror-impl v1.0.31                                                                                                                                                                 
   Compiling tokio-rustls v0.22.0                                                                                                                                                                   
   Compiling pin-project v1.0.11                                                                                                                                                                    
   Compiling sqlx-rt v0.5.13                                                                                                                                                                        
   Compiling flume v0.10.13                                                                                                                                                                         
   Compiling thiserror v1.0.31                                                                                                                                                                      
   Compiling sqlx-core v0.5.13                                                                                                                                                                      
   Compiling sqlx-macros v0.5.13                                                                                                                                                                    
   Compiling sqlx v0.5.13                                                                                                                                                                           
   Compiling sqlx v0.1.0 (/project)                                                                                                                                                                 
    Finished dev [unoptimized + debuginfo] target(s) in 1m 41s                                                                                                                                      

Let me know if this still reproduces on your end with the 0.2.2 or the latest main and I'll reopen this. Make sure you check your system profiler (top) to ensure it isn't a memory issue,

Hey alex, I don't think the example project you post is convincible.

  1. The problem occur's in the linking stage.
  2. Your sample project does not actually use the sqlx-macros crate.
  3. So it surely won't show same issue.

I met similar problem on my wsl2 ubuntu20.04, and does not on real ubuntu20.04, trying to make a reproducing example.

Alexhuszagh commented 1 year ago

2. Your sample project does not actually use the sqlx-macros crate.

It does, as a dependency. I'll see if it's still an issue using it directly, but I don't see why this should be any different.

   Compiling sqlx-macros v0.5.13                                                                                                                                                                    
   Compiling sqlx v0.5.13                                                                                                                                                                           
   Compiling sqlx v0.1.0 (/project)                                                                                                                                                                 
    Finished dev [unoptimized + debuginfo] target(s) in 1m 41s   

It failing on WSL2 though is good to know. If I can reproduce this, I'll add the appropriate labels and try a fix.

Alexhuszagh commented 1 year ago

@xie-zheng I'm unable to replicate this under the following 3 scenarios using the following crate:

  1. Podman run inside of WSL2 on Windows
  2. Podman run outside of WSL2 on Windows
  3. Docker desktop for Windows run outside of WSL2.
  4. Docker desktop for Windows run inside of WSL2.

All are using the WSL2 backend. In short, I can't replicate it under any conditions.

xie-zheng commented 1 year ago

@xie-zheng I'm unable to replicate this under the following 3 scenarios using the following crate:

All are using the WSL2 backend. In short, I can't replicate it under any conditions.

Thanks alex, currently I'am not able to reproduce the previous linking error.

as for

  1. Your sample project does not actually use the sqlx-macros crate.

I thought dependency would only be linked when really used in the code...

I'll post any progress if i can reproduce the error, thanks so much alex!!!🤝

Alexhuszagh commented 1 year ago

In Matrix chat we were able to reproduce this: I'm trying to find an adequate solution.

Alexhuszagh commented 1 year ago

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?

Alexhuszagh commented 1 year ago

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.