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

--clang-macro-fallback interaction with -Wp,-MMD,file.d #3070

Open
ojeda opened this issue Jan 8, 2025 · 1 comment · May be fixed by #3072
Open

--clang-macro-fallback interaction with -Wp,-MMD,file.d #3070

ojeda opened this issue Jan 8, 2025 · 1 comment · May be fixed by #3072
Labels
A-macros bug rust-for-linux Issues relevant to the Rust for Linux project

Comments

@ojeda
Copy link
Contributor

ojeda commented Jan 8, 2025

--clang-macro-fallback, when asking the preprocessor to generate a dependencies file, changes behavior.

For instance, given a header that would benefit from --clang-macro-fallback, such as:

#define F(n) n
#define N F(4)

Then

bindgen x.h -- -Wp,-MMD,file.d

would generate a dependencies file like:

x.o: x.h

However, if we pass --clang-macro-fallback, e.g.

bindgen x.h --clang-macro-fallback -- -Wp,-MMD,file.d

then it generates something like:

macro_eval.o: ...abspath.../x-precompile.h ...abspath.../x.h .macro_eval.c

This was reduced from trying to use the --clang-macro-fallback feature in the Linux kernel (mailing list post including a kernel patch to test/debug the feature).

A possible workaround may be to run bindgen twice.

Cc @jbaublitz

@ojeda ojeda added A-macros bug rust-for-linux Issues relevant to the Rust for Linux project labels Jan 8, 2025
@jbaublitz jbaublitz linked a pull request Jan 8, 2025 that will close this issue
@jbaublitz
Copy link
Contributor

@ojeda Please see the linked PR that fixes this issue.

@pvdrz When you initially recommend passing all of the CFLAGS to the FallbackTranslationUnit, this is kind of what I was afraid of. It seems like we're going to have to keep an eye on this and either take an allow or deny policy with CFLAGS. Either we have to filter out the ones that are desirable or only pass forward ones we know are safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros bug rust-for-linux Issues relevant to the Rust for Linux project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants