--clang-macro-fallback interaction with -Wp,-MMD,file.d · Issue #3070 · rust-lang/rust-bindgen (original) (raw)

--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:

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