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

Cross compiling fails #277

Closed
candrews opened this issue Nov 28, 2019 · 2 comments · Fixed by #285
Closed

Cross compiling fails #277

candrews opened this issue Nov 28, 2019 · 2 comments · Fixed by #285

Comments

@candrews
Copy link

I'm running an amd64 system trying to cross compile for x86 (which is common for multilib).

Building quiche by running:
cargo build --target=i686-unknown-linux-gnu

results in this build failure:

   Compiling quiche v0.1.0 (/var/tmp/portage/net-libs/quiche-0.1.0/work/quiche-0.1.0-abi_x86_32.x86)
error: failed to run custom build command for `quiche v0.1.0 (/var/tmp/portage/net-libs/quiche-0.1.0/work/quiche-0.1.0-abi_x86_32.x86)`

Caused by:
  process didn't exit successfully: `/var/tmp/portage/net-libs/quiche-0.1.0/work/quiche-0.1.0-abi_x86_32.x86/target/release/build/quiche-0b547c5a4bcd114c/build-script-build` (exit code: 101)
--- stdout
running: "cmake" "/var/tmp/portage/net-libs/quiche-0.1.0/work/quiche-0.1.0-abi_x86_32.x86/deps/boringssl" "-DCMAKE_INSTALL_PREFIX=/var/tmp/portage/net-libs/quiche-0.1.0/work/quiche-0.1.0-abi_x86_32.x86/target/i686-unknown-linux-gnu/release/build/quiche-f20871fc80c099ad/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m32 -march=i686 -march=native -pipe -fuse-linker-plugin -flto -ftree-vectorize -ftree-slp-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-lto -fno-use-linker-plugin" "-DCMAKE_C_COMPILER=/usr/lib/ccache/bin/x86_64-pc-linux-gnu-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m32 -march=i686 -march=native -pipe -fuse-linker-plugin -flto -ftree-vectorize -ftree-slp-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-lto -fno-use-linker-plugin" "-DCMAKE_CXX_COMPILER=/usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++" "-DCMAKE_BUILD_TYPE=RelWithDebInfo"

[snip]

/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(aesni-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(aes-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(ghash-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(md5-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(sha1-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(sha256-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(sha512-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(vpaes-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(x86_64-mont.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(chacha-x86_64.S.o)' is incompatible with i386 output
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `../crypto/libcrypto.a(x86_64-mont5.S.o)' is incompatible with i386 output

Here's the full build log:
net-libs:quiche-0.1.0:20191127-222131.log

Regardless of the --target provided to cargo, quiche is always building boringssl for the native arch, not the target one.

Parameters need to be provided to the boringssl cmake build process so it builds for the cargo provided --target arch and not the native arch.

@candrews
Copy link
Author

rust-lang/cmake-rs#80 seems relevant.

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Nov 30, 2019
* Depend on multilib rust, doesn't support rust-bin, see:
  https://bugs.gentoo.org/701362
* Pass --target to cargo
* Build boringssl separately because cargo doesn't cross compile
  correctly, see:
  cloudflare/quiche#277

Closes: https://bugs.gentoo.org/701346
Package-Manager: Portage-2.3.80, Repoman-2.3.19
Signed-off-by: Craig Andrews <candrews@gentoo.org>
@junhochoi
Copy link
Contributor

@candrews I made a PR #285 to fix this issue. Let me know this works for you.

ghedo pushed a commit that referenced this issue Dec 3, 2019
Pass 32bit toolchain to cmake for cross-building x86 linux from
x86_64 linux. Also CI target is added.

Ref: https://github.com/google/boringssl/blob/master/BUILDING.md

Fixes #277.
ghedo pushed a commit that referenced this issue Dec 3, 2019
Pass 32bit toolchain to cmake for cross-building x86 linux from
x86_64 linux. Also CI target is added.

Ref: https://github.com/google/boringssl/blob/master/BUILDING.md

Fixes #277.
ghedo pushed a commit that referenced this issue Dec 3, 2019
Pass 32bit toolchain to cmake for cross-building x86 linux from
x86_64 linux. Also CI target is added.

Ref: https://github.com/google/boringssl/blob/master/BUILDING.md

Fixes #277.
@ghedo ghedo closed this as completed in #285 Dec 3, 2019
ghedo pushed a commit that referenced this issue Dec 3, 2019
Pass 32bit toolchain to cmake for cross-building x86 linux from
x86_64 linux. Also CI target is added.

Ref: https://github.com/google/boringssl/blob/master/BUILDING.md

Fixes #277.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants