hermit-os / hermit-rs

Hermit for Rust.
Apache License 2.0
1.69k stars 86 forks source link

Cargo configuration file messes with kernel compilation when using `hermit` crate #600

Open vapourismo opened 4 months ago

vapourismo commented 4 months ago

Summary

When the crate that depends on hermit contains a Cargo configuration (e.g. .cargo/config.toml), the compilation of the kernel in the build script of the hermit crate will use that configuration.

How to reproduce a failure

Check out this branch which contains a minimal example to reproduce the issue. It contains a Cargo configuration which sets the build target to riscv64gc-unknown-hermit.

Now when you run cargo build, the build fails during hermit's build script. It looks like it's compiling things for the wrong architecture.

info: syncing channel updates for '1.74.0-aarch64-apple-darwin'
info: latest update on 2023-11-16, rust version 1.74.0 (79e9716c9 2023-11-13)
info: component 'clippy' for target 'aarch64-apple-darwin' is up to date
info: component 'rustfmt' for target 'aarch64-apple-darwin' is up to date
warning: Force-skipping unavailable component 'rust-std-riscv64gc-unknown-hermit'
   Compiling hermit v0.9.1
The following warnings were emitted during compilation:

warning: $ cd "/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/kernel-0.8.0" && env -u CARGO -u CARGO_CFG_PANIC -u CARGO_CFG_TARGET_ARCH -u CARGO_CFG_TARGET_ENDIAN -u CARGO_CFG_TARGET_ENV -u CARGO_CFG_TARGET_HAS_ATOMIC -u CARGO_CFG_TARGET_OS -u CARGO_CFG_TARGET_POINTER_WIDTH -u CARGO_CFG_TARGET_VENDOR -u CARGO_ENCODED_RUSTFLAGS -u CARGO_HOME -u CARGO_MAKEFLAGS -u CARGO_MANIFEST_DIR -u CARGO_MANIFEST_LINKS -u CARGO_PKG_AUTHORS -u CARGO_PKG_DESCRIPTION -u CARGO_PKG_HOMEPAGE -u CARGO_PKG_LICENSE -u CARGO_PKG_LICENSE_FILE -u CARGO_PKG_NAME -u CARGO_PKG_README -u CARGO_PKG_REPOSITORY -u CARGO_PKG_RUST_VERSION -u CARGO_PKG_VERSION -u CARGO_PKG_VERSION_MAJOR -u CARGO_PKG_VERSION_MINOR -u CARGO_PKG_VERSION_PATCH -u CARGO_PKG_VERSION_PRE -u LD_LIBRARY_PATH -u RUSTC -u RUSTDOC -u RUSTUP_HOME -u RUSTUP_TOOLCHAIN -u RUST_RECURSION_COUNT "cargo" "run" "--package=xtask" "--target-dir" "/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/target" "--" "build" "--arch" "riscv64" "--profile" "dev" "--target-dir" "/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/target" "--no-default-features"

error: failed to run custom build command for `hermit v0.9.1`

Caused by:
  process didn't exit successfully: `/Users/ole/Downloads/hermit-mcve/target/debug/build/hermit-4d7fecdfe5b84535/build-script-build` (exit status: 101)
  --- stdout
  cargo:warning=$ cd "/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/kernel-0.8.0" && env -u CARGO -u CARGO_CFG_PANIC -u CARGO_CFG_TARGET_ARCH -u CARGO_CFG_TARGET_ENDIAN -u CARGO_CFG_TARGET_ENV -u CARGO_CFG_TARGET_HAS_ATOMIC -u CARGO_CFG_TARGET_OS -u CARGO_CFG_TARGET_POINTER_WIDTH -u CARGO_CFG_TARGET_VENDOR -u CARGO_ENCODED_RUSTFLAGS -u CARGO_HOME -u CARGO_MAKEFLAGS -u CARGO_MANIFEST_DIR -u CARGO_MANIFEST_LINKS -u CARGO_PKG_AUTHORS -u CARGO_PKG_DESCRIPTION -u CARGO_PKG_HOMEPAGE -u CARGO_PKG_LICENSE -u CARGO_PKG_LICENSE_FILE -u CARGO_PKG_NAME -u CARGO_PKG_README -u CARGO_PKG_REPOSITORY -u CARGO_PKG_RUST_VERSION -u CARGO_PKG_VERSION -u CARGO_PKG_VERSION_MAJOR -u CARGO_PKG_VERSION_MINOR -u CARGO_PKG_VERSION_PATCH -u CARGO_PKG_VERSION_PRE -u LD_LIBRARY_PATH -u RUSTC -u RUSTDOC -u RUSTUP_HOME -u RUSTUP_TOOLCHAIN -u RUST_RECURSION_COUNT "cargo" "run" "--package=xtask" "--target-dir" "/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/target" "--" "build" "--arch" "riscv64" "--profile" "dev" "--target-dir" "/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/target" "--no-default-features"

  --- stderr
     Compiling cfg-if v1.0.0
     Compiling tinyvec_macros v0.1.1
     Compiling utf8parse v0.2.1
     Compiling untrusted v0.9.0
     Compiling rustls-pki-types v1.7.0
     Compiling unicode-bidi v0.3.15
     Compiling anstyle v1.0.7
     Compiling ring v0.17.8
     Compiling crossbeam-utils v0.8.20
     Compiling is_terminal_polyfill v1.70.0
     Compiling syn v2.0.66
  error[E0463]: can't find crate for `core`
    |
    = note: the `riscv64gc-unknown-hermit` target may not be installed
    = help: consider downloading the target with `rustup target add riscv64gc-unknown-hermit`
    = help: consider building the standard library from source with `cargo build -Zbuild-std`

  For more information about this error, try `rustc --explain E0463`.
  error: could not compile `cfg-if` (lib) due to 1 previous error
  warning: build failed, waiting for other jobs to finish...
  error: could not compile `untrusted` (lib) due to 1 previous error
  error: could not compile `tinyvec_macros` (lib) due to 1 previous error
  error: could not compile `utf8parse` (lib) due to 1 previous error
  error[E0463]: can't find crate for `std`
    |
    = note: the `riscv64gc-unknown-hermit` target may not be installed
    = help: consider downloading the target with `rustup target add riscv64gc-unknown-hermit`
    = help: consider building the standard library from source with `cargo build -Zbuild-std`

  error: could not compile `rustls-pki-types` (lib) due to 1 previous error
  error: could not compile `unicode-bidi` (lib) due to 1 previous error
  error: could not compile `is_terminal_polyfill` (lib) due to 1 previous error
  error: could not compile `anstyle` (lib) due to 1 previous error
  error: could not compile `crossbeam-utils` (lib) due to 1 previous error
  The following warnings were emitted during compilation:

  warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:22:
  warning: ring@0.17.8: In file included from include/ring-core/mem.h:60:
  warning: ring@0.17.8: In file included from include/ring-core/base.h:64:
  warning: ring@0.17.8: In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:52:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:32:
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/cdefs.h:828:2: error: Unsupported architecture
  warning: ring@0.17.8: #error Unsupported architecture
  warning: ring@0.17.8:  ^
  warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:22:
  warning: ring@0.17.8: In file included from include/ring-core/mem.h:60:
  warning: ring@0.17.8: In file included from include/ring-core/base.h:64:
  warning: ring@0.17.8: In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:52:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:33:
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/machine/_types.h:36:2: error: architecture not supported
  warning: ring@0.17.8: #error architecture not supported
  warning: ring@0.17.8:  ^
  warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:22:
  warning: ring@0.17.8: In file included from include/ring-core/mem.h:60:
  warning: ring@0.17.8: In file included from include/ring-core/base.h:64:
  warning: ring@0.17.8: In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:52:
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
  warning: ring@0.17.8: typedef __int64_t       __darwin_blkcnt_t;      /* total blocks */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:56:9: error: unknown type name '__int32_t'
  warning: ring@0.17.8: typedef __int32_t       __darwin_blksize_t;     /* preferred block size */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:57:9: error: unknown type name '__int32_t'
  warning: ring@0.17.8: typedef __int32_t       __darwin_dev_t;         /* dev_t */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'
  warning: ring@0.17.8: typedef __uint32_t      __darwin_gid_t;         /* [???] process and group IDs */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'
  warning: ring@0.17.8: typedef __uint32_t      __darwin_id_t;          /* [XSI] pid_t, uid_t, or gid_t*/
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'; did you mean 'uint64_t'?
  warning: ring@0.17.8: typedef __uint64_t      __darwin_ino64_t;       /* [???] Used for 64 bit inodes */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/_types/_uint64_t.h:31:28: note: 'uint64_t' declared here
  warning: ring@0.17.8: typedef unsigned long long uint64_t;
  warning: ring@0.17.8:                            ^
  warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:22:
  warning: ring@0.17.8: In file included from include/ring-core/mem.h:60:
  warning: ring@0.17.8: In file included from include/ring-core/base.h:64:
  warning: ring@0.17.8: In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:52:
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
  warning: ring@0.17.8: typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'
  warning: ring@0.17.8: typedef __uint16_t      __darwin_mode_t;        /* [???] Some file attributes */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
  warning: ring@0.17.8: typedef __int64_t       __darwin_off_t;         /* [???] Used for file sizes */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:72:9: error: unknown type name '__int32_t'
  warning: ring@0.17.8: typedef __int32_t       __darwin_pid_t;         /* [???] process and group IDs */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'
  warning: ring@0.17.8: typedef __uint32_t      __darwin_sigset_t;      /* [???] signal set */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:74:9: error: unknown type name '__int32_t'
  warning: ring@0.17.8: typedef __int32_t       __darwin_suseconds_t;   /* [???] microseconds */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'
  warning: ring@0.17.8: typedef __uint32_t      __darwin_uid_t;         /* [???] user IDs */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'
  warning: ring@0.17.8: typedef __uint32_t      __darwin_useconds_t;    /* [???] microseconds */
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:22:
  warning: ring@0.17.8: In file included from include/ring-core/mem.h:60:
  warning: ring@0.17.8: In file included from include/ring-core/base.h:64:
  warning: ring@0.17.8: In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:53:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types/_intptr_t.h:30:
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/machine/types.h:39:2: error: architecture not supported
  warning: ring@0.17.8: #error architecture not supported
  warning: ring@0.17.8:  ^
  warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:22:
  warning: ring@0.17.8: In file included from include/ring-core/mem.h:60:
  warning: ring@0.17.8: In file included from include/ring-core/base.h:64:
  warning: ring@0.17.8: In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:53:
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types/_intptr_t.h:32:9: error: unknown type name '__darwin_intptr_t'
  warning: ring@0.17.8: typedef __darwin_intptr_t       intptr_t;
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: In file included from crypto/curve25519/curve25519.c:24:
  warning: ring@0.17.8: In file included from crypto/curve25519/internal.h:20:
  warning: ring@0.17.8: In file included from crypto/curve25519/../internal.h:400:
  warning: ring@0.17.8: In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/string.h:61:
  warning: ring@0.17.8: /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/_types.h:43:9: error: unknown type name '__uint32_t'
  warning: ring@0.17.8: typedef __uint32_t      __darwin_wctype_t;
  warning: ring@0.17.8:         ^
  warning: ring@0.17.8: fatal error: too many errors emitted, stopping now [-ferror-limit=]
  warning: ring@0.17.8: 20 errors generated.

  error: failed to run custom build command for `ring v0.17.8`

  Caused by:
    process didn't exit successfully: `/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/target/debug/build/ring-b8750ade0ff822af/build-script-build` (exit status: 1)
    --- stdout
    cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
    cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_8_
    OPT_LEVEL = Some("0")
    TARGET = Some("riscv64gc-unknown-hermit")
    HOST = Some("aarch64-apple-darwin")
    cargo:rerun-if-env-changed=CC_riscv64gc-unknown-hermit
    CC_riscv64gc-unknown-hermit = None
    cargo:rerun-if-env-changed=CC_riscv64gc_unknown_hermit
    CC_riscv64gc_unknown_hermit = Some("/nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/bin/clang")
    cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
    cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
    CRATE_CC_NO_DEFAULTS = None
    DEBUG = Some("true")
    cargo:rerun-if-env-changed=CFLAGS_riscv64gc-unknown-hermit
    CFLAGS_riscv64gc-unknown-hermit = None
    cargo:rerun-if-env-changed=CFLAGS_riscv64gc_unknown_hermit
    CFLAGS_riscv64gc_unknown_hermit = None
    cargo:rerun-if-env-changed=TARGET_CFLAGS
    TARGET_CFLAGS = None
    cargo:rerun-if-env-changed=CFLAGS
    CFLAGS = None
    cargo:warning=In file included from crypto/curve25519/curve25519.c:22:
    cargo:warning=In file included from include/ring-core/mem.h:60:
    cargo:warning=In file included from include/ring-core/base.h:64:
    cargo:warning=In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:52:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:32:
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/cdefs.h:828:2: error: Unsupported architecture
    cargo:warning=#error Unsupported architecture
    cargo:warning= ^
    cargo:warning=In file included from crypto/curve25519/curve25519.c:22:
    cargo:warning=In file included from include/ring-core/mem.h:60:
    cargo:warning=In file included from include/ring-core/base.h:64:
    cargo:warning=In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:52:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:33:
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/machine/_types.h:36:2: error: architecture not supported
    cargo:warning=#error architecture not supported
    cargo:warning= ^
    cargo:warning=In file included from crypto/curve25519/curve25519.c:22:
    cargo:warning=In file included from include/ring-core/mem.h:60:
    cargo:warning=In file included from include/ring-core/base.h:64:
    cargo:warning=In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:52:
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
    cargo:warning=typedef __int64_t       __darwin_blkcnt_t;      /* total blocks */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:56:9: error: unknown type name '__int32_t'
    cargo:warning=typedef __int32_t       __darwin_blksize_t;     /* preferred block size */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:57:9: error: unknown type name '__int32_t'
    cargo:warning=typedef __int32_t       __darwin_dev_t;         /* dev_t */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'
    cargo:warning=typedef __uint32_t      __darwin_gid_t;         /* [???] process and group IDs */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'
    cargo:warning=typedef __uint32_t      __darwin_id_t;          /* [XSI] pid_t, uid_t, or gid_t*/
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'; did you mean 'uint64_t'?
    cargo:warning=typedef __uint64_t      __darwin_ino64_t;       /* [???] Used for 64 bit inodes */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/_types/_uint64_t.h:31:28: note: 'uint64_t' declared here
    cargo:warning=typedef unsigned long long uint64_t;
    cargo:warning=                           ^
    cargo:warning=In file included from crypto/curve25519/curve25519.c:22:
    cargo:warning=In file included from include/ring-core/mem.h:60:
    cargo:warning=In file included from include/ring-core/base.h:64:
    cargo:warning=In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:52:
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
    cargo:warning=typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'
    cargo:warning=typedef __uint16_t      __darwin_mode_t;        /* [???] Some file attributes */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
    cargo:warning=typedef __int64_t       __darwin_off_t;         /* [???] Used for file sizes */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:72:9: error: unknown type name '__int32_t'
    cargo:warning=typedef __int32_t       __darwin_pid_t;         /* [???] process and group IDs */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'
    cargo:warning=typedef __uint32_t      __darwin_sigset_t;      /* [???] signal set */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:74:9: error: unknown type name '__int32_t'
    cargo:warning=typedef __int32_t       __darwin_suseconds_t;   /* [???] microseconds */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'
    cargo:warning=typedef __uint32_t      __darwin_uid_t;         /* [???] user IDs */
    cargo:warning=        ^
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'
    cargo:warning=typedef __uint32_t      __darwin_useconds_t;    /* [???] microseconds */
    cargo:warning=        ^
    cargo:warning=In file included from crypto/curve25519/curve25519.c:22:
    cargo:warning=In file included from include/ring-core/mem.h:60:
    cargo:warning=In file included from include/ring-core/base.h:64:
    cargo:warning=In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:53:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types/_intptr_t.h:30:
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/machine/types.h:39:2: error: architecture not supported
    cargo:warning=#error architecture not supported
    cargo:warning= ^
    cargo:warning=In file included from crypto/curve25519/curve25519.c:22:
    cargo:warning=In file included from include/ring-core/mem.h:60:
    cargo:warning=In file included from include/ring-core/base.h:64:
    cargo:warning=In file included from /nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/resource-root/include/stdint.h:52:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/stdint.h:53:
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/sys/_types/_intptr_t.h:32:9: error: unknown type name '__darwin_intptr_t'
    cargo:warning=typedef __darwin_intptr_t       intptr_t;
    cargo:warning=        ^
    cargo:warning=In file included from crypto/curve25519/curve25519.c:24:
    cargo:warning=In file included from crypto/curve25519/internal.h:20:
    cargo:warning=In file included from crypto/curve25519/../internal.h:400:
    cargo:warning=In file included from /nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/string.h:61:
    cargo:warning=/nix/store/21rgqylgwrms6xzqdf9ggs1wdljh1sqx-libSystem-11.0.0/include/_types.h:43:9: error: unknown type name '__uint32_t'
    cargo:warning=typedef __uint32_t      __darwin_wctype_t;
    cargo:warning=        ^
    cargo:warning=fatal error: too many errors emitted, stopping now [-ferror-limit=]
    cargo:warning=20 errors generated.

    --- stderr

    error occurred: Command "/nix/store/gxi0i62c7nn0ppr0bdplblgkxnnr09pb-clang-wrapper-16.0.6/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=riscv64-unknown-hermit" "-I" "include" "-I" "/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/target/riscv64gc-unknown-hermit/debug/build/ring-b33d96f04ed4b1dd/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-Wall" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-g3" "-DNDEBUG" "-o" "/Users/ole/Downloads/hermit-mcve/target/riscv64gc-unknown-hermit/debug/build/hermit-ae15bf038155b93e/out/target/riscv64gc-unknown-hermit/debug/build/ring-b33d96f04ed4b1dd/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args clang did not execute successfully (status code exit status: 1).

  thread 'main' panicked at /Users/ole/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hermit-0.9.1/build.rs:118:9:
  assertion failed: status.success()
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
mkroening commented 4 months ago

This is a known problem, but thanks for opening an issue for tracking this!

This issue exists due to Cargo configuration unification: once a config file in one of the parent directories sets the target, we cannot unset it again. We need to use the host triple for the build script. --target HOST is probably not happening, and unsetting configuration settings is not there yet.

So in your case there is no way around removing the offending cargo config, sadly.