Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

compnerd
Copy link
Member

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.

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.
Comment on lines +1279 to +1282
$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")
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Member Author

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.

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

Successfully merging this pull request may close these issues.

2 participants