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

cjdns-v22: Cross-compilation error for libsodium-sys (and ring) #205

Open
yojoe opened this issue Apr 15, 2023 · 0 comments
Open

cjdns-v22: Cross-compilation error for libsodium-sys (and ring) #205

yojoe opened this issue Apr 15, 2023 · 0 comments

Comments

@yojoe
Copy link

yojoe commented Apr 15, 2023

When cross-compiling cjdns-v22 the build fails during the build of the libsodium-sys library.
I'm building for x86_64 with Ubuntu 22.04 on Apple Silicon (M1) via a Multipass VM.
The cause for the failure is not a compilation error, but the fact that the libsodium-sys tests (make check) are executed, which shouldn't be done when cross-compiling.

The sodiumoxide build.rs has a line which should prevent executing the tests, but for some strange reason the libsodium-sys build obviously gets the wrong TARGET environment variable value. Somewhere in the output file of the build (target/release/build/cjdns_sys-051ac9670f9a8917/output) I find the following lines:

TARGET = Some("aarch64-unknown-linux-gnu")
HOST = Some("aarch64-unknown-linux-gnu")

This is strange, because I explicitly set the TARGET_ARCH environment variable as required in the cross-do script, and I even try to set the TARGET environment variable explicitly as shown below:

$ export TARGET_ARCH='x86_64'
$ export TARGET='=x86_64-linux-gnu-'
$ SYSTEM=linux CROSS_COMPILE=x86_64-linux-gnu- ./cross-do

...
Using x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiler CC: x86_64-linux-gnu-gcc
Compiler CFLAGS:
Compiler LDFLAGS:
   Compiling libc v0.2.139
...
   Compiling libsodium-sys v0.2.6 (https://github.com/cjdelisle/sodiumoxide?rev=9f6a18d40a4db253edfebac9f2ce5c22d09b1f47#9f6a18d4)
...
   Compiling boringtun v0.3.0 (https://github.com/cjdelisle/boringtun?rev=f288b2f461e7322a278b63b1ddc4ab705b5b7462#f288b2f4)
   Compiling tokio v1.16.1
error: failed to run custom build command for `libsodium-sys v0.2.6 (https://github.com/cjdelisle/sodiumoxide?rev=9f6a18d40a4db253edfebac9f2ce5c22d09b1f47#9f6a18d4)`

Caused by:
  process didn't exit successfully: `/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-66bd81d0eab81d76/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=SODIUM_LIB_DIR
  cargo:rerun-if-env-changed=SODIUM_SHARED
  cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG
  cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE
  OPT_LEVEL = Some("2")
  TARGET = Some("aarch64-unknown-linux-gnu")
  HOST = Some("aarch64-unknown-linux-gnu")
  CC_aarch64-unknown-linux-gnu = None
  CC_aarch64_unknown_linux_gnu = None
  HOST_CC = None
  CC = Some("x86_64-linux-gnu-gcc")
  CFLAGS_aarch64-unknown-linux-gnu = None
  CFLAGS_aarch64_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = Some("")
  CRATE_CC_NO_DEFAULTS = None
...
make[3]: Leaving directory '/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-f3937098b48cb1aa/out/source/libsodium/test/default'
  make  check-TESTS
  make[3]: Entering directory '/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-f3937098b48cb1aa/out/source/libsodium/test/default'
  make[4]: Entering directory '/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-f3937098b48cb1aa/out/source/libsodium/test/default'
  FAIL: auth
  FAIL: aead_aes256gcm2
  FAIL: aead_aes256gcm
  FAIL: aead_xchacha20poly1305
  FAIL: auth3
  FAIL: aead_chacha20poly1305
  FAIL: auth2
  FAIL: aead_chacha20poly13052
  FAIL: box2
  FAIL: auth6
  FAIL: box
  FAIL: auth5
  FAIL: box8
  FAIL: box7
  FAIL: auth7
  FAIL: box_easy
  FAIL: box_seed
  FAIL: box_seal
  FAIL: chacha20
  FAIL: box_easy2
  FAIL: codecs
  FAIL: core1
  FAIL: core2
  FAIL: core3
  FAIL: core5
  FAIL: core6
  FAIL: core4
  FAIL: generichash
  FAIL: ed25519_convert
  FAIL: generichash2
  FAIL: hash
  FAIL: generichash3
  FAIL: keygen
  FAIL: hash3
  FAIL: kdf
  FAIL: kx
  FAIL: misuse
  FAIL: metamorphic
  FAIL: onetimeauth2
  FAIL: onetimeauth
  FAIL: onetimeauth7
  FAIL: pwhash_argon2i
  FAIL: pwhash_argon2id
  FAIL: randombytes
  FAIL: scalarmult
  FAIL: scalarmult5
  FAIL: scalarmult2
  FAIL: scalarmult6
  FAIL: scalarmult7
  FAIL: scalarmult8
  FAIL: secretbox
  FAIL: secretbox7
  FAIL: secretbox2
  FAIL: secretbox8
  FAIL: secretbox_easy
  FAIL: secretbox_easy2
  FAIL: secretstream
  FAIL: shorthash
  FAIL: sign
  FAIL: sodium_core
  FAIL: sodium_utils
  FAIL: sodium_version
  FAIL: stream
  FAIL: stream3
  FAIL: stream2
  FAIL: stream4
  FAIL: verify1
  FAIL: sodium_utils3
  FAIL: sodium_utils2
  FAIL: core_ed25519
  FAIL: pwhash_scrypt
  FAIL: core_ristretto255
  FAIL: pwhash_scrypt_ll
  FAIL: scalarmult_ed25519
  FAIL: scalarmult_ristretto255
  FAIL: siphashx24
  FAIL: xchacha20
  ============================================================================
  Testsuite summary for libsodium 1.0.18
  ============================================================================
  # TOTAL: 77
  # PASS:  0
  # SKIP:  0
  # XFAIL: 0
  # FAIL:  77
  # XPASS: 0
  # ERROR: 0
  ============================================================================
  See test/default/test-suite.log
  Please report to https://github.com/jedisct1/libsodium/issues
  ============================================================================
  make[4]: Leaving directory '/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-f3937098b48cb1aa/out/source/libsodium/test/default'
  make[3]: Leaving directory '/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-f3937098b48cb1aa/out/source/libsodium/test/default'
  make[2]: Leaving directory '/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-f3937098b48cb1aa/out/source/libsodium/test/default'
  make[1]: Leaving directory '/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-f3937098b48cb1aa/out/source/libsodium/test'
...

thread 'main' panicked at '
  Failed to build libsodium using cd "/home/ubuntu/cjdns-v22/target/release/build/libsodium-sys-f3937098b48cb1aa/out/source/libsodium" && V="1" "make" "check" "-j8"
  ', /home/ubuntu/.cargo/git/checkouts/sodiumoxide-9b8c3ad42446e2d9/9f6a18d/libsodium-sys/build.rs:277:9

So how can it happen that the libsodium-sys build ends up with a wrong TARGET env var value, although I explicitly set it to a different value before the build?

The same is probably happening to the ring library, but since it doesn't seem to have any tests executed during the build, the problem is hidden (for now):

~/cjdns-v22$ grep -rnH "TARGET = Some" *
target/release/build/ring-828bbe5e60beb4a3/output:2:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:16:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:30:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:44:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:58:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:72:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:86:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:100:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:114:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:128:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:142:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:156:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:170:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:184:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:198:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:212:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:226:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:240:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:254:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:268:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:282:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/ring-828bbe5e60beb4a3/output:301:TARGET = Some("aarch64-unknown-linux-gnu")
target/release/build/cjdns_sys-051ac9670f9a8917/output:1480:TARGET = Some("aarch64-unknown-linux-gnu")
@yojoe yojoe changed the title cjdns-v22: Cross compilation error for libsodium-sys cjdns-v22: Cross-compilation error for libsodium-sys (and ring) Apr 15, 2023
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

No branches or pull requests

1 participant