-
Notifications
You must be signed in to change notification settings - Fork 10.5k
utils: refactor CMake invocation construction #82135
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
base: main
Are you sure you want to change the base?
Conversation
Make the flag handling more explicit for the various platforms. This prepares us to add additional SDKs in the future which require separate handling of flags.
$UseASM = $UseBuiltCompilers.Contains("ASM") -or $UseMSVCCompilers.Contains("ASM") -or $UsePinnedCompilers.Contains("ASM") | ||
$UseC = $UseBuiltCompilers.Contains("C") -or $UseMSVCCompilers.Contains("C") -or $UsePinnedCompilers.Contains("C") | ||
$UseCXX = $UseBuiltCompilers.Contains("CXX") -or $UseMSVCCompilers.Contains("CXX") -or $UsePinnedCompilers.Contains("CXX") | ||
$UseSwift = $UseBuiltCompilers.Contains("Swift") -or $UsePinnedCompilers.Contains("Swift") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth revisiting these arguments in favor of a map of a hashtable of language to compiler:
enum CompilerSource {
MSVC
Bootstrap
Built
}
[hashtable] $UseCompilers = @{}
# [...]
$UseCompilers = @{
"Swift" = [CompilerSource]::Bootstrap
"C" = [CompilerSource]::MSVC
"CXX" = [CompilerSource]::MSVC
}
if ($DebugInfo) { | ||
# Prefer `/Z7` over `/ZI` | ||
Add-FlagsDefine $Defines CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded | ||
Add-FlagsDefine $Defines CMAKE_POLICY_CMP0141 NEW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mean to use CMAKE_POLICY_DEFAULT_CMP0141
} | ||
} | ||
|
||
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER $CC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually ever use values that are not previously set here? I did a quick pass and it seems like this never happens - the only defines that are something not overridden in this function are passed with the same value as would be set here (CMAKE_SYSTEM_NAME
and CMAKE_Swift_COMPILER_TARGET
).
I am wondering if we could cache and/or have static maps with the values set for a given configuration rather than re-computing them every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do (and I have some local changes) where the value is passed in, and then augmented with the rest of the values.
I don't think that they can be fully static as we don't have great CodeView debugging with Swift.
Make the flag handling more explicit for the various platforms. This prepares us to add additional SDKs in the future which require separate handling of flags.