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

Multiple build configurations? #142

Open
stolyaroleh opened this issue Apr 11, 2023 · 3 comments
Open

Multiple build configurations? #142

stolyaroleh opened this issue Apr 11, 2023 · 3 comments

Comments

@stolyaroleh
Copy link
Contributor

stolyaroleh commented Apr 11, 2023

I want to try buck2 in a C++ project, and I want to be able to:

  • use different compilers (gcc/clang)
  • use different build configurations (release/debug/sanitizers)

What's the suggested way to implement this? Multiple toolchains? How does cxx_library or cxx_binary know what toolchain to use?
How would command line look like? Is something like buck2 test //... --debug --asan and buck2 run //:main --release --gcc possible?

I found this page about configurations, and it seems like one should be able to select() things based on config values. Do I write a single toolchain that is parameterized by config values instead? buck2 build -c cpp.compiler=gcc -c cpp.debug=true //...?

I also found this RFC: https://buck2.build/docs/rfcs/drafts/configuration-at-syntax/, but it doesn't specify how to structure the project in order to make buck2 build //foo:bar@release+gcc possible.

@ndmitchell
Copy link
Contributor

There is a single toolchain toolchains//:cxx that is used for all C++ compilations. You can. use either selects or .buckconfig to change what it points at. You could make the toolchains//:cxx an alias with a select statement, or you could call read_config to grab the config and populate the fields from there. Internally we use a select for the outer structure and then read_config for the inner details - but that's not necessarily the recommended approach, where select only would be advised. I'm just not sure if we have all the pieces set up to support that - e.g. the configuration RFC. CC @stepancheg who might know.

@themarwhal
Copy link
Contributor

We have an example where we create a toolchain alias with select that might be of interest to you.

@stolyaroleh
Copy link
Contributor Author

Thanks, this looks very helpful.
Great podcast episode, by the way :)

facebook-github-bot pushed a commit that referenced this issue Jul 17, 2024
Summary: Pull Request resolved: facebookincubator/fizz#142

Reviewed By: namanahuja

Differential Revision: D59832580

Pulled By: ahornby

fbshipit-source-id: 1b936a007e5d08f7bc959d5775bce36b107f4bb3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants