Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vsts-ci/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ phases:
matrix:
Linux ARM Native:
buildName: ubuntu.16.04
Linux ARM64 Native:
buildName: ubuntu.16.04
Linux Native:
buildName: centos.7
Linux Alpine:
Expand Down
2 changes: 1 addition & 1 deletion .vsts-ci/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ phases:
condition: succeeded()
- powershell: |
Invoke-WebRequest "https://aka.ms/vs/15/release/vs_BuildTools.exe" -OutFile vs_BuildTools.exe -UseBasicParsing
Start-Process -FilePath 'vs_BuildTools.exe' -ArgumentList '--quiet', '--norestart', '--locale en-US', '--add Microsoft.VisualStudio.Component.VC.Tools.ARM', '--add Microsoft.VisualStudio.Component.VC.Tools.ARM64', '--includeRecommended', '--add Microsoft.VisualStudio.Workload.VCTools', '--add Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop.arm', '--add Microsoft.VisualStudio.Component.VC.ATL', '--add Microsoft.VisualStudio.Component.VC.ATLMFC', '--add Microsoft.VisualStudio.Component.VC.ATL.ARM', '--add Microsoft.VisualStudio.Component.VC.ATL.ARM64' -Wait
Start-Process -FilePath 'vs_BuildTools.exe' -ArgumentList '--quiet', '--norestart', '--locale en-US', '--add Microsoft.VisualStudio.Component.VC.Tools.ARM', '--add Microsoft.VisualStudio.Component.VC.Tools.ARM64', '--includeRecommended', '--add Microsoft.VisualStudio.Workload.VCTools', '--add Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop.arm', '--add Microsoft.VisualStudio.Component.VC.ATL.Spectre', '--add Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre', '--add Microsoft.VisualStudio.Component.VC.ATL.ARM.Spectre', '--add Microsoft.VisualStudio.Component.VC.ATL.ARM64.Spectre', '--add Microsoft.VisualStudio.Component.VC.Runtimes.ARM.Spectre', '--add Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre', '--add Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre' -Wait
Remove-Item .\vs_BuildTools.exe
Remove-Item -Force -Recurse 'C:\Program Files (x86)\Microsoft Visual Studio\Installer'
$vsPath = ${Env:ProgramFiles(x86)} + '\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin'
Expand Down
32 changes: 25 additions & 7 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -392,16 +392,17 @@ cmd.exe /C cd /d "$location" "&" "$vcvarsallbatPath" "$Arch" "&" "$cmakePath" "$

function Start-BuildNativeUnixBinaries {
param (
[switch] $BuildLinuxArm
[switch] $BuildLinuxArm,
[switch] $BuildLinuxArm64
)

if (-not $Environment.IsLinux -and -not $Environment.IsMacOS) {
Write-Warning -Message "'Start-BuildNativeUnixBinaries' is only supported on Linux/macOS platforms"
return
}

if ($BuildLinuxArm -and -not $Environment.IsUbuntu) {
throw "Cross compiling for linux-arm is only supported on Ubuntu environment"
if (($BuildLinuxArm -or $BuildLinuxArm64) -and -not $Environment.IsUbuntu) {
throw "Cross compiling for linux-arm/linux-arm64 are only supported on Ubuntu environment"
}

# Verify we have all tools in place to do the build
Expand All @@ -414,6 +415,10 @@ function Start-BuildNativeUnixBinaries {
foreach ($Dependency in 'arm-linux-gnueabihf-gcc', 'arm-linux-gnueabihf-g++') {
$precheck = $precheck -and (precheck $Dependency "Build dependency '$Dependency' not found. Run 'Start-PSBootstrap'.")
}
} elseif ($BuildLinuxArm64) {
foreach ($Dependency in 'aarch64-linux-gnu-gcc', 'aarch64-linux-gnu-g++') {
$precheck = $precheck -and (precheck $Dependency "Build dependency '$Dependency' not found. Run 'Start-PSBootstrap'.")
}
}

# Abort if any precheck failed
Expand All @@ -440,6 +445,10 @@ function Start-BuildNativeUnixBinaries {
Start-NativeExecution { cmake -DCMAKE_TOOLCHAIN_FILE="./arm.toolchain.cmake" . }
Start-NativeExecution { make -j }
}
elseif ($BuildLinuxArm64) {
Start-NativeExecution { cmake -DCMAKE_TOOLCHAIN_FILE="./arm64.toolchain.cmake" . }
Start-NativeExecution { make -j }
}
else {
Start-NativeExecution { cmake -DCMAKE_BUILD_TYPE=Debug . }
Start-NativeExecution { make -j }
Expand Down Expand Up @@ -621,6 +630,7 @@ function PlaceUnixBinaries

$RuntimePathLinux = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-x64/native') -Force
$RuntimePathLinuxARM = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-arm/native') -Force
$RuntimePathLinuxARM64 = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-arm64/native') -Force
$RuntimePathLinuxAlpine = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-musl-x64/native') -Force
$RuntimePathOSX = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/osx/native') -Force

Expand Down Expand Up @@ -738,6 +748,7 @@ function Start-PSBuild {
"osx-x64",
"linux-x64",
"linux-arm",
"linux-arm64",
"win-arm",
"win-arm64")]
[string]$Runtime,
Expand All @@ -752,8 +763,8 @@ function Start-PSBuild {
[string]$ReleaseTag
)

if ($Runtime -eq "linux-arm" -and -not $Environment.IsUbuntu) {
throw "Cross compiling for linux-arm is only supported on Ubuntu environment"
if (($Runtime -eq "linux-arm" -or $Runtime -eq "linux-arm64") -and -not $Environment.IsUbuntu) {
throw "Cross compiling for linux-arm/linux-arm64 are only supported on Ubuntu environment"
}

if ("win-arm","win-arm64" -contains $Runtime -and -not $Environment.IsWindows) {
Expand Down Expand Up @@ -1050,6 +1061,7 @@ function New-PSOptions {
"osx-x64",
"linux-x64",
"linux-arm",
"linux-arm64",
"win-arm",
"win-arm64")]
[string]$Runtime,
Expand Down Expand Up @@ -1873,6 +1885,7 @@ function Start-PSBootstrap {
[switch]$NoSudo,
[switch]$BuildWindowsNative,
[switch]$BuildLinuxArm,
[switch]$BuildLinuxArm64,
[switch]$Force
)

Expand All @@ -1896,8 +1909,8 @@ function Start-PSBootstrap {
Pop-Location
}

if ($BuildLinuxArm -and -not $Environment.IsUbuntu) {
Write-Error "Cross compiling for linux-arm is only supported on Ubuntu environment"
if (($BuildLinuxArm -or $BuildLinuxArm64) -and -not $Environment.IsUbuntu) {
Write-Error "Cross compiling for linux-arm/linux-arm64 are only supported on Ubuntu environment"
return
}

Expand All @@ -1909,6 +1922,8 @@ function Start-PSBootstrap {

if ($BuildLinuxArm) {
$Deps += "gcc-arm-linux-gnueabihf", "g++-arm-linux-gnueabihf"
} elseif ($BuildLinuxArm64) {
$Deps += "gcc-aarch64-linux-gnu", "g++-aarch64-linux-gnu"
}

# .NET Core required runtime libraries
Expand Down Expand Up @@ -2483,6 +2498,7 @@ function Start-CrossGen {
"osx-x64",
"linux-x64",
"linux-arm",
"linux-arm64",
"win-arm",
"win-arm64")]
[string]
Expand Down Expand Up @@ -2545,6 +2561,8 @@ function Start-CrossGen {
}
} elseif ($Runtime -eq "linux-arm") {
throw "crossgen is not available for 'linux-arm'"
} elseif ($Runtime -eq "linux-arm64") {
throw "crossgen is not available for 'linux-arm64'"
} elseif ($Environment.IsLinux) {
"linux-x64"
} elseif ($Environment.IsMacOS) {
Expand Down
17 changes: 17 additions & 0 deletions src/libpsl-native/arm64.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++ -fstack-protector-strong -fpie -DFORTIFY_SOURCE=2 -O2)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,relro,-z,now")
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)

add_compile_options(-g)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
13 changes: 12 additions & 1 deletion tools/releaseBuild/PowershellNative.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
param (

[Parameter(Mandatory, ParameterSetName = 'Build')]
[ValidateSet('x64', 'x86', 'x64_arm', 'x64_arm64', 'linux-x64', 'osx', 'linux-arm', 'linux-musl-x64')]
[ValidateSet('x64', 'x86', 'x64_arm', 'x64_arm64', 'linux-x64', 'osx', 'linux-arm', 'linux-arm64', 'linux-musl-x64')]
[string]
$Arch,

Expand Down Expand Up @@ -62,6 +62,17 @@ end {
Write-Verbose -Verbose "Skipping artifact upload since this is a PR."
}
}
elseif ($Arch -eq 'linux-arm64') {
Start-PSBootstrap -BuildLinuxArm64
Start-BuildNativeUnixBinaries -BuildLinuxArm64

if ($env:BUILD_REASON -ne 'PullRequest') {
$buildOutputPath = Join-Path $RepoRoot "src/powershell-unix"
Compress-Archive -Path $buildOutputPath/libpsl-native.* -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
} else {
Write-Verbose -Verbose "Skipping artifact upload since this is a PR."
}
}
else {
Write-Verbose "Starting Start-PSBootstrap" -Verbose
Start-PSBootstrap -BuildWindowsNative
Expand Down
12 changes: 12 additions & 0 deletions tools/releaseBuild/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@
"BinaryBucket": "release",
"EnableFeature": [ "ArtifactAsFolder" ]
},
{
"Name": "ubuntu.16.04",
"RepoDestinationPath": "/PowerShellNative",
"BuildCommand": "/PowerShellNative/tools/releaseBuild/PowershellNative.ps1 -RepoRoot _RepoDestinationPath_ -TargetLocation _DockerVolume_ -Arch linux-arm64 -Configuration Release",
"AdditionalContextFiles": [
"./tools/releaseBuild/PowershellNative.ps1"
],
"DockerFile": "./tools/releaseBuild/images/Ubuntu16.04/Dockerfile",
"DockerImageName": "ps-ubunutu-16-04",
"BinaryBucket": "release",
"EnableFeature": [ "ArtifactAsFolder" ]
},
{
"Name": "centos.7",
"RepoDestinationPath": "/PowerShellNative",
Expand Down