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 v0.10.1 fails to compile on thumbv7em-none-eabi target #766

Open
jsdw opened this issue Nov 20, 2024 · 2 comments
Open

secp256k1-sys v0.10.1 fails to compile on thumbv7em-none-eabi target #766

jsdw opened this issue Nov 20, 2024 · 2 comments

Comments

@jsdw
Copy link

jsdw commented Nov 20, 2024

When I try to compile a crate including secp256k1 with cargo build --target thumbv7em-none-eabi, I run into the error printed below.

is it expected that this crate will fail to compile on this target? Perhaps you've encountered this issue before and, if so, perhaps you might have pointers on how to avoid it?

warning: [email protected]: depend/secp256k1/contrib/lax_der_parsing.c:7:10: fatal error: string.h: No such file or directory
warning: [email protected]:     7 | #include <string.h>
warning: [email protected]:       |          ^~~~~~~~~~
warning: [email protected]: compilation terminated.
warning: [email protected]: In file included from depend/secp256k1/src/util.h:13,
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]: /opt/homebrew/Cellar/arm-none-eabi-gcc/14.2.0/lib/gcc/arm-none-eabi/14.2.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
warning: [email protected]:     9 | # include_next <stdint.h>
warning: [email protected]:       |                ^~~~~~~~~~
warning: [email protected]: compilation terminated.
error: failed to run custom build command for `secp256k1-sys v0.10.1`

Caused by:
  process didn't exit successfully: `/Users/jameswilson/Work/subxt/testing/no-std-tests/target/debug/build/secp256k1-sys-7af7af88b98c083c/build-script-build` (exit status: 1)
  --- stdout
  OUT_DIR = Some(/Users/jameswilson/Work/subxt/testing/no-std-tests/target/thumbv7em-none-eabi/debug/build/secp256k1-sys-f6a905ec8c4a28e7/out)
  OPT_LEVEL = Some(0)
  TARGET = Some(thumbv7em-none-eabi)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CC_thumbv7em-none-eabi
  CC_thumbv7em-none-eabi = None
  cargo:rerun-if-env-changed=CC_thumbv7em_none_eabi
  CC_thumbv7em_none_eabi = 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:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  CARGO_CFG_TARGET_FEATURE = Some(dsp,mclass,thumb-mode,thumb2,v5te,v6,v6k,v6t2,v7)
  cargo:rerun-if-env-changed=CFLAGS_thumbv7em-none-eabi
  CFLAGS_thumbv7em-none-eabi = None
  cargo:rerun-if-env-changed=CFLAGS_thumbv7em_none_eabi
  CFLAGS_thumbv7em_none_eabi = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  OUT_DIR = Some(/Users/jameswilson/Work/subxt/testing/no-std-tests/target/thumbv7em-none-eabi/debug/build/secp256k1-sys-f6a905ec8c4a28e7/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  TARGET = Some(thumbv7em-none-eabi)
  CARGO_CFG_TARGET_FEATURE = Some(dsp,mclass,thumb-mode,thumb2,v5te,v6,v6k,v6t2,v7)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CFLAGS_thumbv7em-none-eabi
  CFLAGS_thumbv7em-none-eabi = None
  cargo:rerun-if-env-changed=CFLAGS_thumbv7em_none_eabi
  CFLAGS_thumbv7em_none_eabi = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  OUT_DIR = Some(/Users/jameswilson/Work/subxt/testing/no-std-tests/target/thumbv7em-none-eabi/debug/build/secp256k1-sys-f6a905ec8c4a28e7/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  TARGET = Some(thumbv7em-none-eabi)
  CARGO_CFG_TARGET_FEATURE = Some(dsp,mclass,thumb-mode,thumb2,v5te,v6,v6k,v6t2,v7)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CFLAGS_thumbv7em-none-eabi
  CFLAGS_thumbv7em-none-eabi = None
  cargo:rerun-if-env-changed=CFLAGS_thumbv7em_none_eabi
  CFLAGS_thumbv7em_none_eabi = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=depend/secp256k1/contrib/lax_der_parsing.c:7:10: fatal error: string.h: No such file or directory
  cargo:warning=    7 | #include <string.h>
  cargo:warning=      |          ^~~~~~~~~~
  cargo:warning=compilation terminated.
  cargo:warning=In file included from depend/secp256k1/src/util.h:13,
  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=/opt/homebrew/Cellar/arm-none-eabi-gcc/14.2.0/lib/gcc/arm-none-eabi/14.2.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
  cargo:warning=    9 | # include_next <stdint.h>
  cargo:warning=      |                ^~~~~~~~~~
  cargo:warning=compilation terminated.

  --- stderr


  error occurred: Command "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-mthumb" "-march=armv7e-m" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm/wasm-sysroot" "-Wall" "-Wextra" "-Wno-unused-function" "-Wno-unused-parameter" "-DSECP256K1_API=" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DENABLE_MODULE_ELLSWIFT=1" "-Dprintf(...)=" "-DECMULT_GEN_PREC_BITS=4" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-DENABLE_MODULE_RECOVERY=1" "-o" "/Users/jameswilson/Work/subxt/testing/no-std-tests/target/thumbv7em-none-eabi/debug/build/secp256k1-sys-f6a905ec8c4a28e7/out/c928380082b86401-precomputed_ecmult_gen.o" "-c" "depend/secp256k1/src/precomputed_ecmult_gen.c" with args arm-none-eabi-gcc did not execute successfully (status code exit status: 1).
@apoelstra
Copy link
Member

I think this should be fixed by #663.

@apoelstra
Copy link
Member

Ah, no, this is different from #663. This is about string.h in lax_der_parsing. Interesting.

This standards page says that a freestanding implementation must have stdint.h; possibly your compiler does not support C99. But string.h is not required and in theory even a confirming C99 compiler might not have it (but we use e.g. memcpy throughout the codebase, so it would be quite invasive to try to fix this).

Possibly there is way to configure your compiler to provide paths to standard headers? For the things we're doing in this library you could maybe also define your own versions somewhere.

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

2 participants