nelhage / llama

Apache License 2.0
584 stars 24 forks source link

Include system headers in dependency list for preprocessing #23

Closed nvartolomei closed 3 years ago

nvartolomei commented 3 years ago

Currently system and transitive headers are excluded: https://github.com/nelhage/llama/blob/5228c1e713a28831c35d3b96d8833b0c83531b35/cmd/llamacc/dependencies.go#L47

I'm trying to build https://github.com/clickhouse/clickhouse and it uses -isystem includes extensively for dependencies. Almost all dependencies are vendored in contrib/ with an option to fallback to system provided library.

It seems that -isystem include is also used to hide some warnings from dependencies as the project is configured with aggressive warnings.

What do you think about changing -MM to -M and provide an option (maybe enabled by default) to exclude transferring includes outside of project root (what would this be?).

nelhage commented 3 years ago

Oof, yeah, I fretted over this when I wrote -MM and then didn't find a super clean solution and deferred it.

I think the best answer here might be to use -M, and then to exclude everything inside the default search path, as determined by $CC -Wp,-v -xc -E -o/dev/null /dev/null. Ideally we'd cache that result somewhere, though, since I don't want to add another compiler invocation to every build. We could add a dedicated RPC to the daemon, I suppose.

Does that seem likely to work?