`preprocessor_flags` vs. `compiler_flags`
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
Why is there a distinction in the `cxx_library()` API between preprocessor flags and compiler flags? I assumed that maybe by putting something in `preprocessor_flags`, buck2 would automatically prepend `-D`, but it turns out it doesn't do that. It still just merges it with compiler flags as if they're identical.
When I think of preprocessor flags, I think of `-D` and `-U`, and not much else . But since it's just treating anything you put here as a regular command line argument, you could hypothetically put anything here. You could put `-O3` here and it would "work", for example. Where do I make the distinction? Is an include path a preprocessor flag? What about [/Zc:preprocessor](https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170) using MSVC? Ultimately, my question boils down to why does buck2 _care_ about this distinction in the first place? A flag is a flag.
I did observe that there is an `exported_preprocessor_flags` but no analogous `exported_compiler_flags`. Why is this? For example, our application builds using libc++ (not libstdc++), and we build using C++17. So `--stdlib=libc++` and `--std=c++17` are flags we would like to pass unconditionally to every cpp file in our codebase. If there were an `exported_compiler_flags` attribute this would be easy, but since there's not, the only workaround I can think of is to make a `my_cxx_library()` wrapper rule.
Mostly curious about the design rationale behind these topics.
Contributor guide
Assessment
This issue has not been assessed yet.