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

Current main fails to compile aws-lc-sys #1788

Closed
1 task done
mouse07410 opened this issue Feb 13, 2024 · 18 comments
Closed
1 task done

Current main fails to compile aws-lc-sys #1788

mouse07410 opened this issue Feb 13, 2024 · 18 comments

Comments

@mouse07410
Copy link

mouse07410 commented Feb 13, 2024

Checklist

  • I've searched the issue tracker for similar bugs.

Describe the bug

Unable to generate bindings.: ClangDiagnostic("/Users/ur20980/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.13.0/aws-lc/include/openssl/err.h:112:10: fatal error: 'stdio.h' file not found\n")

To Reproduce
Steps to reproduce the behavior:

  1. Clone this repo git clone --recurse-submodules https://github.com/rustls/rustls.git
  2. cd rustls
  3. Do cargo test --release
  4. Observe the error:
$ git clone --recurse-submodules https://github.com/rustls/rustls.git
Cloning into 'rustls'...
remote: Enumerating objects: 26917, done.
remote: Counting objects: 100% (4049/4049), done.
remote: Compressing objects: 100% (1112/1112), done.
remote: Total 26917 (delta 3270), reused 3122 (delta 2912), pack-reused 22868
Receiving objects: 100% (26917/26917), 10.23 MiB | 2.53 MiB/s, done.
Resolving deltas: 100% (18838/18838), done.
$ cd rustls
$ cargo test --release; date                                         
   Compiling libc v0.2.153
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling glob v0.3.1
   Compiling rustix v0.38.31
   Compiling prettyplease v0.2.16
   Compiling memchr v2.7.1
   Compiling regex-syntax v0.8.2
   Compiling minimal-lexical v0.2.1
   Compiling either v1.10.0
   Compiling cfg-if v1.0.0
   Compiling bitflags v2.4.2
   Compiling libloading v0.8.1
   Compiling bindgen v0.69.4
   Compiling home v0.5.9
   Compiling itertools v0.12.1
   Compiling lazy_static v1.4.0
   Compiling rustc-hash v1.1.0
   Compiling nom v7.1.3
   Compiling clang-sys v1.7.0
   Compiling lazycell v1.3.0
   Compiling shlex v1.3.0
   Compiling log v0.4.20
   Compiling dunce v1.0.4
   Compiling fs_extra v1.3.0
   Compiling paste v1.0.14
   Compiling aho-corasick v1.1.2
   Compiling regex-automata v0.4.5
   Compiling aws-lc-rs v1.6.1
   Compiling untrusted v0.9.0
   Compiling cexpr v0.6.0
   Compiling rustls-pki-types v1.2.0
   Compiling mirai-annotations v1.12.0
   Compiling zeroize v1.7.0
   Compiling base64 v0.21.7
   Compiling rustls v0.23.0-alpha.0 (/Users/ur20980/src/rustls/rustls)
   Compiling once_cell v1.19.0
   Compiling regex v1.10.3
   Compiling is-terminal v0.4.12
   Compiling subtle v2.5.0
   Compiling termcolor v1.4.1
   Compiling humantime v2.1.0
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling rustls-pemfile v2.0.0
   Compiling webpki-roots v0.26.1
   Compiling autocfg v1.1.0
   Compiling powerfmt v0.2.0
   Compiling bencher v0.1.5
   Compiling deranged v0.3.11
   Compiling num-traits v0.2.18
   Compiling num-bigint v0.4.4
   Compiling time-core v0.1.2
   Compiling cc v1.0.83
   Compiling errno v0.3.8
   Compiling num-conv v0.1.0
   Compiling serde v1.0.196
   Compiling cmake v0.1.50
   Compiling time v0.3.34
   Compiling which v4.4.2
   Compiling getrandom v0.2.12
   Compiling ring v0.17.7
   Compiling spin v0.9.8
   Compiling yasna v0.5.2
   Compiling pem v3.0.3
   Compiling socket2 v0.5.5
   Compiling env_logger v0.10.2
   Compiling num-integer v0.1.46
   Compiling mio v0.8.10
   Compiling pin-project-lite v0.2.13
   Compiling strsim v0.10.0
   Compiling bytes v1.5.0
   Compiling serde_derive v1.0.196
   Compiling tokio-macros v2.2.0
   Compiling tokio v1.36.0
   Compiling aws-lc-sys v0.13.0
   Compiling rcgen v0.12.1
error: failed to run custom build command for `aws-lc-sys v0.13.0`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/Users/ur20980/src/rustls/target/release/build/aws-lc-sys-de27243413207beb/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=use_bindgen_generated

  --- stderr
  /Users/ur20980/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.13.0/aws-lc/include/openssl/err.h:112:10: fatal error: 'stdio.h' file not found
  thread 'main' panicked at /Users/ur20980/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.13.0/builder/bindgen.rs:151:10:
  Unable to generate bindings.: ClangDiagnostic("/Users/ur20980/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.13.0/aws-lc/include/openssl/err.h:112:10: fatal error: 'stdio.h' file not found\n")
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
     1: core::panicking::panic_fmt
               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
     2: core::result::unwrap_failed
               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
     3: core::result::Result<T,E>::expect
     4: build_script_main::bindgen::generate_bindings
     5: build_script_main::generate_bindings
     6: build_script_main::main
     7: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
Tue Feb 13 16:35:59 EST 2024
$

Applicable Version(s)
Current main. A few days ago it compiled OK and passed the tests.

Expected behavior
Successful compilation, and passing of all the tests.

Additional context

  • Apple Silicon M2, MacOS Sonoma 14.3.1.
  • Xcode-15.2.
  • Cargo 1.76.0, Rust-1.76.0.
  • bindgen 0.69.4.

Update

  1. Works correctly on Intel-based Mac (same versions of everything).
  2. https://github.com/aws/aws-lc.git installs OK and passes all the tests on Apple Silicon - so the problem seems to be with aws-lc-rs and/or aws-lc-sys crates:
$ build/crypto/crypto_test
.  .  .
[----------] Global test environment tear-down
[==========] 1780 tests from 111 test suites ran. (20971 ms total)
[  PASSED  ] 1780 tests.

  YOU HAVE 3 DISABLED TESTS
@djc
Copy link
Member

djc commented Feb 14, 2024

Current main. A few days ago it compiled OK and passed the tests.

The rustls default was switched from ring to aws-lc-rs recently (in #1780) which might be why you're seeing this now? The ring crypto provider is still provided so it should be easy to switch back using Cargo features.

On my M1 Max, I can build 3179b92 with cargo build --release in the rustls directory of the repo, with the same compiler toolchain.

@ctz
Copy link
Member

ctz commented Feb 14, 2024

I think it might be more fruitful to report this at https://github.com/aws/aws-lc-rs

There is also similar reports in the bindgen repo rust-lang/rust-bindgen#2401

@mouse07410
Copy link
Author

I think it might be more fruitful to report this at https://github.com/aws/aws-lc-rs

Reported - but it looks like some parameters for the aws-lc-rs as a dependency build would need to go into this project's Cargo.toml.

@cpu
Copy link
Member

cpu commented Feb 15, 2024

it looks like some parameters for the aws-lc-rs as a dependency build would need to go into this project's Cargo.toml.

I believe the suggestion in the aws-lc-rs thread was for you to take a direct dependency on aws-lc-rs and add the required feature flag. This will activate it for Rustls' copy of the dependency as well.

Have you tried that approach?

@justsmth
Copy link

justsmth commented Feb 15, 2024

@mouse07410 found a way to reproduce the problem directly using bindgen: rust-lang/rust-bindgen#2401 (comment)

@mouse07410
Copy link
Author

mouse07410 commented Feb 15, 2024

it looks like some parameters for the aws-lc-rs as a dependency build would need to go into this project's Cargo.toml.

I believe the suggestion in the aws-lc-rs thread was for you to take a direct dependency on aws-lc-rs and add the required feature flag. This will activate it for Rustls' copy of the dependency as well.

Have you tried that approach?

I don't understand how to do that, given that I don't build aws-lc-rs separately, and that's it's a library that I cannot actually install.

Also, given that bindgen was demonstrated to fail, it is unclear whether adding "bindgen" feature could remedy the problem (though first - somebody has to tell me how to add that feature).

@cpu
Copy link
Member

cpu commented Feb 15, 2024

I don't understand how to do that, given that I don't build aws-lc-rs separately, and that's it's a library that I cannot actually install.

Ah I see, you're building Rustls but not actually consuming it as a dependency in a Rust project of your own? Is that an accurate summary?

@mouse07410
Copy link
Author

Ah I see, you're building Rustls but not actually consuming it as a dependency in a Rust project of your own? Is that an accurate summary?

For now - yes it is.

@djc
Copy link
Member

djc commented Feb 15, 2024

@mouse07410 what are you actually building? Is it a Rust project that somehow includes rustls (and thus aws-lc-rs) in its transitive dependency graph? If so, you can add a direct dependency on aws-lc-rs with the bindgen feature and that should make it work. If not, what is it that you're trying to do?

@mouse07410
Copy link
Author

what is it that you're trying to do?

First, right now I'm preparing for getting rustls into a project. There are several moving parts, including PQ crypto, so it takes time. Yes, in its more mature stage it will include rustls in its dependency graph.

Second, it would be great if somebody (you?) actually showed what the direct dependency on aws-lc-rs should look like, even though it must be obvious for many readers. I'd also like to hear why you think that specifying some feature for aws-lc-rs would help, given that independent bindgen failure was demonstrated.

@djc
Copy link
Member

djc commented Feb 15, 2024

Well, I was going off of this comment from the aws-lc-rs thread:

One possible work-around is to take a direct dependency on aws-lc-rs and enable the "bindgen" feature. This may also require the installation of libclang/llvm. Our User Guide provides basic instructions for this.

But, I think the more interesting question is why neither @justsmth nor I can reproduce this, in similar Apple Silicon environments?

@mouse07410
Copy link
Author

mouse07410 commented Feb 15, 2024

I was going off of this comment from the aws-lc-rs thread

And the User Guide they referred to indeed showed how to install libclang/llvm using HomeBrew. In other words, not very helpful, especially given that they were already installed.

Doesn't give a simple unambiguous help like

[dependencies]
.  .  .
aws-lc-rs = { version = "1.2.3", features = ["broken, bindgen, whatever" ]}
.  .  .

the more interesting question is why neither @justsmth nor I can reproduce this, in similar Apple Silicon environments?

My suspicion is - presence or absence on the system of other Clang versions (see my comments in the bindgen issue). But I can't be sure. If we all had "pristine" machines with only MacOS, Xcode, Rust-1.76.0, and rustls clone - it would've been nice and simple...

@djc
Copy link
Member

djc commented Feb 16, 2024

My suspicion is - presence or absence on the system of other Clang versions (see my comments in the bindgen issue). But I can't be sure. If we all had "pristine" machines with only MacOS, Xcode, Rust-1.76.0, and rustls clone - it would've been nice and simple...

which -a clang reports only /usr/bin/clang for me, installed on Feb 2 (same as all the other c* binaries in /usr/bin).

@mouse07410
Copy link
Author

mouse07410 commented Feb 16, 2024

Well, you have only one Clang, presumably from Xcode (or it's CommandLineTools). In my case

$ which -a clang
/opt/local/bin/clang
/usr/bin/clang
$ port installed | grep clang
  clang-17 @17.0.6_0+analyzer (active)
  clang_select @2.2_1 (active)
  gcc12-libcxx @12.3.0_4+clang17 (active)
  gcc13-libcxx @13.2.0_4+clang17 (active)
  py311-clang @10_0+clang17 (active)
$ 

and that's after I pruned (removed) other unnecessary versions of Clang that I suspected could interfere with bindgen.

Update

It is interesting to note that while my system has no "explicitly" visible LLVM, bindgen managed to locate and use header fines from /opt/local/libexec/llvm-16 (ignoring /opt/local/libexec/llvm-17, in case it matters).

$ which -a llvm
$ ll /usr/bin/llvm*
-rwxr-xr-x  76 root  wheel  168160 Feb  2 12:19 /usr/bin/llvm-g++*
-rwxr-xr-x  76 root  wheel  168160 Feb  2 12:19 /usr/bin/llvm-gcc*
$ ll /opt/local/bin/llvm*
-rwxr-xr-x  1 root  admin  192 Oct  5 12:38 /opt/local/bin/llvm-addr2line-mp-14*
-rwxr-xr-x  1 root  admin  192 Oct  5 13:06 /opt/local/bin/llvm-addr2line-mp-15*
-rwxr-xr-x  1 root  admin  192 Nov 28 18:27 /opt/local/bin/llvm-addr2line-mp-17*
-rwxr-xr-x  1 root  admin  178 Oct  5 12:38 /opt/local/bin/llvm-ar-mp-14*
-rwxr-xr-x  1 root  admin  178 Oct  5 13:06 /opt/local/bin/llvm-ar-mp-15*
-rwxr-xr-x  1 root  admin  178 Nov 28 18:27 /opt/local/bin/llvm-ar-mp-17*
-rwxr-xr-x  1 root  admin  178 Oct  5 12:38 /opt/local/bin/llvm-as-mp-14*
-rwxr-xr-x  1 root  admin  178 Oct  5 13:06 /opt/local/bin/llvm-as-mp-15*
-rwxr-xr-x  1 root  admin  178 Nov 28 18:27 /opt/local/bin/llvm-as-mp-17*
-rwxr-xr-x  1 root  admin  194 Oct  5 12:38 /opt/local/bin/llvm-bcanalyzer-mp-14*
-rwxr-xr-x  1 root  admin  194 Oct  5 13:06 /opt/local/bin/llvm-bcanalyzer-mp-15*
-rwxr-xr-x  1 root  admin  194 Nov 28 18:27 /opt/local/bin/llvm-bcanalyzer-mp-17*
-rwxr-xr-x  1 root  admin  200 Oct  5 12:38 /opt/local/bin/llvm-bitcode-strip-mp-14*
-rwxr-xr-x  1 root  admin  200 Oct  5 13:06 /opt/local/bin/llvm-bitcode-strip-mp-15*
-rwxr-xr-x  1 root  admin  200 Nov 28 18:27 /opt/local/bin/llvm-bitcode-strip-mp-17*
-rwxr-xr-x  1 root  admin  186 Oct  5 12:38 /opt/local/bin/llvm-c-test-mp-14*
.  .  .
-rwxr-xr-x  1 root  admin  188 Nov 28 18:27 /opt/local/bin/llvm-windres-mp-17*
-rwxr-xr-x  1 root  admin  182 Oct  5 12:38 /opt/local/bin/llvm-xray-mp-14*
-rwxr-xr-x  1 root  admin  182 Oct  5 13:06 /opt/local/bin/llvm-xray-mp-15*
-rwxr-xr-x  1 root  admin  182 Nov 28 18:27 /opt/local/bin/llvm-xray-mp-17*
$ 

@skmcgrail
Copy link
Contributor

@mouse07410

I believe your finding is correct that this is a MacPorts llvm-16 issue. I also use MacPorts but did not have llvm-16 version installed. I uninstalled all my clang and llvm installations from MacPorts, and then only installed clang/llvm 16. If I then force binding generation of x86-64 architecture I get the following error as well:

error: failed to run custom build command for `aws-lc-sys v0.13.2 (/workspace/aws-lc-rs/aws-lc-sys)`

Caused by:
  process didn't exit successfully: `/workspace/aws-lc-rs/target/debug/build/aws-lc-sys-e03fe402074ee5a3/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=macos_x86_64

  --- stderr
  /workspace/aws-lc-rs/aws-lc-sys/aws-lc/include/openssl/err.h:112:10: fatal error: 'stdio.h' file not found
  thread 'main' panicked at aws-lc-sys/builder/bindgen.rs:151:10:
  Unable to generate bindings.: ClangDiagnostic("/workspace/aws-lc-rs/aws-lc-sys/aws-lc/include/openssl/err.h:112:10: fatal error: 'stdio.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

So I don't think this is a specific issue to Apple M2, but more an issue with llvm-16 on MacPorts if bindgen attempts to use it.

@djc
Copy link
Member

djc commented Feb 17, 2024

Which is a little strange, since I think 1.76 is supposed to be compatible with LLVM 16?

rust-lang/rust#117947

@cpu
Copy link
Member

cpu commented Feb 27, 2024

Is there any action to take in the Rustls repo for this situation? It seems like there's consensus the problem is with tooling unrelated to Rustls itself.

@ctz ctz closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2024
@mouse07410
Copy link
Author

Is there any action to take in the Rustls repo for this situation?

I don't think so. Except, perhaps, mention in the README or such that LLVM-16 with Clang-16 are problematic.

It seems like there's consensus the problem is with tooling unrelated to Rustls itself.

I concur.

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

6 participants