briansmith / ring

Safe, fast, small crypto using Rust
Other
3.7k stars 698 forks source link

Error building for arm - "ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?" #2139

Closed andrewdavidmackenzie closed 27 minutes ago

andrewdavidmackenzie commented 2 weeks ago

I have ring as an indirect dependency, and all is well.

I use cargo-dist to prepare and build my releases, and that works well.

However, I want to produce pre-built binaries for Raspberry Pis, and so I added these targets ("aarch64-unknown-linux-gnu", "armv7-unknown-linux-gnueabihf") to my cargo-dist release target list.

For both of those targets, the build failed when build ring with this build error:

warning: ring@0.17.8: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?
warning: ring@0.17.8: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?

I added cargo meta-data to install gcc toolchains, but still no luck. It did change the aarach64 build failure to this complicated one!

The armv7 one remains the same, despite a few attempts at installing different gcc toolchains for that target, using cargo.toml meta-data (https://github.com/andrewdavidmackenzie/pigg/blob/master/Cargo.toml#L125)

I have created this issue in cargo-dist looking for help

Thanks in advance for any help or pointers!

andrewdavidmackenzie commented 2 weeks ago

More info...

In my failing cargo-dist build the error message states:

The following warnings were emitted during compilation:

warning: ring@0.17.8: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?
warning: ring@0.17.8: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?

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

So, I thought I'd try adding the install of that (arm-linux-gnueabihf-gcc) in my customization of cargo dist:

- name: Install GCC for arm
  run: |
    sudo apt-get install gcc-arm-linux-gnueabihf
    sudo apt-get install arm-linux-gnueabihf-gcc

Which (kinda as I expected) lead to this error from the next build

`"E: Unable to locate package arm-linux-gnueabihf-gcc"``

as that's the binary name, not the package name.

So, I went back to where I was (installing package gcc-arm-linux-gnueabihf)....

I think the summary is (would be great to get a confirmation):

The package to be installed is called gcc-arm-linux-gnueabihf

The name of the binary to be invoked is arm-linux-gnueabihf-gcc which is part of that package

I install that package via cargo-dist meta data:

[workspace.metadata.dist.dependencies.apt]
gcc-aarch64-linux-gnu = { version = '*', targets = ["aarch64-unknown-linux-gnu"] }
gcc-arm-linux-gnueabihf = { version = '*', targets = ["armv7-unknown-linux-gnueabihf"] }

but still get the error as described, where ring build fails.

 cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?
andrewdavidmackenzie commented 2 weeks ago

If there is anything else I can do, or information I can supply, regarding this issue - please let me know.

andrewdavidmackenzie commented 4 days ago

Thought I'd ping to see if any triage, or ACK, of this issue... Thanks

andrewdavidmackenzie commented 1 day ago

Ping. Still facing this issue Example GH Actions run and was wondering if it could get any attention or comment? Thanks.

andrewdavidmackenzie commented 20 hours ago

FYI - Digging more I suspect some cargo-dist issue, and am pursuing it here: https://github.com/axodotdev/cargo-dist/issues/1378

So, probably not a ring issue, unless the ring build is specifying a linker in some non-standard way. Thanks

andrewdavidmackenzie commented 20 hours ago

On my local machine, this works:

cross build --target armv7-unknown-linux-gnueabihf

but

cargo build --target armv7-unknown-linux-gnueabihf

(after checking:

brew install arm-linux-gnueabihf-binutils
Warning: arm-linux-gnueabihf-binutils 2.43.1 is already installed and up-to-date.

)

but it fails:

Compiling cfg-if v1.0.0
   Compiling untrusted v0.9.0
   Compiling spin v0.9.8
   Compiling ring v0.17.8 (/Users/andrew/workspace/ring)
   Compiling getrandom v0.2.15
The following warnings were emitted during compilation:

warning: ring@0.17.8: Compiler family detection failed due to error: ToolExecError: Command "arm-linux-gnueabihf-gcc" "-E" "/Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/14424818972907825342detect_compiler_family.c" with args arm-linux-gnueabihf-gcc did not execute successfully (status code exit status: 1).
warning: ring@0.17.8: Compiler family detection failed due to error: ToolExecError: Command "arm-linux-gnueabihf-gcc" "-E" "/Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/12101760709934291851detect_compiler_family.c" with args arm-linux-gnueabihf-gcc did not execute successfully (status code exit status: 1).
warning: ring@0.17.8: arm-linux-gnueabihf-gcc: error trying to exec 'cc1': execvp: No such file or directory

error: failed to run custom build command for `ring v0.17.8 (/Users/andrew/workspace/ring)`

Caused by:
  process didn't exit successfully: `/Users/andrew/workspace/ring/target/debug/build/ring-a304c63f02e21ada/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=CARGO_MANIFEST_DIR
  cargo:rerun-if-env-changed=CARGO_PKG_NAME
  cargo:rerun-if-env-changed=CARGO_PKG_VERSION_MAJOR
  cargo:rerun-if-env-changed=CARGO_PKG_VERSION_MINOR
  cargo:rerun-if-env-changed=CARGO_PKG_VERSION_PATCH
  cargo:rerun-if-env-changed=CARGO_PKG_VERSION_PRE
  cargo:rerun-if-env-changed=CARGO_MANIFEST_LINKS
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rerun-if-env-changed=OUT_DIR
  cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH
  cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS
  cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ENV
  cargo:rerun-if-env-changed=DEBUG
  cargo:rerun-if-env-changed=PERL_EXECUTABLE
  OPT_LEVEL = Some(0)
  TARGET = Some(armv7-unknown-linux-gnueabihf)
  OUT_DIR = Some(/Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CC_armv7-unknown-linux-gnueabihf
  CC_armv7-unknown-linux-gnueabihf = None
  cargo:rerun-if-env-changed=CC_armv7_unknown_linux_gnueabihf
  CC_armv7_unknown_linux_gnueabihf = 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
  cargo:warning=Compiler family detection failed due to error: ToolExecError: Command "arm-linux-gnueabihf-gcc" "-E" "/Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/14424818972907825342detect_compiler_family.c" with args arm-linux-gnueabihf-gcc did not execute successfully (status code exit status: 1).
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  CARGO_CFG_TARGET_FEATURE = None
  cargo:rerun-if-env-changed=CFLAGS_armv7-unknown-linux-gnueabihf
  CFLAGS_armv7-unknown-linux-gnueabihf = None
  cargo:rerun-if-env-changed=CFLAGS_armv7_unknown_linux_gnueabihf
  CFLAGS_armv7_unknown_linux_gnueabihf = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=Compiler family detection failed due to error: ToolExecError: Command "arm-linux-gnueabihf-gcc" "-E" "/Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/12101760709934291851detect_compiler_family.c" with args arm-linux-gnueabihf-gcc did not execute successfully (status code exit status: 1).
  cargo:warning=arm-linux-gnueabihf-gcc: error trying to exec 'cc1': execvp: No such file or directory

  --- stderr
  running "perl" "//Users/andrew/workspace/ring/crypto/fipsmodule/aes/asm/bsaes-armv7.pl" "linux32" "//Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/bsaes-armv7-linux32.S"
  running "perl" "//Users/andrew/workspace/ring/crypto/fipsmodule/aes/asm/vpaes-armv7.pl" "linux32" "//Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/vpaes-armv7-linux32.S"
  running "perl" "//Users/andrew/workspace/ring/crypto/fipsmodule/bn/asm/armv4-mont.pl" "linux32" "//Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/armv4-mont-linux32.S"
  running "perl" "//Users/andrew/workspace/ring/crypto/chacha/asm/chacha-armv4.pl" "linux32" "//Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/chacha-armv4-linux32.S"
  running "perl" "//Users/andrew/workspace/ring/crypto/fipsmodule/modes/asm/ghash-armv4.pl" "linux32" "//Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/ghash-armv4-linux32.S"
  running "perl" "//Users/andrew/workspace/ring/crypto/fipsmodule/sha/asm/sha256-armv4.pl" "linux32" "//Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/sha256-armv4-linux32.S"
  running "perl" "//Users/andrew/workspace/ring/crypto/fipsmodule/sha/asm/sha512-armv4.pl" "linux32" "//Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/sha512-armv4-linux32.S"

  error occurred: Command "arm-linux-gnueabihf-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-march=armv7-a" "-mfpu=vfpv3-d16" "-I" "/Users/andrew/workspace/ring/include" "-I" "/Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/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" "-Werror" "-o" "/Users/andrew/workspace/ring/target/armv7-unknown-linux-gnueabihf/debug/build/ring-cfb68fda08c00de3/out/636860174c5f2fc2-curve25519.o" "-c" "/Users/andrew/workspace/ring/crypto/curve25519/curve25519.c" with args arm-linux-gnueabihf-gcc did not execute successfully (status code exit status: 1).

So, I'll try and investigate that.

andrewdavidmackenzie commented 27 minutes ago

An update. By fixing errors of mine with my linker specification - I now have building for armv7 and aarch64 working on Linux (and hence in GH Actions). Errors remain when trying that locally on macos, but of lower priority.

I will close this issue, investigate more on mac, and possibly open a new issue if required.