Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
78 changes: 77 additions & 1 deletion .github/workflows/call-build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,90 @@ jobs:
with:
ref: ${{ inputs.ref }}

- name: Set up CMake
run: |
$cmakeVersion = "${{ matrix.config.cmake_version }}"
$cmakeArch = "x86_64"
$cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/cmake-${cmakeVersion}-windows-${cmakeArch}.zip"
$cmakeZip = "$env:RUNNER_TEMP\cmake-${cmakeVersion}.zip"
$cmakeDir = "C:\Program Files\CMake"
Write-Host "Downloading CMake ${cmakeVersion} from official GitHub releases: ${cmakeUrl}"
# Download with retry logic
$maxRetries = 3
$retryCount = 0
$downloaded = $false
while ($retryCount -lt $maxRetries -and -not $downloaded) {
try {
$retryCount++
Write-Host "Attempt $retryCount of $maxRetries"
Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeZip -UseBasicParsing -ErrorAction Stop
# Verify file was downloaded and has content
if (Test-Path $cmakeZip) {
$fileInfo = Get-Item $cmakeZip
if ($fileInfo.Length -gt 0) {
Write-Host "Download successful. File size: $($fileInfo.Length) bytes"
$downloaded = $true
} else {
Write-Host "Downloaded file is empty, retrying..."
Remove-Item $cmakeZip -Force -ErrorAction SilentlyContinue
}
}
} catch {
Write-Host "Download attempt $retryCount failed: $_"
if ($retryCount -lt $maxRetries) {
Start-Sleep -Seconds 2
Remove-Item $cmakeZip -Force -ErrorAction SilentlyContinue
} else {
throw "Failed to download CMake after $maxRetries attempts: $_"
}
}
}
# Verify it's a valid ZIP file by checking the header (ZIP files start with PK)
$header = [System.IO.File]::ReadAllBytes($cmakeZip)[0..1]
if (-not ($header[0] -eq 0x50 -and $header[1] -eq 0x4B)) {
Write-Host "Warning: File may not be a valid ZIP. First bytes: $($header[0]), $($header[1])"
Write-Host "Expected: 80, 75 (PK in hex)"
throw "Downloaded file is not a valid ZIP archive"
}
Write-Host "ZIP file validation passed (PK header found)"
Write-Host "Extracting CMake to C:\Program Files"
# Remove existing CMake directory if it exists
if (Test-Path $cmakeDir) {
Remove-Item $cmakeDir -Recurse -Force
}
# Extract ZIP file
Expand-Archive -Path $cmakeZip -DestinationPath "C:\Program Files" -Force
# Rename extracted folder to standard CMake directory name
$extractedDir = "C:\Program Files\cmake-${cmakeVersion}-windows-${cmakeArch}"
if (Test-Path $extractedDir) {
Rename-Item -Path $extractedDir -NewName "CMake" -Force
}
# Verify installation
$cmakeExe = "$cmakeDir\bin\cmake.exe"
if (Test-Path $cmakeExe) {
Write-Host "CMake installed successfully"
& $cmakeExe --version
} else {
throw "CMake installation verification failed: $cmakeExe not found"
}
shell: pwsh

- name: Get dependencies
run: |
Invoke-WebRequest -OutFile winflexbison.zip $env:WINFLEXBISON
Expand-Archive winflexbison.zip -Destination C:\WinFlexBison
Copy-Item -Path C:\WinFlexBison/win_bison.exe C:\WinFlexBison/bison.exe
Copy-Item -Path C:\WinFlexBison/win_flex.exe C:\WinFlexBison/flex.exe
echo "C:\WinFlexBison" | Out-File -FilePath $env:GITHUB_PATH -Append
choco install cmake --version "${{ matrix.config.cmake_version }}" --force
env:
WINFLEXBISON: https://github.com/lexxmark/winflexbison/releases/download/v2.5.22/win_flex_bison-2.5.22.zip
shell: pwsh
Expand Down
78 changes: 77 additions & 1 deletion .github/workflows/call-windows-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,90 @@ jobs:
with:
ref: ${{ inputs.ref }}

- name: Set up CMake
run: |
$cmakeVersion = "${{ matrix.config.cmake_version }}"
$cmakeArch = "x86_64"
$cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/cmake-${cmakeVersion}-windows-${cmakeArch}.zip"
$cmakeZip = "$env:RUNNER_TEMP\cmake-${cmakeVersion}.zip"
$cmakeDir = "C:\Program Files\CMake"
Comment on lines +66 to +72
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

CMake ARM64 Windows release download available

💡 Result:

Yes—CMake provides native Windows ARM64 release downloads.

  • The CMake download page lists Windows ARM64 Installer (cmake-4.2.3-windows-arm64.msi) and Windows ARM64 ZIP (cmake-4.2.3-windows-arm64.zip) for the latest stable release. [1]
  • Native Windows-on-Arm support is available starting with CMake 3.24 (so you can pick an older ARM64 build if needed). [2]

Download page (choose the Windows ARM64 entries):

https://cmake.org/download/

Sources: [1], [2]


Hardcoded x86_64 architecture should use native ARM64 binary on ARM64 runner.

The ARM64 configuration uses os: windows-11-arm but $cmakeArch is hardcoded to "x86_64". While Windows on ARM can run x86_64 binaries through emulation, CMake provides native ARM64 Windows releases (available since CMake 3.24). Using the native ARM64 binary is preferable to emulation.

Suggested fix to detect and use native ARM64 builds
          $cmakeVersion = "${{ matrix.config.cmake_version }}"
-          $cmakeArch = "x86_64"
+          # Determine CMake architecture based on runner
+          if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
+            $cmakeArch = "arm64"
+          } else {
+            $cmakeArch = "x86_64"
+          }
          $cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/cmake-${cmakeVersion}-windows-${cmakeArch}.zip"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Set up CMake
run: |
$cmakeVersion = "${{ matrix.config.cmake_version }}"
$cmakeArch = "x86_64"
$cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/cmake-${cmakeVersion}-windows-${cmakeArch}.zip"
$cmakeZip = "$env:RUNNER_TEMP\cmake-${cmakeVersion}.zip"
$cmakeDir = "C:\Program Files\CMake"
- name: Set up CMake
run: |
$cmakeVersion = "${{ matrix.config.cmake_version }}"
# Determine CMake architecture based on runner
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
$cmakeArch = "arm64"
} else {
$cmakeArch = "x86_64"
}
$cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/cmake-${cmakeVersion}-windows-${cmakeArch}.zip"
$cmakeZip = "$env:RUNNER_TEMP\cmake-${cmakeVersion}.zip"
$cmakeDir = "C:\Program Files\CMake"
🤖 Prompt for AI Agents
In @.github/workflows/call-windows-unit-tests.yaml around lines 66 - 72, The
cmake architecture is hardcoded to "x86_64" which forces an emulated binary on
ARM runners; update the logic that sets $cmakeArch so it picks a native ARM64
build when running on an ARM64 runner (inspect environment like
$env:PROCESSOR_ARCHITECTURE or $env:RUNNER_ARCH and fall back to x86_64
otherwise). Change the assignment for $cmakeArch (the variable used to build
$cmakeUrl) to conditionally use "arm64" for ARM64 hosts and "x86_64" for others
so the download URL (cmake-${cmakeVersion}-windows-${cmakeArch}.zip) points at
the correct native CMake release.

Write-Host "Downloading CMake ${cmakeVersion} from official GitHub releases: ${cmakeUrl}"
# Download with retry logic
$maxRetries = 3
$retryCount = 0
$downloaded = $false
while ($retryCount -lt $maxRetries -and -not $downloaded) {
try {
$retryCount++
Write-Host "Attempt $retryCount of $maxRetries"
Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeZip -UseBasicParsing -ErrorAction Stop
# Verify file was downloaded and has content
if (Test-Path $cmakeZip) {
$fileInfo = Get-Item $cmakeZip
if ($fileInfo.Length -gt 0) {
Write-Host "Download successful. File size: $($fileInfo.Length) bytes"
$downloaded = $true
} else {
Write-Host "Downloaded file is empty, retrying..."
Remove-Item $cmakeZip -Force -ErrorAction SilentlyContinue
}
}
} catch {
Write-Host "Download attempt $retryCount failed: $_"
if ($retryCount -lt $maxRetries) {
Start-Sleep -Seconds 2
Remove-Item $cmakeZip -Force -ErrorAction SilentlyContinue
} else {
throw "Failed to download CMake after $maxRetries attempts: $_"
}
}
}
# Verify it's a valid ZIP file by checking the header (ZIP files start with PK)
$header = [System.IO.File]::ReadAllBytes($cmakeZip)[0..1]
if (-not ($header[0] -eq 0x50 -and $header[1] -eq 0x4B)) {
Write-Host "Warning: File may not be a valid ZIP. First bytes: $($header[0]), $($header[1])"
Write-Host "Expected: 80, 75 (PK in hex)"
throw "Downloaded file is not a valid ZIP archive"
}
Write-Host "ZIP file validation passed (PK header found)"
Write-Host "Extracting CMake to C:\Program Files"
# Remove existing CMake directory if it exists
if (Test-Path $cmakeDir) {
Remove-Item $cmakeDir -Recurse -Force
}
# Extract ZIP file
Expand-Archive -Path $cmakeZip -DestinationPath "C:\Program Files" -Force
# Rename extracted folder to standard CMake directory name
$extractedDir = "C:\Program Files\cmake-${cmakeVersion}-windows-${cmakeArch}"
if (Test-Path $extractedDir) {
Rename-Item -Path $extractedDir -NewName "CMake" -Force
}
# Verify installation
$cmakeExe = "$cmakeDir\bin\cmake.exe"
if (Test-Path $cmakeExe) {
Write-Host "CMake installed successfully"
& $cmakeExe --version
} else {
throw "CMake installation verification failed: $cmakeExe not found"
}
shell: pwsh

- name: Get dependencies
run: |
Invoke-WebRequest -OutFile winflexbison.zip $env:WINFLEXBISON
Expand-Archive winflexbison.zip -Destination C:\WinFlexBison
Copy-Item -Path C:\WinFlexBison/win_bison.exe C:\WinFlexBison/bison.exe
Copy-Item -Path C:\WinFlexBison/win_flex.exe C:\WinFlexBison/flex.exe
echo "C:\WinFlexBison" | Out-File -FilePath $env:GITHUB_PATH -Append
choco install cmake.portable --version "${{ matrix.config.cmake_version }}" --force
env:
WINFLEXBISON: https://github.com/lexxmark/winflexbison/releases/download/v2.5.22/win_flex_bison-2.5.22.zip
shell: pwsh
Expand Down
33 changes: 1 addition & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1219,38 +1219,7 @@ endif()
# LibBacktrace (friendly stacktrace support)
# =========================================
if(FLB_BACKTRACE)
if(FLB_PREFER_SYSTEM_LIB_BACKTRACE)
find_path(LIBBACKTRACE_INCLUDE_DIRS NAMES backtrace.h)
find_library(LIBBACKTRACE_LIBRARIES NAMES backtrace)
endif()
if(LIBBACKTRACE_INCLUDE_DIRS AND LIBBACKTRACE_LIBRARIES)
message(STATUS "libbacktrace found (${LIBBACKTRACE_LIBRARIES})")
include_directories(${LIBBACKTRACE_INCLUDE_DIRS})
link_directories(${LIBBACKTRACE_LIBRARY_DIRS})
else()
message(STATUS "libbacktrace not found, building ourselves")
if (CMAKE_OSX_SYSROOT)
# From macOS Mojave, /usr/include does not store C SDK headers.
# For libbacktrace building on macOS, we have to tell C headers where they are located.
set(DEPS_C_COMPILER "${CMAKE_C_COMPILER} -isysroot ${CMAKE_OSX_SYSROOT}")
else()
set(DEPS_C_COMPILER "${CMAKE_C_COMPILER}")
endif()
set(FLB_LIBBACKTRACE_PATH "${CMAKE_CURRENT_BINARY_DIR}/backtrace-prefix/lib/libbacktrace.a")
ExternalProject_Add(backtrace
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-8602fda/
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-8602fda/configure ${AUTOCONF_HOST_OPT} --prefix=<INSTALL_DIR> --enable-shared=no --enable-static=yes
BUILD_COMMAND ${EXTERNAL_BUILD_TOOL}
BUILD_BYPRODUCTS ${FLB_LIBBACKTRACE_PATH}
INSTALL_COMMAND ${EXTERNAL_BUILD_TOOL} DESTDIR= install
)
add_library(libbacktrace STATIC IMPORTED GLOBAL)
set_target_properties(libbacktrace PROPERTIES IMPORTED_LOCATION ${FLB_LIBBACKTRACE_PATH})
add_dependencies(libbacktrace backtrace)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/backtrace-prefix/include/")
set(LIBBACKTRACE_LIBRARIES "libbacktrace")
endif()
FLB_DEFINITION(FLB_HAVE_LIBBACKTRACE)
include(cmake/libbacktrace.cmake)
endif()

# Onigmo (Regex Engine) options
Expand Down
Loading
Loading