Closed Bug 1526857 Opened 10 months ago Closed 6 months ago

Improve bindgen configuration wrt clang


(Firefox Build System :: General, enhancement)

Not set


(firefox69 fixed)

Tracking Status
firefox69 --- fixed


(Reporter: glandium, Assigned: glandium)




(1 file)

Historically, the bindgen configuration has been using a compiler that is not the build compiler (gcc or msvc), and does its own detection for clang. However, now that clang/clang-cl is the default, it can end up using a different version as shown in bug 1526497. The situation should be improved.

Duplicate of this bug: 1544815
Blocks: 1487552

The current setup for bindgen relies on either finding clang/libclang
from the output of llvm-config, or from the paths given via the
configure flags --with-clang-path/--with-libclang-path.

One very common problem is that the llvm-config we end up using does
not correspond to the clang used for compilation, which has some
undesirable side effect, like failing to build.

So instead of relying on llvm-config, we do the following:

  • when the compiler is clang, we just use that
  • when the compiler is clang-cl, we use clang from the same directory
  • otherwise, we either try to find clang in PATH, or rely on

Once clang is found, we try to deduce the location of the corresponding
libclang via the output of clang -print-search-dirs, or rely on

Can we get this reviewed?

Pushed by
Improve bindgen configuration wrt clang. r=chmanchester
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla69

I can't build anymore. Somehow this causes
ERROR: Could not find libclang to generate rust bindings for C/C++. Please install the necessary packages, run mach bootstrap, or use --with-libclang-path to give the path containing it.

And running ./mach bootstrap does not help.

Regressions: 1557030

This make by mac build succeed, thanks!

See Also: → 1495672
Duplicate of this bug: 1553336
You need to log in before you can comment on or make changes to this bug.