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

bindgen does not use downloaded chromium clang #1595

Open
AuTsing opened this issue Aug 27, 2024 · 4 comments
Open

bindgen does not use downloaded chromium clang #1595

AuTsing opened this issue Aug 27, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@AuTsing
Copy link

AuTsing commented Aug 27, 2024

Since v0.95.0, a new feature #1507 has been merged.
I got some errors when compiling v8.

Error message:

  ...
  ninja: Entering directory `/home/autsing/Gits/rusty_v8/target/debug/gn_out'
  ninja: no work to do.
  cargo:rustc-link-search=native=/home/autsing/Gits/rusty_v8/target/debug/gn_out/obj/
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-changed=src/binding.hpp

  --- stderr
  thread 'main' panicked at /home/autsing/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.69.4/lib.rs:622:31:
  Unable to find libclang: "couldn't find any valid shared libraries matching: ['libclang.so', 'libclang-*.so', 'libclang.so.*', 'libclang-*.so.*'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This error occurs in v8 build.rs running build_binding.
I guess this is because bindgen denps on clang, but I haven't configured it.

My build host is WSL Ubuntu 22.04.
My build steps are as follows:

  1. Install python, curl, libglib2.0-dev.
  2. Clone rusty_v8 repo.
  3. Run command V8_FROM_SOURCE=1 cargo build -vv.

This set of steps works before v0.94.0.

Acctually, I was able to build successfully in github action.
So I think this may be caused by my environment not being configured.
At first I wanted to build for Android, I encountered a problem that the header file could not be found.
Then I tired build for x86_64-unknown-linux-gnu, I encountered the similar problem.

According to README:

The build depends on several binary tools: gn, ninja and clang. The tools will automatically be downloaded, if they are not detected in the environment.

Clang can be automatically downloaded and configured.
Maybe the new version need to configure clang?

@caineblood
Copy link

The above comment asking you to download a file is malware to steal your account; do not under any circumstances download or run it. The post needs to be removed. If you have attempted to run it please have your system cleaned and your account secured immediately.

@devsnek
Copy link
Member

devsnek commented Aug 30, 2024

I wonder if we need to set up bindgen to look in the right place for clang. Could you try temporarily setting CLANG_PATH to the downloaded clang location? (iirc it is in target/xyz/clang)

@AuTsing
Copy link
Author

AuTsing commented Sep 3, 2024

@devsnek Thanks for your answer.
I have tried setting env CLANG_PATH, but it didn't work with the same error message.

After I looked through the doc of bindgen.
I found that bindgen uses the clang installed locally(https://rust-lang.github.io/rust-bindgen/requirements.html#requirements).
I didn't install them at first, so the error message show Unable to find libclang.

And I installed clang with apt install llvm-dev libclang-dev clang.
I build x86_64-unknown-linux-gnu successfully.

Although it has been successfully compiled, I‘m confused about some issues.
The rusty_v8 will automatically download and use clang, but bindgen will not use it, bindgen will use the locally clang.
So maybe we should point out that install these requirements before we build?
Or maybe we should configure bindgen to use the clang download automatically(Actually I didn't know how to configure it, I tried different ways but it didn't work)?

@devsnek
Copy link
Member

devsnek commented Sep 3, 2024

I looked into this some more and it turns out that the clang we download from chromium does not include libclang shared libraries. I'm discussing with them whether these can be included, in which case it should be fairly trivial to set up build.rs to automatically use them instead of the system clang.

@devsnek devsnek added the bug Something isn't working label Sep 4, 2024
@devsnek devsnek changed the title Failed to build rusty_v8 since v0.95.0 bindgen does not use downloaded chromium clang Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants