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
rust-bindgen: wrap with cc-wrapper to provide location of headers #40746
Conversation
See wrapper.nix for implementation details. Note that to parse c++ headers, you must pass `-x c++` as a clang argument.
cc @Ralith as maintainer of rust-bindgen |
Why not just insert the expansion of |
This would lack glibc, but still. |
I honestly have no idea what's up with the infix salt stuff. Something to do with crosscompiling, which we probably want bindgen to support, at least in theory. |
Is cross compilation a goal ? and if so, does any of the two solutions work in this context ? |
I have no familiarity with the nix cross infrastructure, though it seems like it's been getting a lot of work lately. Maybe have a look at the commit logs for cc-wrapper to find someone to ask? I think it would be great if rust-bindgen Just Worked when the target machine differs from the host, but support for the common (non-cross) case would be a good start. I have no idea if the rust infrastructure (old or new) handles crosscompilation at all yet; @P-E-Meunier might know more about that. |
I have never tested cross-compilation. For bindgen, I think it would be cool to add a new subcommand to carnix, that would also output the libraries needed (in |
I only used |
Motivation for this change
bindgen
uses the rawlibclang
and therefore cannot find any header. This makes it nearly unusable.This commit wraps bindgen to provide the correct include flags. Reimplementing
cc-wrapper
would behard and error prone, so I tried to reuse
cc-wrapper
. The result is ugly but I think it will be more robustagainst changes in
cc-wrapper
.The idea is to make bindgen a fake clang and wrap it with cc-wrapper. Since bindgen has its own
set of flags, we wrap it to remove those extra flags, pass the pure clang flags to cc-wrapper, and
then readd the bindgen-specific flags.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)