Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking failure when cross compiling for ARM64 on AMD64 #1569

Closed
aurabindo opened this issue Jul 31, 2021 · 6 comments
Closed

Linking failure when cross compiling for ARM64 on AMD64 #1569

aurabindo opened this issue Jul 31, 2021 · 6 comments
Labels
bug done in pr Already done in a PR

Comments

@aurabindo
Copy link

Bug Report

Environment

Host: amd64
Target: aarch64-unknown-linux-gnu

Zola version: 14

Step to reproduce

export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc
cargo build --release --target=aarch64-unknown-linux-gnu --verbose

Error:

   Compiling zola v0.14.0 (/home/daes/git/zola)
     Running `rustc --crate-name zola --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto -C codegen-units=1 -C metadata=e61bf94b5c4edab4 -C extra-filename=-e61bf94b5c4edab4 --out-dir /home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -C linker=/usr/bin/aarch64-linux-gnu-gcc -L dependency=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps -L dependency=/home/daes/git/zola/target/release/deps --extern atty=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libatty-8beaa8438e67c42f.rlib --extern chrono=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libchrono-190bc08a3c2a3137.rlib --extern clap=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libclap-44b172aead2a0fa4.rlib --extern ctrlc=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libctrlc-5d0f9fc087aadbca.rlib --extern errors=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/liberrors-6fa92b1a94af5ddf.rlib --extern front_matter=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libfront_matter-7911f48831fe4ee9.rlib --extern globset=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libglobset-3b0d67e8f5a4373c.rlib --extern hyper=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libhyper-f0cfc338fbe8a1bc.rlib --extern lazy_static=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/liblazy_static-9ccf4f30a9e50f28.rlib --extern mime_guess=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libmime_guess-aa2f11bf696ea42e.rlib --extern notify=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libnotify-36e75e5ac2735928.rlib --extern open=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libopen-419377b7d5f1dcdd.rlib --extern percent_encoding=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libpercent_encoding-d9e5ea65a81abd81.rlib --extern relative_path=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/librelative_path-f655ba494cdabb54.rlib --extern search=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libsearch-ccf9afcb30599017.rlib --extern serde_json=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libserde_json-9711dd4b59cb6673.rlib --extern site=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libsite-75ff580d7b761f60.rlib --extern termcolor=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libtermcolor-9cdf49124c0a307b.rlib --extern tokio=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libtokio-980a9c044797f93a.rlib --extern url=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/liburl-ec4a8ab13fbb0e7f.rlib --extern utils=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libutils-5ce44656c65e4cd8.rlib --extern ws=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/libws-bacc24ae5785093c.rlib -L native=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/build/onig_sys-1b3f9df4a6d1537c/out -L native=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/build/ring-18a27d3f87f491b3/out -L native=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/build/libwebp-sys-39d345070046bdc8/out -L native=/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/build/sass-sys-4da13cf9d4cca085/out/build/lib`
error: linking with `/usr/bin/aarch64-linux-gnu-gcc` failed: exit status: 1
  |
  = note: "/usr/bin/aarch64-linux-gnu-gcc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-Wl,--as-needed" "-L" "/home/daes/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/zola-e61bf94b5c4edab4.zola.1bzlaou2-cgu.0.rcgu.o" "-o" "/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps/zola-e61bf94b5c4edab4" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/deps" "-L" "/home/daes/git/zola/target/release/deps" "-L" "/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/build/onig_sys-1b3f9df4a6d1537c/out" "-L" "/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/build/ring-18a27d3f87f491b3/out" "-L" "/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/build/libwebp-sys-39d345070046bdc8/out" "-L" "/home/daes/git/zola/target/aarch64-unknown-linux-gnu/release/build/sass-sys-4da13cf9d4cca085/out/build/lib" "-L" "/home/daes/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/rustcYmSDfi/liblibwebp_sys-7bf01effd812e655.rlib" "/tmp/rustcYmSDfi/libring-294d111b49accdfc.rlib" "/tmp/rustcYmSDfi/libsass_sys-85794fb30020c0c1.rlib" "/tmp/rustcYmSDfi/libonig_sys-6c23c9b552f5a72e.rlib" "-Wl,--start-group" "-Wl,--end-group" "/home/daes/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcompiler_builtins-8e0dea81c2814a1a.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: /usr/lib/gcc/aarch64-linux-gnu/11.1.0/../../../../aarch64-linux-gnu/bin/ld: /tmp/rustcYmSDfi/libsass_sys-85794fb30020c0c1.rlib(sass_context.o): Relocations in generic ELF (EM: 62)
          /usr/lib/gcc/aarch64-linux-gnu/11.1.0/../../../../aarch64-linux-gnu/bin/ld: /tmp/rustcYmSDfi/libsass_sys-85794fb30020c0c1.rlib(sass_context.o): Relocations in generic ELF (EM: 62)
@Keats Keats added the bug label Jul 31, 2021
@Keats
Copy link
Collaborator

Keats commented Jul 31, 2021

Eh libsass again..
At this point I would wait for #1535 which will happen probably in the next major version of Zola.
Or if you know how to, I would take a PR to fix https://github.com/compass-rs/sass-rs/blob/master/sass-sys/build.rs in the build process for that arch

@aurabindo
Copy link
Author

I was able to fix sass-rs compile individually by overriding the linker for the architecture I want to build via .cargo/config.toml

[target.aarch64-unknown-linux-gnu]
rustflags = [
    "-C", "linker=aarch64-linux-gnu-gcc",
]

However, using the local version of sass-rs with this fix, hyper fails to build, which ended up being due to reqwest not cross compiling because of pkg-config not having the right cross compiling config, owing to openssl directory not being found:

error: failed to run custom build command for `openssl-sys v0.9.65`

Caused by:
  process didn't exit successfully: `/home/daes/git/reqwest/target/release/build/openssl-sys-5870f37698241082/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  AARCH64_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_ALLOW_CROSS_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: "pkg-config has not been configured to support cross-compilation.\n\n                Install a sysroot for the target platform and configure it via\n                PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a\n                cross-compiling wrapper for pkg-config and set it via\n                PKG_CONFIG environment variable."

  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-unknown-linux-gnu
  $TARGET = aarch64-unknown-linux-gnu
  openssl-sys = 0.9.65

@Keats
Copy link
Collaborator

Keats commented Aug 24, 2021

Hm where would openssl come from? By default it should use rust-tls everywhere...

@pvonmoradi
Copy link

@Keats I think we're having a related issue here: termux/termux-packages#11941

@Keats
Copy link
Collaborator

Keats commented Jan 9, 2023

Any idea why openssl is being pulled?

@Keats
Copy link
Collaborator

Keats commented Jan 12, 2023

Found in the reqwest README:

Reqwest uses rust-native-tls, which will use the operating system TLS framework if available, meaning Windows and macOS. On Linux, it will use OpenSSL 1.1.

Keats added a commit that referenced this issue Jan 20, 2023
Easier cross-compiling
Closes #1569
@Keats Keats added the done in pr Already done in a PR label Jan 20, 2023
@Keats Keats closed this as completed in 61570bb Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug done in pr Already done in a PR
Projects
None yet
Development

No branches or pull requests

3 participants