-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[build.ps1] Set the default architecture using an environment variable #104474
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ Param( | |
[switch]$coverage, | ||
[string]$testscope, | ||
[switch]$testnobuild, | ||
[ValidateSet("x86","x64","arm","arm64","wasm")][string[]][Alias('a')]$arch = @([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()), | ||
[ValidateSet("x86","x64","arm","arm64","wasm")][string[]][Alias('a')]$arch, | ||
[switch]$cross = $false, | ||
[string][Alias('s')]$subset, | ||
[ValidateSet("Debug","Release","Checked")][string][Alias('rc')]$runtimeConfiguration, | ||
|
@@ -27,11 +27,19 @@ Param( | |
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties | ||
) | ||
|
||
function Get-Default-Arch() { | ||
if ($env:DOTNET_RUNTIME_DEFAULT_ARCH) { | ||
eiriktsarpalis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return $env:DOTNET_RUNTIME_DEFAULT_ARCH | ||
eiriktsarpalis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant() | ||
} | ||
|
||
function Get-Help() { | ||
Write-Host "Common settings:" | ||
Write-Host " -arch (-a) Target platform: x86, x64, arm, arm64, or wasm." | ||
Write-Host " Pass a comma-separated list to build for multiple architectures." | ||
Write-Host (" [Default: {0} (Depends on your console's architecture.)]" -f [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()) | ||
Write-Host (" [Default: {0} (Depends on your console's architecture or the DOTNET_RUNTIME_DEFAULT_ARCH environment variable.)]" -f @(Get-Default-Arch)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This covers for the top level There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The peculiarity of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Windows Arm does have native builds for Powershell, however I'm using mingw which only has x64 builds at the moment. A similar issue with SSH connections to Windows arm devices. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to workaround the problem by changing the path in your mingw environment to point to native powershell? It would cover this and all other powershell.exe invocations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That folder doesn't exist on ARM builds. Similar to powershell.exe it's the same executable that adapts depending on the parent architecture:
I understand that this is the case, however like I said this does create problems in the workflows for those that do rely on tools that aren't arm64 native yet. While creating a wrapper script does technically resolve the issue, the dev loop workflow largely relies on muscle memory: I work on x64 and arm64 machines interchangeably so even with the workaround I have to explicitly remember that the current machine is arm64 to make sure the right script/arch parameter is being used. If I don't, I will have lost > 5 minutes waiting on a build that was targeting the wrong architecture. This has been happening frequently enough to me for it to be a problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's surprising. It has been a virtual folder that only exists on non-native contexts. It has been the escape hatch to get back to native context. For example, this is how you can relaunch native x64 cmd from the emulated x86 cmd on Windows x64:
Is it really the case that these same steps do not work in emulated x64 cmd on Windows arm64? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming there existed a build of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. I have done some reading on this topic. The system .exes are multi-arch on Windows Arm, and so there is no way to control the system process architecture by selecting different .exes. Instead, the process launching the .exe controls the process architecture. For example, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, the #!/usr/bin/env bash
start //b //wait //machine arm64 powershell.exe "$@" I'm able to force native powershell process from the mingw environment. This solves the problem using
eiriktsarpalis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Write-Host " -binaryLog (-bl) Output binary log." | ||
Write-Host " -configuration (-c) Build configuration: Debug, Release or Checked." | ||
Write-Host " Checked is exclusive to the CLR subset. It is the same as Debug, except code is" | ||
|
@@ -143,6 +151,10 @@ if ($subset -eq 'help') { | |
exit 0 | ||
} | ||
|
||
if (-not $arch) { | ||
$arch = Get-Default-Arch | ||
} | ||
|
||
# Lower-case the passed in OS string. | ||
if ($os) { | ||
$os = $os.ToLowerInvariant() | ||
|
Uh oh!
There was an error while loading. Please reload this page.