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

Add a command-line option to set the default build type. #1231

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

teo-tsirpanis
Copy link

As part of fixing microsoft/vcpkg#1626, this PR introduces the --x-build-type setting to the vcpkg install command. When this setting is specified with a value of release, or debug, it sets the VCPKG_DEFAULT_BUILD_TYPE variable to the CMake script invocation that builds a port.

The port.cmake file at microsoft/vcpkg will use this variable to initialize VCPKG_BUILD_TYPE, enabling building dependencies in only Release or Debug mode without writing a custom triplet, addressing a long-standing usability issue of vcpkg. For compatibility, if the triplet file sets VCPKG_BUILD_TYPE itself, it prevails over --x-build-type.

If --x-build-type is specified, its value becomes part of the ABI hash. The setting is available only when installing in manifest mode; it would be weird to support it in classic mode, where packages of varied build configurations would coexist under the same triplet.

@BillyONeal
Copy link
Member

BillyONeal commented Oct 13, 2023

This is a triplet setting because, in general, the whole universe needs to agree on the value.

vcpkg install zlib --x-build-type release
vcpkg install curl

will fail, because debug curl is going to need debug zlib, and as far as vcpkg is concerned, debug zlib is installed.

Given that this is a setting the whole world needs to agree on, the right place for it to go is the triplet.

As a result I am weakly against this change. I could see an argument for some sort of system that lets common triplet combos be set by the user directly in manifest mode, but that would still be a different triplet, not a specific command line escape hatch for one particular triplet setting.

@teo-tsirpanis
Copy link
Author

the whole universe needs to agree on the value

That's why --x-build-type works only when installing in manifest mode. The whole universe inside vcpkg_installed agrees, doesn't it?

@Neumann-A
Copy link
Contributor

I am also against it. Furthermore debug only builds are mostly broken by design.

@BillyONeal
Copy link
Member

That's why --x-build-type works only when installing in manifest mode. The whole universe inside vcpkg_installed agrees, doesn't it?

Yes, but why is VCPKG_BUILD_TYPE special among all possible triplet settings?

I could see an argument for some sort of system that lets common triplet combos be set by the user directly in manifest mode

@Thomas1664
Copy link
Contributor

I'm also against this change. This belongs in the triplet file.

@autoantwort
Copy link
Contributor

autoantwort commented Oct 14, 2023

Given that this is a setting the whole world needs to agree on, the right place for it to go is the triplet.

I mean with per port customization you can also do the same with a triplet file 😄

Imho it would be nice to have something like a "dynamic triplet" that derives the content of the triplet file from the triplet name, then you also don't need to pollute the triplet folder of the vcpkg repo (edit: or the overlay triplet folder) with all possible combinations of triplets.

@dg0yt
Copy link
Contributor

dg0yt commented Oct 14, 2023

Imho it would be nice to have something like a "dynamic triplet" that derives the content of the triplet file from the triplet name, then you also don't need to pollute the triplet folder of the vcpkg repo with all possible combinations of triplets.

... if we could transform all inputs into an ABI hashing input...

@autoantwort
Copy link
Contributor

... if we could transform all inputs into an ABI hashing input...

Sounds like this could be a problem? The only challenge could be to get the same triplet abi as for the file based triplets.

@Neumann-A
Copy link
Contributor

Imho it would be nice to have something like a "dynamic triplet" that derives the content of the triplet file from the triplet name,

you could write such a triplet already. Just include a file with the logic in the triplet instead of copying the code all over the triplets

then you also don't need to pollute the triplet folder ...

That feature is called overlay triplets is it not ?

@dg0yt
Copy link
Contributor

dg0yt commented Oct 14, 2023

... if we could transform all inputs into an ABI hashing input...

Sounds like this could be a problem? The only challenge could be to get the same triplet abi as for the file based triplets.

The first challenge is to not get the same ABI hash for all filenames of the dynamic triplet.
#816 would help...

@autoantwort
Copy link
Contributor

The first challenge is to not get the same ABI hash for all filenames of the dynamic triplet.

It depends how you implement it. But if you generate a file you could simply add a comment to the file and get a different file hash <=> triplet abi.

@teo-tsirpanis
Copy link
Author

teo-tsirpanis commented Oct 19, 2023

why is VCPKG_BUILD_TYPE special among all possible triplet settings?

@BillyONeal of the options listed in https://learn.microsoft.com/en-us/vcpkg/users/triplets, VCPKG_BUILD_TYPE is most likely to vary depending on the circumstances of your build instead of the actual target platform. You don't commonly switch between static or dynamic linkage of the dependencies or the CRT when targeting the same platform, but switching between Release and Debug mode is more commonplace for development versus CI/deployment scenarios. Sure vcpkg aggressively caches its binaries but that's not always possible.

Having to choose between either double the build times to build binaries we won't need, or duplicating our triplet files to have only one line added and forgoing relying on vcpkg's automatic platform detection (our custom triplets have the same name as the default ones) is a current deficiency of vcpkg that I would like to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants