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

secp256k1-sys cannot be cross compiled using rust cross. #734

Closed
KernelPanic0 opened this issue Sep 9, 2024 · 3 comments · Fixed by #735
Closed

secp256k1-sys cannot be cross compiled using rust cross. #734

KernelPanic0 opened this issue Sep 9, 2024 · 3 comments · Fixed by #735

Comments

@KernelPanic0
Copy link

I am trying to cross compile a rust application from Ubuntu to a Windows machine. With podman installed, I run the following:
cross build --release --target x86_64-pc-windows-msvc
Everything is fine, up until the compiler reaches the secp256k1-sys crate.

   Compiling same-file v1.0.6
The following warnings were emitted during compilation:

warning: [email protected]: GNU compiler is not supported for this target
warning: [email protected]: GNU compiler is not supported for this target
warning: [email protected]: In file included from /usr/include/stdio.h:894,
warning: [email protected]:                  from depend/secp256k1/src/util.h:14,
warning: [email protected]:                  from depend/secp256k1/src/field.h:10,
warning: [email protected]:                  from depend/secp256k1/src/group.h:10,
warning: [email protected]:                  from depend/secp256k1/src/precomputed_ecmult_gen.c:3:
warning: [email protected]: /usr/include/x86_64-linux-gnu/bits/stdio2.h:111:1: error: expected identifier or ‘(’ before ‘{’ token
warning: [email protected]:   111 | {
warning: [email protected]:       | ^
warning: [email protected]: GNU compiler is not supported for this target
warning: [email protected]: GNU compiler is not supported for this target
warning: [email protected]: GNU compiler is not supported for this target
warning: [email protected]: GNU compiler is not supported for this target
warning: [email protected]: GNU compiler is not supported for this target

error: failed to run custom build command for `secp256k1-sys v0.10.0`

Caused by:
  process didn't exit successfully: `/var/www/Kraken/target/release/build/secp256k1-sys-af278a91dc73c6d7/build-script-build` (exit status: 1)
  --- stdout
  OUT_DIR = Some(/var/www/Kraken/target/x86_64-pc-windows-msvc/release/build/secp256k1-sys-6b3c23eb15e9fc2b/out)
  TARGET = Some(x86_64-pc-windows-msvc)
  OPT_LEVEL = Some(3)
  HOST = Some(x86_64-unknown-linux-gnu)
  cargo:rerun-if-env-changed=VCINSTALLDIR
  VCINSTALLDIR = None
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
  CC_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
  CC_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:warning=GNU compiler is not supported for this target
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  CARGO_CFG_TARGET_FEATURE = Some(cmpxchg16b,fxsr,sse,sse2,sse3)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  OUT_DIR = Some(/var/www/Kraken/target/x86_64-pc-windows-msvc/release/build/secp256k1-sys-6b3c23eb15e9fc2b/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some(cmpxchg16b,fxsr,sse,sse2,sse3)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  OUT_DIR = Some(/var/www/Kraken/target/x86_64-pc-windows-msvc/release/build/secp256k1-sys-6b3c23eb15e9fc2b/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some(cmpxchg16b,fxsr,sse,sse2,sse3)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
  CFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
  CFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=GNU compiler is not supported for this target
  cargo:warning=In file included from /usr/include/stdio.h:894,
  cargo:warning=                 from depend/secp256k1/src/util.h:14,
  cargo:warning=                 from depend/secp256k1/src/field.h:10,
  cargo:warning=                 from depend/secp256k1/src/group.h:10,
  cargo:warning=                 from depend/secp256k1/src/precomputed_ecmult_gen.c:3:
  cargo:warning=/usr/include/x86_64-linux-gnu/bits/stdio2.h:111:1: error: expected identifier or ‘(’ before ‘{’ token
  cargo:warning=  111 | {
  cargo:warning=      | ^
  cargo:warning=GNU compiler is not supported for this target
  cargo:warning=GNU compiler is not supported for this target
  cargo:warning=GNU compiler is not supported for this target
  cargo:warning=GNU compiler is not supported for this target
  cargo:rerun-if-env-changed=AR_x86_64-pc-windows-msvc
  AR_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=AR_x86_64_pc_windows_msvc
  AR_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:warning=GNU compiler is not supported for this target
  cargo:rerun-if-env-changed=ARFLAGS_x86_64-pc-windows-msvc
  ARFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=ARFLAGS_x86_64_pc_windows_msvc
  ARFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None

  --- stderr


  error occurred: Failed to find tool. Is `lib.exe` installed?

Am I missing something obivous?

@apoelstra
Copy link
Member

We should add a patch which drops that stdio.h code. It's totally dead, so I guess the compilers we test on filter it out early enough that it doesn't cause problems, but it shouldn't be there.

I'll PR to delete that code, and backport to 0.10.0 which should hopefully fix your issue.

Having said that, the problem is in your copy of stdio.h so I feel I should say "not our fault" :).

@Kixunil
Copy link
Collaborator

Kixunil commented Sep 9, 2024

Having said that, the problem is in your copy of stdio.h so I feel I should say "not our fault" :).

I agree. Most of our build issues are either bug in cc or wrong C compiler and I'd rather not pollute our code with special exceptions to fix these. (I believe there's a way to print a message "please check your compiler before filing an issue" on build failure.)

That being said, if we can easily delete dead code and it's likely to improve reliability on multiple targets then I don't object to it.

@apoelstra
Copy link
Member

@Kixunil in this case we are already trying to eliminate all calls into the C standard library because they don't need them and they break wasm (at runtime).

So deleting this code is totally within the normal goals of this crate ... it's just that fixing this particular bug is not something we'd be willing to take too many pains to fix. (But fortunately it turns out to be zero marginal pain because we want to delete the code anyway.)

apoelstra added a commit that referenced this issue Sep 10, 2024
b66bae7 secp256k1-sys: update util.h patch to delete more stdio code (Andrew Poelstra)

Pull request description:

  Fixes #734

ACKs for top commit:
  Kixunil:
    ACK b66bae7

Tree-SHA512: 8d1266a1decbd06055922a19d687ec1e616dcf8a21764386c73cc8e20d390c9bc5a6ca416a3dc2602cc8ad7a5641f1af8607d3f64291325b2b2fff343677bc82
apoelstra added a commit to apoelstra/rust-secp256k1 that referenced this issue Sep 10, 2024
ratankaliani pushed a commit to sp1-patches/rust-secp256k1 that referenced this issue Sep 24, 2024
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.

3 participants