Skip to content

Commit 1091b9f

Browse files
committed
Sync bela and update build script
1 parent fe275ff commit 1091b9f

87 files changed

Lines changed: 1120 additions & 725 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,13 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
Privexec_target: [Privexec-win64, Privexec-win32, Privexec-arm64]
24-
include:
25-
- Privexec_target: Privexec-win64
26-
short_target: win64
27-
- Privexec_target: Privexec-win32
28-
short_target: win32
29-
- Privexec_target: Privexec-arm64
30-
short_target: arm64
23+
target: [win64, arm64]
3124
steps:
32-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v5
3326
with:
3427
fetch-depth: 1
3528
- name: compile-Privexec
36-
run: pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "./build.ps1" -Target "${{ matrix.short_target }}"
29+
run: pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "./build.ps1" -Target "${{ matrix.target }}"
3730

3831
- name: Package release
3932
if: startsWith(github.ref, 'refs/tags/')

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Privexec cmake
2-
cmake_minimum_required(VERSION 3.27)
2+
cmake_minimum_required(VERSION 3.31)
33

44
project(Privexec)
55

build.ps1

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
#!/usr/bin/env pwsh
22
param(
3-
[ValidateSet("win64", "win32", "arm64")]
3+
[ValidateSet("win64", "arm64")]
44
[string]$Target = "win64"
55
)
66

7-
$TargetWithHost64s = @{
8-
"win64" = "amd64";
9-
"win32" = "amd64_x86";
10-
"arm64" = "amd64_arm64";
7+
function Get-VSWhere {
8+
$app = Get-Command -CommandType Application "vswhere" -ErrorAction SilentlyContinue
9+
if ($null -ne $app) {
10+
return $app[0].Source
11+
}
12+
$vswhere = Join-Path ${env:ProgramFiles(x86)} -ChildPath "Microsoft Visual Studio\Installer\vswhere.exe"
13+
if (Test-Path $vswhere) {
14+
return $vswhere
15+
}
16+
return $null
1117
}
1218

13-
$TargetWithHost = $TargetWithHost64s[$Target]
14-
1519
Function Invoke-BatchFile {
1620
param(
1721
[Parameter(Mandatory = $true)]
@@ -64,29 +68,50 @@ Function Execute {
6468
return $Process.ExitCode
6569
}
6670

71+
# code begin
72+
$targetTables = @{
73+
"win-x64@win64" = "amd64";
74+
"win-x64@arm64" = "amd64_arm64";
75+
"win-arm64@arm64" = "arm64";
76+
"win-arm64@win64" = "arm64_amd64";
77+
}
6778

68-
$VisualCxxBatchFiles = $(
69-
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat",
70-
"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvarsall.bat",
71-
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
72-
)
79+
$RID = [System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier # win-x64 win-arm64
80+
$vscomponent = "Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
81+
if ($Target -eq "arm64") {
82+
$vscomponent = "Microsoft.VisualStudio.Component.VC.Tools.ARM64"
83+
}
7384

74-
$VisualCxxBatchFile = $null
75-
foreach ($file in $VisualCxxBatchFiles) {
76-
if (Test-Path $file) {
77-
$VisualCxxBatchFile = $file
78-
break
79-
}
85+
$vsarch = $targetTables["$RID@$Target"]
86+
87+
$vswhere = Get-VSWhere
88+
if ($null -eq $vswhere) {
89+
Write-Host -ForegroundColor Red "No vswhere installation found"
90+
exit 1
91+
}
92+
93+
# vswhere -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
94+
$vsInstallDir = &$vswhere -latest -products * -requires $vscomponent -property installationPath
95+
if ([string]::IsNullOrEmpty($vsInstallDir)) {
96+
$vsInstallDir = &$vswhere -latest -prerelease -products * -requires $vscomponent -property installationPath
8097
}
81-
if ($null -eq $VisualCxxBatchFile) {
82-
Write-Host -ForegroundColor Red "visual c++ vcvarsall.bat not found"
98+
if ([string]::IsNullOrEmpty($vsInstallDir)) {
99+
Write-Host -ForegroundColor Red "No Visual Studio installation found."
83100
exit 1
84101
}
85102

103+
$VisualCxxBatchFile = Join-Path $vsInstallDir -ChildPath "VC\Auxiliary\Build\vcvarsall.bat"
86104

87-
Write-Host "call `"$VisualCxxBatchFile`" $TargetWithHost"
105+
Write-Host "call `"$VisualCxxBatchFile`" $vsarch"
106+
107+
Invoke-BatchFile -Path $VisualCxxBatchFile -Arguments $vsarch
108+
109+
$cmake = Get-Command -CommandType Application "cmake" -ErrorAction SilentlyContinue
110+
if ($null -ne $cmake) {
111+
$cmakeExe = $cmake[0].Source
112+
Write-Host "Use cmake $cmakeExe"
113+
}
88114

89-
Invoke-BatchFile -Path $VisualCxxBatchFile -Arguments $TargetWithHost
90115
$WD = Join-Path -Path $PWD -ChildPath "build"
91116
try {
92117
New-Item -ItemType Directory -Force -Path $WD

vendor/bela.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/fcharlie/bela/tree/f7b2f361512a2a86f9edf4c3f7a2b7cf2c83702a
1+
https://github.com/fcharlie/bela/tree/d246bf431c77418bd52995706d3babb23c597a54

vendor/bela/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# bela sources
2-
cmake_minimum_required(VERSION 3.27)
2+
cmake_minimum_required(VERSION 3.31)
33

4-
project(bela CXX C ASM)
4+
project(bela)
55

66
include(FeatureSummary)
77

vendor/bela/build.ps1

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
#!/usr/bin/env pwsh
22
param(
3-
[ValidateSet("win64", "win32", "arm64")]
3+
[ValidateSet("win64", "arm64")]
44
[string]$Target = "win64"
55
)
66

7-
$TargetWithHost64s = @{
8-
"win64" = "amd64";
9-
"win32" = "amd64_x86";
10-
"arm64" = "amd64_arm64";
7+
function Get-VSWhere {
8+
$app = Get-Command -CommandType Application "vswhere" -ErrorAction SilentlyContinue
9+
if ($null -ne $app) {
10+
return $app[0].Source
11+
}
12+
$vswhere = Join-Path ${env:ProgramFiles(x86)} -ChildPath "Microsoft Visual Studio\Installer\vswhere.exe"
13+
if (Test-Path $vswhere) {
14+
return $vswhere
15+
}
16+
return $null
1117
}
1218

13-
$TargetWithHost = $TargetWithHost64s[$Target]
14-
1519
Function Invoke-BatchFile {
1620
param(
1721
[Parameter(Mandatory = $true)]
@@ -64,29 +68,50 @@ Function Execute {
6468
return $Process.ExitCode
6569
}
6670

71+
# code begin
72+
$targetTables = @{
73+
"win-x64@win64" = "amd64";
74+
"win-x64@arm64" = "amd64_arm64";
75+
"win-arm64@arm64" = "arm64";
76+
"win-arm64@win64" = "arm64_amd64";
77+
}
6778

68-
$VisualCxxBatchFiles = $(
69-
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat",
70-
"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvarsall.bat",
71-
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
72-
)
79+
$RID = [System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier # win-x64 win-arm64
80+
$vscomponent = "Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
81+
if ($Target -eq "arm64") {
82+
$vscomponent = "Microsoft.VisualStudio.Component.VC.Tools.ARM64"
83+
}
7384

74-
$VisualCxxBatchFile = $null
75-
foreach ($file in $VisualCxxBatchFiles) {
76-
if (Test-Path $file) {
77-
$VisualCxxBatchFile = $file
78-
break
79-
}
85+
$vsarch = $targetTables["$RID@$Target"]
86+
87+
$vswhere = Get-VSWhere
88+
if ($null -eq $vswhere) {
89+
Write-Host -ForegroundColor Red "No vswhere installation found"
90+
exit 1
91+
}
92+
93+
# vswhere -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
94+
$vsInstallDir = &$vswhere -latest -products * -requires $vscomponent -property installationPath
95+
if ([string]::IsNullOrEmpty($vsInstallDir)) {
96+
$vsInstallDir = &$vswhere -latest -prerelease -products * -requires $vscomponent -property installationPath
8097
}
81-
if ($null -eq $VisualCxxBatchFile) {
82-
Write-Host -ForegroundColor Red "visual c++ vcvarsall.bat not found"
98+
if ([string]::IsNullOrEmpty($vsInstallDir)) {
99+
Write-Host -ForegroundColor Red "No Visual Studio installation found."
83100
exit 1
84101
}
85102

103+
$VisualCxxBatchFile = Join-Path $vsInstallDir -ChildPath "VC\Auxiliary\Build\vcvarsall.bat"
86104

87-
Write-Host "call `"$VisualCxxBatchFile`" $TargetWithHost"
105+
Write-Host "call `"$VisualCxxBatchFile`" $vsarch"
106+
107+
Invoke-BatchFile -Path $VisualCxxBatchFile -Arguments $vsarch
108+
109+
$cmake = Get-Command -CommandType Application "cmake" -ErrorAction SilentlyContinue
110+
if ($null -ne $cmake) {
111+
$cmakeExe = $cmake[0].Source
112+
Write-Host "Use cmake $cmakeExe"
113+
}
88114

89-
Invoke-BatchFile -Path $VisualCxxBatchFile -Arguments $TargetWithHost
90115
$WD = Join-Path -Path $PWD -ChildPath "build"
91116
try {
92117
New-Item -ItemType Directory -Force -Path $WD

vendor/bela/clang-tidy.bat

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
@echo off
22

3-
where pwsh.exe >nul 2>nul
4-
if %ERRORLEVEL% NEQ 0 (
5-
echo It is recommended to install PowerShell 7^+ for a better experience.
6-
powershell -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0clang-tidy.ps1" %*
7-
) else (
8-
pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0clang-tidy.ps1" %*
9-
)
3+
pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -File "%~dp0clang-tidy.ps1" %*

vendor/bela/clang-tidy.ps1

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,60 @@ param(
55
[string]$Out
66
)
77

8-
# C:\Program Files\Microsoft Visual Studio\2022
9-
$VS2022Root = "$env:ProgramFiles\Microsoft Visual Studio\2022"
10-
11-
$clangtidy = $null
12-
$clangtidyLocal = $(
13-
# x64
14-
"$VS2022Root\Preview\VC\Tools\Llvm\x64\bin\clang-tidy.exe",
15-
"$VS2022Root\Community\VC\Tools\Llvm\x64\bin\clang-tidy.exe",
16-
"$VS2022Root\Professional\VC\Tools\Llvm\x64\bin\clang-tidy.exe",
17-
"$VS2022Root\Enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe",
18-
19-
"$env:ProgramFiles\llvm\bin\clang-tidy.exe"
20-
)
21-
foreach ($c in $clangtidyLocal) {
22-
if (Test-Path $c) {
23-
$clangtidy = $c
24-
break
8+
9+
$llvmArchTable = @{
10+
"win-x64" = "x64";
11+
"win-arm64" = "arm64";
12+
}
13+
14+
$RID = [System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier
15+
# win-x64 win-arm64
16+
17+
$llvmArch = $llvmArchTable[$RID]
18+
19+
function Get-VSWhere {
20+
$app = Get-Command -CommandType Application "vswhere" -ErrorAction SilentlyContinue
21+
if ($null -ne $app) {
22+
return $app[0].Source
23+
}
24+
$vswhere = Join-Path ${env:ProgramFiles(x86)} -ChildPath "Microsoft Visual Studio\Installer\vswhere.exe"
25+
if (Test-Path $vswhere) {
26+
return $vswhere
2527
}
28+
return $null
2629
}
2730

28-
if ($null -eq $clangtidy) {
29-
$clangtidyobj = Get-Command -CommandType Application "clang-tidy" -ErrorAction SilentlyContinue
30-
if ($null -eq $clangtidyobj) {
31-
Write-Host -ForegroundColor Red "No clang-tidy to be found"
32-
return
31+
32+
function Get-ClangTidy {
33+
$app = Get-Command -CommandType Application "clang-tidy" -ErrorAction SilentlyContinue
34+
if ($null -ne $app) {
35+
return $app[0].Source
36+
}
37+
$clangTidy = Join-Path $env:ProgramFiles -ChildPath "llvm\bin\clang-tidy.exe"
38+
if (Test-Path $clangTidy) {
39+
return $clangTidy
40+
}
41+
# vswhere.exe -prerelease -latest -requires Microsoft.VisualStudio.Component.VC.Llvm.Clang -property installationPath
42+
$vswhere = Get-VSWhere
43+
if ($null -eq $vswhere) {
44+
return $null
45+
}
46+
$InstallDir = &$vswhere -prerelease -latest -requires Microsoft.VisualStudio.Component.VC.Llvm.Clang -property installationPath
47+
if ([string]::IsNullOrEmpty($InstallDir)) {
48+
return $null
3349
}
34-
$clangtidy = $clangtidyobj[0].Source
50+
$clangTidy = Join-Path $InstallDir -ChildPath "VC\Tools\Llvm\${llvmArch}\bin\clang-tidy.exe"
51+
return $clangTidy
3552
}
3653

54+
$clangTidyExe = Get-ClangTidy
55+
if ($null -eq $clangTidyExe) {
56+
Write-Host -ForegroundColor Red "clang-tidy not found"
57+
exit 1
58+
}
59+
60+
# vswhere -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
61+
3762
$SOURCE_DIRS = $(
3863
"$PSScriptRoot\src\bela",
3964
"$PSScriptRoot\src\belahash",
@@ -59,6 +84,8 @@ $checks = $(
5984
"-readability-magic-numbers",
6085
"-readability-qualified-auto",
6186
"-readability-function-cognitive-complexity",
87+
"-readability-identifier-length",
88+
#"-readability-math-missing-parentheses",
6289
"modernize-*",
6390
"-modernize-use-trailing-return-type",
6491
"-modernize-avoid-c-arrays",
@@ -75,7 +102,7 @@ $inputArgs = $(
75102
"-m64",
76103
"-x",
77104
"c++" ,
78-
"-std=c++20",
105+
"-std=c++23",
79106
"-ferror-limit=1000",
80107
"-D_WIN64",
81108
"-DNDEBUG",
@@ -92,7 +119,7 @@ $inputArgs = $(
92119

93120
$inputArgsPrefix = [string]::Join(" ", $inputArgs)
94121

95-
Write-Host "Use $clangtidy`n$inputArgsPrefix"
122+
Write-Host "Use $clangTidyExe`n$inputArgsPrefix"
96123

97124
$extensions = (".cc", ".cxx", ".cpp", ".c++");
98125

@@ -102,7 +129,7 @@ foreach ($d in $SOURCE_DIRS) {
102129
if ($extensions.Contains($_.Extension)) {
103130
$FileName = $_.FullName
104131
Write-Host -ForegroundColor Magenta "check $FileName"
105-
$exitCode = Start-Process -FilePath $clangtidy -ArgumentList "`"$FileName`" $inputArgsPrefix" -Wait -PassThru -NoNewWindow -WorkingDirectory $PSScriptRoot
132+
$exitCode = Start-Process -FilePath $clangTidyExe -ArgumentList "`"$FileName`" $inputArgsPrefix" -Wait -PassThru -NoNewWindow -WorkingDirectory $PSScriptRoot
106133
$exitCode | Out-Null
107134
}
108135
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
https://github.com/greg7mdp/parallel-hashmap.git
2-
154c63489e84d5569d3b466342a2ae8fd99e4734
2+
88123934b46b77c3b6d80167382734cbff6eff74

vendor/bela/include/bela/__phmap/phmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3559,7 +3559,8 @@ class parallel_hash_set
35593559
class K = key_type,
35603560
typename std::enable_if<!std::is_same<K, iterator>::value, int>::type = 0>
35613561
node_type extract(const key_arg<K>& key) {
3562-
auto it = find(key);
3562+
UniqueLock m;
3563+
auto it = this->template find<K, UniqueLock>(key, this->hash(key), m);
35633564
return it == end() ? node_type() : extract(const_iterator{it});
35643565
}
35653566

0 commit comments

Comments
 (0)