From d42057770d66c22ef574aaf8c894a1170fe96db8 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Sat, 11 Jul 2026 16:12:22 +0500 Subject: [PATCH 01/43] Add libffi build support for Windows C loader --- tools/metacall-environment.ps1 | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1 index 37275b797..4eff194dc 100755 --- a/tools/metacall-environment.ps1 +++ b/tools/metacall-environment.ps1 @@ -245,6 +245,56 @@ function Set-Curl { Write-Output "-DCURL_LIBRARY_NAME=""$CURL_LIB_NAME""" >> $EnvOpts } +function Set-C { + Write-Output "Install C Loader Dependencies (libffi)" + + Set-Location $ROOT_DIR + + $LibFFIVersion = "3.5.2" + $DepsDir = "$ROOT_DIR\dependencies" + $RuntimeDir = "$DepsDir\libffi" + $DistDir = "$RuntimeDir\dist" + + mkdir -Force $DepsDir + mkdir -Force $RuntimeDir + mkdir -Force $DistDir + + Set-Location $DepsDir + + # Download official libffi source tarball + if (!(Test-Path -Path "$DepsDir\libffi.tar.gz")) { + Write-Output "libffi not found, downloading..." + (New-Object Net.WebClient).DownloadFile( + "https://github.com/libffi/libffi/releases/download/v$LibFFIVersion/libffi-$LibFFIVersion.tar.gz", + "$DepsDir\libffi.tar.gz" + ) + } + + # Extract + cmake -E tar xzf "$DepsDir\libffi.tar.gz" + + $SrcDir = "$DepsDir\libffi-$LibFFIVersion" + $BuildDir = "$RuntimeDir\build" + mkdir -Force $BuildDir + + # Git Bash is available on all Windows GitHub Actions runners + $GitBash = "C:\Program Files\Git\bin\bash.exe" + $MsvccSh = "$SrcDir/msvcc.sh" + $DistDirUnix = $DistDir.Replace('\', '/') + $BuildDirUnix = $BuildDir.Replace('\', '/') + $SrcDirUnix = $SrcDir.Replace('\', '/') + + # Build libffi using msvcc.sh — official upstream documented approach + & $GitBash -c "cd '$BuildDirUnix' && '$SrcDirUnix/configure' CC='$MsvccSh -m64' CXX='$MsvccSh -m64' LD=link CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' --prefix='$DistDirUnix' --build=x86_64-pc-mingw64 && make && make install" + + # Write CMake flags + $EnvOpts = "$ROOT_DIR\build\CMakeConfig.txt" + $LibFFIDir = $DistDir.Replace('\', '/') + + Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFIDir/include""" >> $EnvOpts + Write-Output "-DLIBFFI_LIBRARY=""$LibFFIDir/lib/libffi.lib""" >> $EnvOpts +} + function Add-to-Path { $GivenPath = $args[0] @@ -351,6 +401,7 @@ function Configure { } if ("$var" -eq 'c') { Write-Output "c selected" + Set-C } if ("$var" -eq 'cobol') { Write-Output "cobol selected" From 5f0b22beb80830a85e77dceee234b2f78a51a5ed Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Mon, 13 Jul 2026 19:48:44 +0500 Subject: [PATCH 02/43] Enable C loader in Windows CI workflow --- .github/workflows/windows-test.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml index 3518e6d4d..4f2395586 100644 --- a/.github/workflows/windows-test.yml +++ b/.github/workflows/windows-test.yml @@ -5,7 +5,7 @@ on: pull_request: push: tags: - - 'v*.*.*' + - "v*.*.*" branches: - master - develop @@ -24,16 +24,15 @@ jobs: matrix: os: [2022, 2025] options: [ - {build: debug, sanitizer: without-sanitizer}, - {build: debug, sanitizer: address-sanitizer}, + { build: debug, sanitizer: without-sanitizer }, + { build: debug, sanitizer: address-sanitizer }, + # TODO: Not supported yet by MSVC + # {build: debug, sanitizer: thread-sanitizer}, + # {build: debug, sanitizer: memory-sanitizer}, - # TODO: Not supported yet by MSVC - # {build: debug, sanitizer: thread-sanitizer}, - # {build: debug, sanitizer: memory-sanitizer}, - - # TODO: https://github.com/metacall/core/issues/461 - # {build: release, sanitizer: without-sanitizer} - ] + # TODO: https://github.com/metacall/core/issues/461 + # {build: release, sanitizer: without-sanitizer} + ] steps: - name: Check out the repository @@ -49,7 +48,7 @@ jobs: - name: Set up the environment run: cmd.exe /c "powershell .\tools\metacall-environment.ps1 $Env:METACALL_INSTALL_OPTIONS" env: - METACALL_INSTALL_OPTIONS: python nodejs java ruby typescript wasm rpc file # netcore5 java c cobol rust rapidjson pack # clangformat v8rep51 coverage + METACALL_INSTALL_OPTIONS: python nodejs java ruby typescript wasm rpc file c # netcore5 java c cobol rust rapidjson pack # clangformat v8rep51 coverage - name: Configure run: | @@ -58,7 +57,7 @@ jobs: cd "$METACALL_PATH\build" cmd.exe /c "powershell ..\tools\metacall-configure.ps1 $Env:METACALL_BUILD_OPTIONS" env: - METACALL_BUILD_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs java ruby typescript wasm rpc file # netcore5 java c cobol rust examples install pack benchmarks # v8 coverage + METACALL_BUILD_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs java ruby typescript wasm rpc file c # netcore5 java c cobol rust examples install pack benchmarks # v8 coverage - name: Build working-directory: ./build @@ -82,3 +81,4 @@ jobs: wait_workflow: true client_payload: '{"ref": "${{ github.head_ref || github.ref_name }}"}' ref: master + From f35b24db89d6aebd130adf22464d9ced8fd6aa5e Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Wed, 15 Jul 2026 10:32:16 +0500 Subject: [PATCH 03/43] Add libffi and LLVM/libclang setup for Windows C loader --- tools/metacall-environment.ps1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1 index 4eff194dc..6eeeb9a81 100755 --- a/tools/metacall-environment.ps1 +++ b/tools/metacall-environment.ps1 @@ -246,7 +246,7 @@ function Set-Curl { } function Set-C { - Write-Output "Install C Loader Dependencies (libffi)" + Write-Output "Install C Loader Dependencies (libffi + LLVM)" Set-Location $ROOT_DIR @@ -287,12 +287,24 @@ function Set-C { # Build libffi using msvcc.sh — official upstream documented approach & $GitBash -c "cd '$BuildDirUnix' && '$SrcDirUnix/configure' CC='$MsvccSh -m64' CXX='$MsvccSh -m64' LD=link CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' --prefix='$DistDirUnix' --build=x86_64-pc-mingw64 && make && make install" - # Write CMake flags + # Write libffi CMake flags $EnvOpts = "$ROOT_DIR\build\CMakeConfig.txt" $LibFFIDir = $DistDir.Replace('\', '/') Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFIDir/include""" >> $EnvOpts Write-Output "-DLIBFFI_LIBRARY=""$LibFFIDir/lib/libffi.lib""" >> $EnvOpts + + # Install LLVM via choco (includes libclang) + Write-Output "Installing LLVM..." + choco install llvm --confirm + + $LLVMDir = "C:/Program Files/LLVM" + + Add-to-Path "$LLVMDir\bin" + + # Write LibClang CMake flags — same pattern as Darwin/FreeBSD in metacall-environment.sh + Write-Output "-DLibClang_INCLUDE_DIR=""$LLVMDir/include""" >> $EnvOpts + Write-Output "-DLibClang_LIBRARY=""$LLVMDir/lib/libclang.lib""" >> $EnvOpts } function Add-to-Path { From 9f6cd5e1f4fe8d8698d32c030a7c5cbbfc3d17de Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Wed, 15 Jul 2026 11:20:58 +0500 Subject: [PATCH 04/43] Fix libclang setup: use official LLVM prebuilt archive instead of choco --- .github/workflows/windows-test.yml | 26 +++++++++++----------- tools/metacall-environment.ps1 | 35 ++++++++++++++++++------------ 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml index 4f2395586..3b5a56def 100644 --- a/.github/workflows/windows-test.yml +++ b/.github/workflows/windows-test.yml @@ -5,7 +5,7 @@ on: pull_request: push: tags: - - "v*.*.*" + - 'v*.*.*' branches: - master - develop @@ -24,15 +24,16 @@ jobs: matrix: os: [2022, 2025] options: [ - { build: debug, sanitizer: without-sanitizer }, - { build: debug, sanitizer: address-sanitizer }, - # TODO: Not supported yet by MSVC - # {build: debug, sanitizer: thread-sanitizer}, - # {build: debug, sanitizer: memory-sanitizer}, + {build: debug, sanitizer: without-sanitizer}, + {build: debug, sanitizer: address-sanitizer}, - # TODO: https://github.com/metacall/core/issues/461 - # {build: release, sanitizer: without-sanitizer} - ] + # TODO: Not supported yet by MSVC + # {build: debug, sanitizer: thread-sanitizer}, + # {build: debug, sanitizer: memory-sanitizer}, + + # TODO: https://github.com/metacall/core/issues/461 + # {build: release, sanitizer: without-sanitizer} + ] steps: - name: Check out the repository @@ -48,7 +49,7 @@ jobs: - name: Set up the environment run: cmd.exe /c "powershell .\tools\metacall-environment.ps1 $Env:METACALL_INSTALL_OPTIONS" env: - METACALL_INSTALL_OPTIONS: python nodejs java ruby typescript wasm rpc file c # netcore5 java c cobol rust rapidjson pack # clangformat v8rep51 coverage + METACALL_INSTALL_OPTIONS: python nodejs java ruby typescript wasm rpc file c # netcore5 java cobol rust rapidjson pack # clangformat v8rep51 coverage - name: Configure run: | @@ -57,7 +58,7 @@ jobs: cd "$METACALL_PATH\build" cmd.exe /c "powershell ..\tools\metacall-configure.ps1 $Env:METACALL_BUILD_OPTIONS" env: - METACALL_BUILD_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs java ruby typescript wasm rpc file c # netcore5 java c cobol rust examples install pack benchmarks # v8 coverage + METACALL_BUILD_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs java ruby typescript wasm rpc file c # netcore5 java cobol rust examples install pack benchmarks # v8 coverage - name: Build working-directory: ./build @@ -80,5 +81,4 @@ jobs: workflow_file_name: ci.yml wait_workflow: true client_payload: '{"ref": "${{ github.head_ref || github.ref_name }}"}' - ref: master - + ref: master \ No newline at end of file diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1 index 6eeeb9a81..1d6482798 100755 --- a/tools/metacall-environment.ps1 +++ b/tools/metacall-environment.ps1 @@ -246,11 +246,12 @@ function Set-Curl { } function Set-C { - Write-Output "Install C Loader Dependencies (libffi + LLVM)" + Write-Output "Install C Loader Dependencies (libffi + libclang)" Set-Location $ROOT_DIR $LibFFIVersion = "3.5.2" + $LLVMVersion = "19.1.0" $DepsDir = "$ROOT_DIR\dependencies" $RuntimeDir = "$DepsDir\libffi" $DistDir = "$RuntimeDir\dist" @@ -270,41 +271,47 @@ function Set-C { ) } - # Extract cmake -E tar xzf "$DepsDir\libffi.tar.gz" $SrcDir = "$DepsDir\libffi-$LibFFIVersion" $BuildDir = "$RuntimeDir\build" mkdir -Force $BuildDir - # Git Bash is available on all Windows GitHub Actions runners $GitBash = "C:\Program Files\Git\bin\bash.exe" - $MsvccSh = "$SrcDir/msvcc.sh" $DistDirUnix = $DistDir.Replace('\', '/') $BuildDirUnix = $BuildDir.Replace('\', '/') $SrcDirUnix = $SrcDir.Replace('\', '/') + $MsvccSh = "$SrcDirUnix/msvcc.sh" - # Build libffi using msvcc.sh — official upstream documented approach & $GitBash -c "cd '$BuildDirUnix' && '$SrcDirUnix/configure' CC='$MsvccSh -m64' CXX='$MsvccSh -m64' LD=link CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' --prefix='$DistDirUnix' --build=x86_64-pc-mingw64 && make && make install" - # Write libffi CMake flags $EnvOpts = "$ROOT_DIR\build\CMakeConfig.txt" $LibFFIDir = $DistDir.Replace('\', '/') Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFIDir/include""" >> $EnvOpts Write-Output "-DLIBFFI_LIBRARY=""$LibFFIDir/lib/libffi.lib""" >> $EnvOpts - # Install LLVM via choco (includes libclang) - Write-Output "Installing LLVM..." - choco install llvm --confirm + # Download official LLVM prebuilt archive (includes libclang.lib + headers) + # Using clang+llvm archive which contains libraries needed for development + $LLVMArchive = "clang+llvm-$LLVMVersion-x86_64-pc-windows-msvc.tar.xz" + $LLVMDir = "$DepsDir\llvm" - $LLVMDir = "C:/Program Files/LLVM" + if (!(Test-Path -Path "$DepsDir\$LLVMArchive")) { + Write-Output "LLVM not found, downloading..." + (New-Object Net.WebClient).DownloadFile( + "https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVMVersion/$LLVMArchive", + "$DepsDir\$LLVMArchive" + ) + } + + mkdir -Force $LLVMDir + cmake -E tar xf "$DepsDir\$LLVMArchive" + Robocopy.exe /move /e "$DepsDir\clang+llvm-$LLVMVersion-x86_64-pc-windows-msvc" $LLVMDir /NFL /NDL /NJH /NJS /NC /NS /NP - Add-to-Path "$LLVMDir\bin" + $LLVMDirUnix = $LLVMDir.Replace('\', '/') - # Write LibClang CMake flags — same pattern as Darwin/FreeBSD in metacall-environment.sh - Write-Output "-DLibClang_INCLUDE_DIR=""$LLVMDir/include""" >> $EnvOpts - Write-Output "-DLibClang_LIBRARY=""$LLVMDir/lib/libclang.lib""" >> $EnvOpts + Write-Output "-DLibClang_INCLUDE_DIR=""$LLVMDirUnix/include""" >> $EnvOpts + Write-Output "-DLibClang_LIBRARY=""$LLVMDirUnix/lib/libclang.lib""" >> $EnvOpts } function Add-to-Path { From 2bb872af6ad2f1ed9954c149cac75effe17a9642 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Wed, 15 Jul 2026 15:30:56 +0500 Subject: [PATCH 05/43] Fix libtcc Windows MSVC: skip CMake configure step --- cmake/InstallLibTCC.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index fd3ef4287..d34033391 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -95,7 +95,7 @@ elseif(PROJECT_OS_FAMILY STREQUAL win32) if(PROJECT_OS_NAME STREQUAL MinGW) set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --config-mingw32 --disable-static) else() - set(LIBTCC_CONFIGURE "") + set(LIBTCC_CONFIGURE ${CMAKE_COMMAND} -E echo "Skipping configure for MSVC") endif() else() message(FATAL_ERROR "TCC library install support not implemented in this platform") From 15b108406d5e83fdfd4ef0536f31bdafaca31e97 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Wed, 15 Jul 2026 15:46:53 +0500 Subject: [PATCH 06/43] Fix libtcc Windows build: use cl compiler in build-tcc.bat --- cmake/InstallLibTCC.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index d34033391..3002b7a6f 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -115,7 +115,7 @@ elseif(PROJECT_OS_FAMILY STREQUAL win32) if(PROJECT_OS_NAME STREQUAL MinGW) set(LIBTCC_BUILD make -j${N}) else() - set(LIBTCC_BUILD ./win32/build-tcc.bat -i ${LIBTCC_INSTALL_PREFIX}) + set(LIBTCC_BUILD ./win32/build-tcc.bat -c cl -i ${LIBTCC_INSTALL_PREFIX}) endif() else() message(FATAL_ERROR "TCC library install support not implemented in this platform") From c6ab9a631d2f968a2d2787cb3f36f7a7abb2c4bb Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Wed, 15 Jul 2026 16:02:10 +0500 Subject: [PATCH 07/43] Fix libtcc Windows build: run build-tcc.bat from win32 directory --- cmake/InstallLibTCC.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index 3002b7a6f..86ac7c9a9 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -115,7 +115,7 @@ elseif(PROJECT_OS_FAMILY STREQUAL win32) if(PROJECT_OS_NAME STREQUAL MinGW) set(LIBTCC_BUILD make -j${N}) else() - set(LIBTCC_BUILD ./win32/build-tcc.bat -c cl -i ${LIBTCC_INSTALL_PREFIX}) + set(LIBTCC_BUILD cmd /c "cd win32 && build-tcc.bat -c cl -i ${LIBTCC_INSTALL_PREFIX}") endif() else() message(FATAL_ERROR "TCC library install support not implemented in this platform") From 43cdf094fce5d0998c6ca34ba44eef5675cf8fe8 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Wed, 15 Jul 2026 16:33:28 +0500 Subject: [PATCH 08/43] Fix libtcc Windows install: convert path separators for build-tcc.bat --- cmake/InstallLibTCC.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index 86ac7c9a9..40e89b762 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -115,7 +115,8 @@ elseif(PROJECT_OS_FAMILY STREQUAL win32) if(PROJECT_OS_NAME STREQUAL MinGW) set(LIBTCC_BUILD make -j${N}) else() - set(LIBTCC_BUILD cmd /c "cd win32 && build-tcc.bat -c cl -i ${LIBTCC_INSTALL_PREFIX}") + string(REPLACE "/" "\\" LIBTCC_INSTALL_PREFIX_WIN ${LIBTCC_INSTALL_PREFIX}) + set(LIBTCC_BUILD cmd /c "cd win32 && build-tcc.bat -c cl -i ${LIBTCC_INSTALL_PREFIX_WIN}") endif() else() message(FATAL_ERROR "TCC library install support not implemented in this platform") From c25e41ac96245fad03b4e71fd1280e0fd1989f09 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 16 Jul 2026 10:32:50 +0500 Subject: [PATCH 09/43] Fix libtcc Windows: correct dll name and install path for build-tcc.bat output --- cmake/InstallLibTCC.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index 40e89b762..44645ac0e 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -136,10 +136,17 @@ set(LIBTCC_COMMIT_SHA "30afb50e6436175e0eacf4b6d407d2eb867b265a") if(PROJECT_OS_FAMILY STREQUAL macos) # TODO: --disable-static is not working on MacOS, this should be reported or further investigated, remove this when it is solved set(LIBTTC_LIBRARY_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}tcc${CMAKE_STATIC_LIBRARY_SUFFIX}") +elseif(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) + set(LIBTTC_LIBRARY_NAME "libtcc.dll") else() set(LIBTTC_LIBRARY_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}tcc${CMAKE_SHARED_LIBRARY_SUFFIX}") endif() set(LIBTTC_LIBRARY_PATH "${PROJECT_OUTPUT_DIR}/${LIBTTC_LIBRARY_NAME}") +if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) + set(LIBTTC_LIBRARY_SOURCE_PATH "${LIBTCC_INSTALL_PREFIX}/${LIBTTC_LIBRARY_NAME}") +else() + set(LIBTTC_LIBRARY_SOURCE_PATH "${LIBTCC_INSTALL_PREFIX}/lib/${LIBTTC_LIBRARY_NAME}") +endif() set(LIBTTC_RUNTIME_PATH "${LIBTCC_INSTALL_PREFIX}/lib/tcc") set(LIBTTC_RUNTIME_INCLUDE_PATH "${LIBTTC_RUNTIME_PATH}/include") set(LIBTTC_RUNTIME_FILES @@ -160,7 +167,7 @@ ExternalProject_Add(${LIBTCC_TARGET} TEST_COMMAND "" UPDATE_COMMAND "" INSTALL_COMMAND ${LIBTCC_INSTALL} - COMMAND ${CMAKE_COMMAND} -E copy "${LIBTCC_INSTALL_PREFIX}/lib/${LIBTTC_LIBRARY_NAME}" "${LIBTTC_LIBRARY_PATH}" + COMMAND ${CMAKE_COMMAND} -E copy "${LIBTTC_LIBRARY_SOURCE_PATH}" "${LIBTTC_LIBRARY_PATH}" COMMAND ${CMAKE_COMMAND} -E copy ${LIBTTC_RUNTIME_FILES} "${PROJECT_OUTPUT_DIR}" ) From a4bd56f2bb3b8b9bacb323a869dd355b7d64aa34 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 16 Jul 2026 10:48:11 +0500 Subject: [PATCH 10/43] Fix libtcc Windows runtime path: build-tcc.bat puts files in lib/ not lib/tcc/ --- cmake/InstallLibTCC.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index 44645ac0e..bda3b4ccf 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -147,7 +147,11 @@ if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) else() set(LIBTTC_LIBRARY_SOURCE_PATH "${LIBTCC_INSTALL_PREFIX}/lib/${LIBTTC_LIBRARY_NAME}") endif() -set(LIBTTC_RUNTIME_PATH "${LIBTCC_INSTALL_PREFIX}/lib/tcc") +if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) + set(LIBTTC_RUNTIME_PATH "${LIBTCC_INSTALL_PREFIX}/lib") +else() + set(LIBTTC_RUNTIME_PATH "${LIBTCC_INSTALL_PREFIX}/lib/tcc") +endif() set(LIBTTC_RUNTIME_INCLUDE_PATH "${LIBTTC_RUNTIME_PATH}/include") set(LIBTTC_RUNTIME_FILES "${LIBTTC_RUNTIME_PATH}/libtcc1.a" From 3bfa700ba2290b82f6667ecb103ae5b1b94a66d7 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 16 Jul 2026 11:01:31 +0500 Subject: [PATCH 11/43] Fix libtcc Windows include dir: use libtcc/ instead of include/ to avoid MinGW header conflicts with MSVC --- cmake/InstallLibTCC.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index bda3b4ccf..306926425 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -200,7 +200,11 @@ install(DIRECTORY COMPONENT runtime ) -set(LIBTCC_INCLUDE_DIR "${LIBTCC_INSTALL_PREFIX}/include") +if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) + set(LIBTCC_INCLUDE_DIR "${LIBTCC_INSTALL_PREFIX}/libtcc") +else() + set(LIBTCC_INCLUDE_DIR "${LIBTCC_INSTALL_PREFIX}/include") +endif() set(LIBTCC_LIBRARY "${LIBTTC_LIBRARY_PATH}") set(LIBTCC_FOUND TRUE) From 5d00a8f0d2829987e820d8dacde7e155bbcc9d6d Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 16 Jul 2026 14:22:01 +0500 Subject: [PATCH 12/43] Add debug step to check libffi output structure --- .github/workflows/windows-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml index 3b5a56def..5b0b7486a 100644 --- a/.github/workflows/windows-test.yml +++ b/.github/workflows/windows-test.yml @@ -50,6 +50,10 @@ jobs: run: cmd.exe /c "powershell .\tools\metacall-environment.ps1 $Env:METACALL_INSTALL_OPTIONS" env: METACALL_INSTALL_OPTIONS: python nodejs java ruby typescript wasm rpc file c # netcore5 java cobol rust rapidjson pack # clangformat v8rep51 coverage + # Debug libffi output to help diagnose issues with libffi on Windows + - name: Debug libffi output + run: | + Get-ChildItem -Recurse "D:\a\metacall-core\metacall-core\dependencies\libffi\dist" | Select-Object FullName - name: Configure run: | From bd55f22a58b79708d79c761a2c007aca1f2e64a8 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 16 Jul 2026 16:49:51 +0500 Subject: [PATCH 13/43] Add debug step to inspect libffi output and CMakeConfig --- .github/workflows/windows-test.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml index 5b0b7486a..eda6b2d65 100644 --- a/.github/workflows/windows-test.yml +++ b/.github/workflows/windows-test.yml @@ -53,7 +53,14 @@ jobs: # Debug libffi output to help diagnose issues with libffi on Windows - name: Debug libffi output run: | - Get-ChildItem -Recurse "D:\a\metacall-core\metacall-core\dependencies\libffi\dist" | Select-Object FullName + Write-Output "=== Checking libffi dist ===" + if (Test-Path "D:\a\metacall-core\metacall-core\dependencies\libffi\dist") { + Get-ChildItem -Recurse "D:\a\metacall-core\metacall-core\dependencies\libffi\dist" | Select-Object FullName + } else { + Write-Output "libffi dist directory does not exist" + } + Write-Output "=== Checking CMakeConfig.txt ===" + Get-Content "D:\a\metacall-core\metacall-core\build\CMakeConfig.txt" - name: Configure run: | From d2db712ca60825617dd191f9db77db0319fd3787 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Fri, 17 Jul 2026 09:57:42 +0500 Subject: [PATCH 14/43] Remove debug step to inspect libffi output and CMakeConfig --- .github/workflows/windows-test.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml index eda6b2d65..3b5a56def 100644 --- a/.github/workflows/windows-test.yml +++ b/.github/workflows/windows-test.yml @@ -50,17 +50,6 @@ jobs: run: cmd.exe /c "powershell .\tools\metacall-environment.ps1 $Env:METACALL_INSTALL_OPTIONS" env: METACALL_INSTALL_OPTIONS: python nodejs java ruby typescript wasm rpc file c # netcore5 java cobol rust rapidjson pack # clangformat v8rep51 coverage - # Debug libffi output to help diagnose issues with libffi on Windows - - name: Debug libffi output - run: | - Write-Output "=== Checking libffi dist ===" - if (Test-Path "D:\a\metacall-core\metacall-core\dependencies\libffi\dist") { - Get-ChildItem -Recurse "D:\a\metacall-core\metacall-core\dependencies\libffi\dist" | Select-Object FullName - } else { - Write-Output "libffi dist directory does not exist" - } - Write-Output "=== Checking CMakeConfig.txt ===" - Get-Content "D:\a\metacall-core\metacall-core\build\CMakeConfig.txt" - name: Configure run: | From 56269a27305a60c5b97430f0603e1f3844fb4fd2 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 23 Jul 2026 15:37:31 +0500 Subject: [PATCH 15/43] Fix: Apply Set-C hardening --- tools/metacall-environment.ps1 | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1 index 1d6482798..933862e01 100755 --- a/tools/metacall-environment.ps1 +++ b/tools/metacall-environment.ps1 @@ -283,13 +283,33 @@ function Set-C { $SrcDirUnix = $SrcDir.Replace('\', '/') $MsvccSh = "$SrcDirUnix/msvcc.sh" - & $GitBash -c "cd '$BuildDirUnix' && '$SrcDirUnix/configure' CC='$MsvccSh -m64' CXX='$MsvccSh -m64' LD=link CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' --prefix='$DistDirUnix' --build=x86_64-pc-mingw64 && make && make install" + if (!(Test-Path -Path $GitBash)) { + throw "Git Bash is required to build libffi but was not found at '$GitBash'." + } + + if (!(Test-Path -Path "$SrcDir\configure") -or !(Test-Path -Path "$SrcDir\msvcc.sh")) { + throw "The libffi source archive did not extract the required configure and msvcc.sh files." + } + + & $GitBash -c "cd '$BuildDirUnix' && '$SrcDirUnix/configure' CC='$MsvccSh -m64' CXX='$MsvccSh -m64' LD=link CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' --prefix='$DistDirUnix' && make && make install" + + if ($LASTEXITCODE -ne 0) { + throw "Failed to configure, build, or install libffi (exit code $LASTEXITCODE)." + } + + $LibFFIHeader = Get-ChildItem -Path $DistDir -Filter "ffi.h" -File -Recurse | Select-Object -First 1 + $LibFFILibrary = Get-ChildItem -Path $DistDir -Filter "*.lib" -File -Recurse | Where-Object { $_.Name -match '^libffi' } | Select-Object -First 1 + + if (($null -eq $LibFFIHeader) -or ($null -eq $LibFFILibrary)) { + throw "libffi installation is incomplete: expected ffi.h and an MSVC libffi .lib file under '$DistDir'." + } $EnvOpts = "$ROOT_DIR\build\CMakeConfig.txt" - $LibFFIDir = $DistDir.Replace('\', '/') + $LibFFIIncludeDir = $LibFFIHeader.Directory.FullName.Replace('\', '/') + $LibFFILibraryPath = $LibFFILibrary.FullName.Replace('\', '/') - Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFIDir/include""" >> $EnvOpts - Write-Output "-DLIBFFI_LIBRARY=""$LibFFIDir/lib/libffi.lib""" >> $EnvOpts + Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFIIncludeDir""" >> $EnvOpts + Write-Output "-DLIBFFI_LIBRARY=""$LibFFILibraryPath""" >> $EnvOpts # Download official LLVM prebuilt archive (includes libclang.lib + headers) # Using clang+llvm archive which contains libraries needed for development From 621dee8886991a2dd1f65f8ca4957dbdc76104b9 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 05:46:26 +0500 Subject: [PATCH 16/43] Add Test Workflow --- .../workflows/libffi-msvc-investigation.yml | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 .github/workflows/libffi-msvc-investigation.yml diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml new file mode 100644 index 000000000..aeb442b88 --- /dev/null +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -0,0 +1,160 @@ + name: libffi MSVC investigation + + on: + workflow_dispatch: + + jobs: + build-libffi: + runs-on: windows-2022 + + steps: + - name: Activate MSVC + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + + - name: Download and inspect libffi + shell: pwsh + run: | + $Version = "3.5.2" + $Archive = "$env:RUNNER_TEMP\libffi-$Version.tar.gz" + $Source = "$env:RUNNER_TEMP\libffi-$Version" + $Build = "$env:RUNNER_TEMP\libffi-build" + $Install = "$env:RUNNER_TEMP\libffi-install" + + Invoke-WebRequest ` + "https://github.com/libffi/libffi/releases/download/v$Version/libffi-$Version.tar.gz" ` + -OutFile $Archive + + $Expected = "f3a3082a23b37c293a4fcd1053147b371f2ff91fa7ea1b2a52e335676bac82dc" + $Actual = (Get-FileHash $Archive -Algorithm SHA256).Hash.ToLower() + + if ($Actual -ne $Expected) { + throw "Checksum mismatch: expected $Expected, got $Actual" + } + + tar -xzf $Archive -C $env:RUNNER_TEMP + + $Required = @( + "configure", + "msvcc.sh", + "ltmain.sh", + "compile", + "missing", + "install-sh", + "config.guess", + "config.sub" + ) + + foreach ($File in $Required) { + if (!(Test-Path "$Source\$File")) { + throw "Missing required file: $Source\$File" + } + } + + New-Item -ItemType Directory -Force $Build, $Install + + "LIBFFI_SRC=$Source" >> $env:GITHUB_ENV + "LIBFFI_BUILD=$Build" >> $env:GITHUB_ENV + "LIBFFI_INSTALL=$Install" >> $env:GITHUB_ENV + + - name: Inspect Windows and Git Bash paths + shell: pwsh + run: | + Write-Host "PowerShell source path: $env:LIBFFI_SRC" + + & "C:\Program Files\Git\bin\bash.exe" -lc @' + set -eux + + src="$(cygpath -u "$LIBFFI_SRC")" + build="$(cygpath -u "$LIBFFI_BUILD")" + install="$(cygpath -u "$LIBFFI_INSTALL")" + + printf "src=%s\nbuild=%s\ninstall=%s\n" \ + "$src" "$build" "$install" + + test -f "$src/configure" + test -f "$src/msvcc.sh" + test -f "$src/ltmain.sh" + test -f "$src/compile" + test -f "$src/missing" + test -f "$src/install-sh" + test -f "$src/config.guess" + test -f "$src/config.sub" + '@ + + - name: Inspect build tools + shell: pwsh + run: | + where.exe cl + where.exe link + where.exe ml64 + where.exe bash + + $Make = Get-Command make -ErrorAction SilentlyContinue + if (!$Make) { + throw "GNU make is unavailable on this runner" + } + + where.exe make + + - name: Configure and build libffi + shell: pwsh + run: | + & "C:\Program Files\Git\bin\bash.exe" -lc @' + set -eux + + src="$(cygpath -u "$LIBFFI_SRC")" + build="$(cygpath -u "$LIBFFI_BUILD")" + install="$(cygpath -u "$LIBFFI_INSTALL")" + + cd "$build" + + "$src/configure" \ + CC="$src/msvcc.sh -m64" \ + CXX="$src/msvcc.sh -m64" \ + LD=link \ + CPP="cl -nologo -EP" \ + CXXCPP="cl -nologo -EP" \ + CPPFLAGS="-DFFI_BUILDING_DLL" \ + --disable-docs \ + --prefix="$install" + + make V=1 + make install + '@ + + - name: Verify installation + shell: pwsh + run: | + Get-ChildItem $env:LIBFFI_INSTALL -Recurse + + $Header = Get-ChildItem ` + $env:LIBFFI_INSTALL -Recurse -Filter ffi.h | + Select-Object -First 1 + + $Library = Get-ChildItem ` + $env:LIBFFI_INSTALL -Recurse -Filter *.lib | + Where-Object Name -Match '^libffi' | + Select-Object -First 1 + + if (!$Header) { + throw "ffi.h was not installed" + } + + if (!$Library) { + throw "No libffi MSVC library was installed" + } + + Write-Host "Header: $($Header.FullName)" + Write-Host "Library: $($Library.FullName)" + dumpbin /headers $Library.FullName + + - name: Upload investigation results + if: always() + uses: actions/upload-artifact@v4 + with: + name: libffi-msvc-investigation + path: | + ${{ runner.temp }}/libffi-build/config.log + ${{ runner.temp }}/libffi-install \ No newline at end of file From c618cc2de6e0225a34a217806d203ca8c71ff15a Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:00:36 +0500 Subject: [PATCH 17/43] Make some changes in test file --- .../workflows/libffi-msvc-investigation.yml | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index aeb442b88..0bf39fa49 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -102,12 +102,16 @@ shell: pwsh run: | & "C:\Program Files\Git\bin\bash.exe" -lc @' - set -eux + set -euxo pipefail src="$(cygpath -u "$LIBFFI_SRC")" build="$(cygpath -u "$LIBFFI_BUILD")" install="$(cygpath -u "$LIBFFI_INSTALL")" + # The release archive already contains generated Autotools files. + # Avoid timestamp rounding on Windows triggering their regeneration. + find "$src" -name Makefile.in -exec touch {} + + cd "$build" "$src/configure" \ @@ -120,10 +124,27 @@ --disable-docs \ --prefix="$install" - make V=1 - make install + make V=1 \ + SHELL=/bin/sh \ + AUTOMAKE=true \ + ACLOCAL=true \ + AUTOCONF=true \ + AUTOHEADER=true + + make install \ + SHELL=/bin/sh \ + AUTOMAKE=true \ + ACLOCAL=true \ + AUTOCONF=true \ + AUTOHEADER=true + + find "$install" -maxdepth 4 -type f -print '@ + if ($LASTEXITCODE -ne 0) { + throw "libffi build/install failed with exit code $LASTEXITCODE" + } + - name: Verify installation shell: pwsh run: | @@ -157,4 +178,4 @@ name: libffi-msvc-investigation path: | ${{ runner.temp }}/libffi-build/config.log - ${{ runner.temp }}/libffi-install \ No newline at end of file + ${{ runner.temp }}/libffi-install From 1eb03515ff90fcdcec1c23cce182b5b79d64cc7c Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:06:18 +0500 Subject: [PATCH 18/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 0bf39fa49..abd390f37 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -114,7 +114,7 @@ cd "$build" - "$src/configure" \ + CONFIG_SHELL=/bin/sh "$src/configure" \ CC="$src/msvcc.sh -m64" \ CXX="$src/msvcc.sh -m64" \ LD=link \ @@ -124,6 +124,11 @@ --disable-docs \ --prefix="$install" + # Keep Make from re-running config.status due to equal/coarse + # timestamps on the Windows filesystem. + touch "$build/config.status" + find "$build" -name Makefile -exec touch {} + + make V=1 \ SHELL=/bin/sh \ AUTOMAKE=true \ From 9ddb78f7d7cd808f1175288b343322b1898b6c8b Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:12:02 +0500 Subject: [PATCH 19/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index abd390f37..431b8e413 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -124,19 +124,16 @@ --disable-docs \ --prefix="$install" - # Keep Make from re-running config.status due to equal/coarse - # timestamps on the Windows filesystem. - touch "$build/config.status" - find "$build" -name Makefile -exec touch {} + - - make V=1 \ + # Do not remake the configure-generated Makefile. The Windows + # filesystem can report its prerequisites as newer after extraction. + make --old-file=Makefile V=1 \ SHELL=/bin/sh \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ AUTOHEADER=true - make install \ + make --old-file=Makefile install \ SHELL=/bin/sh \ AUTOMAKE=true \ ACLOCAL=true \ From f7c4a0d75a1ebce74c4500780a69772ef56cb8d7 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:17:34 +0500 Subject: [PATCH 20/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 431b8e413..3345e5583 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -114,7 +114,7 @@ cd "$build" - CONFIG_SHELL=/bin/sh "$src/configure" \ + SHELL=/bin/sh CONFIG_SHELL=/bin/sh "$src/configure" \ CC="$src/msvcc.sh -m64" \ CXX="$src/msvcc.sh -m64" \ LD=link \ @@ -124,17 +124,17 @@ --disable-docs \ --prefix="$install" + grep '^SHELL = /bin/sh$' Makefile + # Do not remake the configure-generated Makefile. The Windows # filesystem can report its prerequisites as newer after extraction. make --old-file=Makefile V=1 \ - SHELL=/bin/sh \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ AUTOHEADER=true make --old-file=Makefile install \ - SHELL=/bin/sh \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ From a2430772d7bd63a556c087533c41c63666665e6b Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:26:41 +0500 Subject: [PATCH 21/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 3345e5583..a361275b5 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -126,6 +126,11 @@ grep '^SHELL = /bin/sh$' Makefile + # GNU Make on Windows expands $(SHELL) to Git's installation path, + # which contains spaces and is not quoted by generated recipes. + find "$build" -name Makefile -exec \ + sed -i 's|$(SHELL) ./config.status|/bin/sh ./config.status|g' {} + + # Do not remake the configure-generated Makefile. The Windows # filesystem can report its prerequisites as newer after extraction. make --old-file=Makefile V=1 \ From 35f6d9241c021b357334307717287525d3f19e4e Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:32:37 +0500 Subject: [PATCH 22/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index a361275b5..f9831cb82 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -127,9 +127,16 @@ grep '^SHELL = /bin/sh$' Makefile # GNU Make on Windows expands $(SHELL) to Git's installation path, - # which contains spaces and is not quoted by generated recipes. + # which contains spaces. Keep nested Make invocations from trying + # to regenerate the verified release files. find "$build" -name Makefile -exec \ - sed -i 's|$(SHELL) ./config.status|/bin/sh ./config.status|g' {} + + sed -i \ + -e 's|$(SHELL)|/bin/sh|g' \ + -e 's|^AUTOMAKE =.*|AUTOMAKE = true|' \ + -e 's|^ACLOCAL =.*|ACLOCAL = true|' \ + -e 's|^AUTOCONF =.*|AUTOCONF = true|' \ + -e 's|^AUTOHEADER =.*|AUTOHEADER = true|' \ + {} + # Do not remake the configure-generated Makefile. The Windows # filesystem can report its prerequisites as newer after extraction. From 3b2be709bef9dac6e280c47566cbbee5a028b90f Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:40:59 +0500 Subject: [PATCH 23/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index f9831cb82..682ef7fab 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -138,15 +138,17 @@ -e 's|^AUTOHEADER =.*|AUTOHEADER = true|' \ {} + - # Do not remake the configure-generated Makefile. The Windows - # filesystem can report its prerequisites as newer after extraction. - make --old-file=Makefile V=1 \ + # Apply the no-regeneration policy to this Make process and every + # recursive Make process it starts. + export MAKEFLAGS="--old-file=Makefile --old-file=config.status --old-file=fficonfig.h --old-file=stamp-h1" + + make V=1 \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ AUTOHEADER=true - make --old-file=Makefile install \ + make install \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ From ba763c0314a16d30b0575a88a8431e8876f5c29b Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:47:50 +0500 Subject: [PATCH 24/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 682ef7fab..785c51dbb 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -127,8 +127,7 @@ grep '^SHELL = /bin/sh$' Makefile # GNU Make on Windows expands $(SHELL) to Git's installation path, - # which contains spaces. Keep nested Make invocations from trying - # to regenerate the verified release files. + # which contains spaces. find "$build" -name Makefile -exec \ sed -i \ -e 's|$(SHELL)|/bin/sh|g' \ @@ -138,9 +137,15 @@ -e 's|^AUTOHEADER =.*|AUTOHEADER = true|' \ {} + - # Apply the no-regeneration policy to this Make process and every - # recursive Make process it starts. - export MAKEFLAGS="--old-file=Makefile --old-file=config.status --old-file=fficonfig.h --old-file=stamp-h1" + # Configure detects two-second timestamp resolution on this runner. + # Establish an unambiguous order so Make does not regenerate the + # release archive's Autotools files or the configured build files. + sleep 3 + find "$src" -name Makefile.in -exec touch {} + + touch "$src/fficonfig.h.in" + sleep 3 + find "$build" -name Makefile -exec touch {} + + touch config.status fficonfig.h stamp-h1 make V=1 \ AUTOMAKE=true \ From d6e00225b694ce06f3fba255497d56cfb4b8db73 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 06:54:37 +0500 Subject: [PATCH 25/43] Make some changes in test file --- .../workflows/libffi-msvc-investigation.yml | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 785c51dbb..35a746009 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -137,23 +137,34 @@ -e 's|^AUTOHEADER =.*|AUTOHEADER = true|' \ {} + - # Configure detects two-second timestamp resolution on this runner. - # Establish an unambiguous order so Make does not regenerate the - # release archive's Autotools files or the configured build files. - sleep 3 - find "$src" -name Makefile.in -exec touch {} + - touch "$src/fficonfig.h.in" - sleep 3 - find "$build" -name Makefile -exec touch {} + - touch config.status fficonfig.h stamp-h1 + # Make names source-tree regeneration targets with absolute paths. + # Suppress each exact generated target; these options are inherited + # by recursive Make invocations through MAKEFLAGS. + make_old_files=( + "--old-file=$src/configure" + "--old-file=$src/aclocal.m4" + "--old-file=$src/fficonfig.h.in" + "--old-file=$build/config.status" + "--old-file=$build/fficonfig.h" + "--old-file=$build/stamp-h1" + "--old-file=Makefile" + "--old-file=config.status" + "--old-file=fficonfig.h" + "--old-file=stamp-h1" + ) + + while IFS= read -r generated_file; do + make_old_files+=("--old-file=$generated_file") + done < <(find "$src" "$build" \ + \( -name Makefile.in -o -name Makefile \) -print) - make V=1 \ + make "${make_old_files[@]}" V=1 \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ AUTOHEADER=true - make install \ + make "${make_old_files[@]}" install \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ From c73186583cb47db59f2ad25f18844bc561e54752 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 07:02:46 +0500 Subject: [PATCH 26/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 35a746009..8def457b8 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -111,6 +111,8 @@ # The release archive already contains generated Autotools files. # Avoid timestamp rounding on Windows triggering their regeneration. find "$src" -name Makefile.in -exec touch {} + + touch "$src/fficonfig.h.in" + sleep 3 cd "$build" @@ -159,12 +161,16 @@ \( -name Makefile.in -o -name Makefile \) -print) make "${make_old_files[@]}" V=1 \ + SHELL=/bin/sh \ + CONFIG_SHELL=/bin/sh \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ AUTOHEADER=true make "${make_old_files[@]}" install \ + SHELL=/bin/sh \ + CONFIG_SHELL=/bin/sh \ AUTOMAKE=true \ ACLOCAL=true \ AUTOCONF=true \ From e43852f0fdad77bc15a7943c13ec119edffdaa84 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 07:12:13 +0500 Subject: [PATCH 27/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 8def457b8..b0f622390 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -130,7 +130,8 @@ # GNU Make on Windows expands $(SHELL) to Git's installation path, # which contains spaces. - find "$build" -name Makefile -exec \ + find "$src" "$build" \ + \( -name Makefile.in -o -name Makefile \) -exec \ sed -i \ -e 's|$(SHELL)|/bin/sh|g' \ -e 's|^AUTOMAKE =.*|AUTOMAKE = true|' \ From 48560c6817b9484b9117b65dc61e2ba7699528ab Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 09:21:00 +0500 Subject: [PATCH 28/43] Make some changes in test file --- .../workflows/libffi-msvc-investigation.yml | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index b0f622390..eb5a0158a 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -140,28 +140,22 @@ -e 's|^AUTOHEADER =.*|AUTOHEADER = true|' \ {} + - # Make names source-tree regeneration targets with absolute paths. - # Suppress each exact generated target; these options are inherited - # by recursive Make invocations through MAKEFLAGS. - make_old_files=( - "--old-file=$src/configure" - "--old-file=$src/aclocal.m4" - "--old-file=$src/fficonfig.h.in" - "--old-file=$build/config.status" - "--old-file=$build/fficonfig.h" - "--old-file=$build/stamp-h1" - "--old-file=Makefile" - "--old-file=config.status" - "--old-file=fficonfig.h" - "--old-file=stamp-h1" - ) - - while IFS= read -r generated_file; do - make_old_files+=("--old-file=$generated_file") - done < <(find "$src" "$build" \ - \( -name Makefile.in -o -name Makefile \) -print) - - make "${make_old_files[@]}" V=1 \ + # Place Autotools inputs in the future and generated outputs one + # hour beyond them. This exceeds the filesystem's two-second + # resolution and prevents Makefile/config.status regeneration. + source_guard="$(date -u -d '+1 hour' '+%Y-%m-%d %H:%M:%S UTC')" + build_guard="$(date -u -d '+2 hours' '+%Y-%m-%d %H:%M:%S UTC')" + find "$src" \ + \( -name Makefile.am -o -name Makefile.in \ + -o -name configure -o -name configure.ac \ + -o -name '*.m4' -o -name fficonfig.h.in \) \ + -exec touch -d "$source_guard" {} + + find "$build" \ + \( -name Makefile -o -name config.status \ + -o -name fficonfig.h -o -name stamp-h1 \) \ + -exec touch -d "$build_guard" {} + + + make V=1 \ SHELL=/bin/sh \ CONFIG_SHELL=/bin/sh \ AUTOMAKE=true \ @@ -169,7 +163,7 @@ AUTOCONF=true \ AUTOHEADER=true - make "${make_old_files[@]}" install \ + make install \ SHELL=/bin/sh \ CONFIG_SHELL=/bin/sh \ AUTOMAKE=true \ From 6f0ab36690fd83d48ac09c7d38eb4631fc2a864d Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 09:26:27 +0500 Subject: [PATCH 29/43] Make some changes in test file --- .../workflows/libffi-msvc-investigation.yml | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index eb5a0158a..7ee991fc8 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -138,22 +138,21 @@ -e 's|^ACLOCAL =.*|ACLOCAL = true|' \ -e 's|^AUTOCONF =.*|AUTOCONF = true|' \ -e 's|^AUTOHEADER =.*|AUTOHEADER = true|' \ + -e 's|^\($(srcdir)/Makefile\.in\):.*|\1:|' \ + -e 's|^\($(top_srcdir)/configure\):.*|\1:|' \ + -e 's|^\($(ACLOCAL_M4)\):.*|\1:|' \ + -e 's|^\($(top_srcdir)/fficonfig\.h\.in\):.*|\1:|' \ + -e 's|^\(config\.status\):.*|\1:|' \ + -e 's|^\(Makefile\):.*|\1:|' \ + -e 's|^\(stamp-h1\):.*|\1:|' \ {} + - # Place Autotools inputs in the future and generated outputs one - # hour beyond them. This exceeds the filesystem's two-second - # resolution and prevents Makefile/config.status regeneration. - source_guard="$(date -u -d '+1 hour' '+%Y-%m-%d %H:%M:%S UTC')" - build_guard="$(date -u -d '+2 hours' '+%Y-%m-%d %H:%M:%S UTC')" - find "$src" \ - \( -name Makefile.am -o -name Makefile.in \ - -o -name configure -o -name configure.ac \ - -o -name '*.m4' -o -name fficonfig.h.in \) \ - -exec touch -d "$source_guard" {} + - find "$build" \ - \( -name Makefile -o -name config.status \ - -o -name fficonfig.h -o -name stamp-h1 \) \ - -exec touch -d "$build_guard" {} + + # Verify that the top-level generated-file rules have no + # prerequisites and therefore cannot start a remake/recheck loop. + grep -F '$(srcdir)/Makefile.in:' Makefile + grep '^config.status:$' Makefile + grep '^Makefile:$' Makefile + grep '^stamp-h1:$' Makefile make V=1 \ SHELL=/bin/sh \ From c1a40325d07931926befb6583bbd501e3491c32d Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 09:30:22 +0500 Subject: [PATCH 30/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 7ee991fc8..6efca0190 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -143,16 +143,18 @@ -e 's|^\($(ACLOCAL_M4)\):.*|\1:|' \ -e 's|^\($(top_srcdir)/fficonfig\.h\.in\):.*|\1:|' \ -e 's|^\(config\.status\):.*|\1:|' \ + -e 's|^\($(top_builddir)/config\.status\):.*|\1:|' \ -e 's|^\(Makefile\):.*|\1:|' \ -e 's|^\(stamp-h1\):.*|\1:|' \ + -e 's|^\($(top_builddir)/stamp-h1\):.*|\1:|' \ {} + # Verify that the top-level generated-file rules have no # prerequisites and therefore cannot start a remake/recheck loop. grep -F '$(srcdir)/Makefile.in:' Makefile - grep '^config.status:$' Makefile + grep -E '^(\$\(top_builddir\)/)?config\.status:$' Makefile grep '^Makefile:$' Makefile - grep '^stamp-h1:$' Makefile + grep -E '^(\$\(top_builddir\)/)?stamp-h1:$' Makefile make V=1 \ SHELL=/bin/sh \ From 2c353eb7498b5acc319a43a612155698ac922838 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 09:35:24 +0500 Subject: [PATCH 31/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 6efca0190..3e99d1ef2 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -6,6 +6,7 @@ jobs: build-libffi: runs-on: windows-2022 + timeout-minutes: 30 steps: - name: Activate MSVC @@ -142,19 +143,17 @@ -e 's|^\($(top_srcdir)/configure\):.*|\1:|' \ -e 's|^\($(ACLOCAL_M4)\):.*|\1:|' \ -e 's|^\($(top_srcdir)/fficonfig\.h\.in\):.*|\1:|' \ - -e 's|^\(config\.status\):.*|\1:|' \ - -e 's|^\($(top_builddir)/config\.status\):.*|\1:|' \ + -e 's|^\([^:#]*config\.status\):.*|\1:|' \ -e 's|^\(Makefile\):.*|\1:|' \ - -e 's|^\(stamp-h1\):.*|\1:|' \ - -e 's|^\($(top_builddir)/stamp-h1\):.*|\1:|' \ + -e 's|^\([^:#]*stamp-h1\):.*|\1:|' \ {} + # Verify that the top-level generated-file rules have no # prerequisites and therefore cannot start a remake/recheck loop. grep -F '$(srcdir)/Makefile.in:' Makefile - grep -E '^(\$\(top_builddir\)/)?config\.status:$' Makefile + grep -E 'config\.status:$' Makefile grep '^Makefile:$' Makefile - grep -E '^(\$\(top_builddir\)/)?stamp-h1:$' Makefile + grep -E 'stamp-h1:$' Makefile make V=1 \ SHELL=/bin/sh \ @@ -164,7 +163,7 @@ AUTOCONF=true \ AUTOHEADER=true - make install \ + make V=1 install \ SHELL=/bin/sh \ CONFIG_SHELL=/bin/sh \ AUTOMAKE=true \ @@ -212,4 +211,8 @@ name: libffi-msvc-investigation path: | ${{ runner.temp }}/libffi-build/config.log + ${{ runner.temp }}/libffi-build/config.status + ${{ runner.temp }}/libffi-build/Makefile + ${{ runner.temp }}/libffi-build/fficonfig.h + ${{ runner.temp }}/libffi-build/libtool ${{ runner.temp }}/libffi-install From 688c56eb3530db2a129022ee858e92b3a1efe83c Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 09:49:52 +0500 Subject: [PATCH 32/43] Fix libffi header template setup --- .github/workflows/libffi-msvc-investigation.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 3e99d1ef2..86d61e29f 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -44,7 +44,8 @@ "missing", "install-sh", "config.guess", - "config.sub" + "config.sub", + "include\ffi.h.in" ) foreach ($File in $Required) { @@ -113,6 +114,7 @@ # Avoid timestamp rounding on Windows triggering their regeneration. find "$src" -name Makefile.in -exec touch {} + touch "$src/fficonfig.h.in" + cp "$src/include/ffi.h.in" "$build/ffi.h.in.dist" sleep 3 cd "$build" @@ -127,6 +129,12 @@ --disable-docs \ --prefix="$install" + # Preserve the distributed public-header template. Some Windows + # configure combinations lose it while setting up the build tree. + cp "$build/ffi.h.in.dist" "$src/include/ffi.h.in" + touch "$build/include/ffi.h" + test -f "$src/include/ffi.h.in" + grep '^SHELL = /bin/sh$' Makefile # GNU Make on Windows expands $(SHELL) to Git's installation path, From 2e335a342a317ebf7c30c67a503c2dd200fe88a6 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 09:54:24 +0500 Subject: [PATCH 33/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 86d61e29f..ca0e21af4 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -109,6 +109,7 @@ src="$(cygpath -u "$LIBFFI_SRC")" build="$(cygpath -u "$LIBFFI_BUILD")" install="$(cygpath -u "$LIBFFI_INSTALL")" + src_native="$(cygpath -m "$LIBFFI_SRC")" # The release archive already contains generated Autotools files. # Avoid timestamp rounding on Windows triggering their regeneration. @@ -156,6 +157,11 @@ -e 's|^\([^:#]*stamp-h1\):.*|\1:|' \ {} + + # Configure requires MSYS paths, while the native MinGW Make + # executable performs dependency checks using Windows paths. + find "$build" -name Makefile -exec \ + sed -i "s|$src|$src_native|g" {} + + # Verify that the top-level generated-file rules have no # prerequisites and therefore cannot start a remake/recheck loop. grep -F '$(srcdir)/Makefile.in:' Makefile From e5a119a8dc323a2bf15597fd4e1f90e3261cd254 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 09:58:15 +0500 Subject: [PATCH 34/43] Make some changes in test file --- .github/workflows/libffi-msvc-investigation.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index ca0e21af4..47df19d78 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -115,7 +115,6 @@ # Avoid timestamp rounding on Windows triggering their regeneration. find "$src" -name Makefile.in -exec touch {} + touch "$src/fficonfig.h.in" - cp "$src/include/ffi.h.in" "$build/ffi.h.in.dist" sleep 3 cd "$build" @@ -126,14 +125,11 @@ LD=link \ CPP="cl -nologo -EP" \ CXXCPP="cl -nologo -EP" \ - CPPFLAGS="-DFFI_BUILDING_DLL" \ --disable-docs \ + --disable-shared \ + --enable-static \ --prefix="$install" - # Preserve the distributed public-header template. Some Windows - # configure combinations lose it while setting up the build tree. - cp "$build/ffi.h.in.dist" "$src/include/ffi.h.in" - touch "$build/include/ffi.h" test -f "$src/include/ffi.h.in" grep '^SHELL = /bin/sh$' Makefile From 9c1f10c299c53ab014cbe7558ea684811f816279 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 10:02:56 +0500 Subject: [PATCH 35/43] Define static linkage for libffi MSVC build --- .github/workflows/libffi-msvc-investigation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml index 47df19d78..b22259404 100644 --- a/.github/workflows/libffi-msvc-investigation.yml +++ b/.github/workflows/libffi-msvc-investigation.yml @@ -125,6 +125,7 @@ LD=link \ CPP="cl -nologo -EP" \ CXXCPP="cl -nologo -EP" \ + CPPFLAGS="-DFFI_STATIC_BUILD" \ --disable-docs \ --disable-shared \ --enable-static \ From f2b85d1de78a5f7e70ca49b87dc569507aaaf59b Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 10:19:19 +0500 Subject: [PATCH 36/43] Fix Windows C loader libffi static build --- source/loaders/c_loader/CMakeLists.txt | 1 + tools/metacall-environment.ps1 | 150 ++++++++++++++++++++++--- 2 files changed, 136 insertions(+), 15 deletions(-) diff --git a/source/loaders/c_loader/CMakeLists.txt b/source/loaders/c_loader/CMakeLists.txt index 503e01059..fa802e6ee 100644 --- a/source/loaders/c_loader/CMakeLists.txt +++ b/source/loaders/c_loader/CMakeLists.txt @@ -171,6 +171,7 @@ target_link_libraries(${target} target_compile_definitions(${target} PRIVATE + $<$:FFI_STATIC_BUILD> PUBLIC $<$>:${target_upper}_STATIC_DEFINE> diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1 index 933862e01..2484bf34f 100755 --- a/tools/metacall-environment.ps1 +++ b/tools/metacall-environment.ps1 @@ -251,57 +251,176 @@ function Set-C { Set-Location $ROOT_DIR $LibFFIVersion = "3.5.2" + $LibFFISha256 = "f3a3082a23b37c293a4fcd1053147b371f2ff91fa7ea1b2a52e335676bac82dc" $LLVMVersion = "19.1.0" $DepsDir = "$ROOT_DIR\dependencies" $RuntimeDir = "$DepsDir\libffi" + $Archive = "$DepsDir\libffi.tar.gz" + $SrcDir = "$DepsDir\libffi-$LibFFIVersion" + $BuildDir = "$RuntimeDir\build" $DistDir = "$RuntimeDir\dist" mkdir -Force $DepsDir mkdir -Force $RuntimeDir - mkdir -Force $DistDir Set-Location $DepsDir # Download official libffi source tarball - if (!(Test-Path -Path "$DepsDir\libffi.tar.gz")) { + if (!(Test-Path -Path $Archive)) { Write-Output "libffi not found, downloading..." (New-Object Net.WebClient).DownloadFile( "https://github.com/libffi/libffi/releases/download/v$LibFFIVersion/libffi-$LibFFIVersion.tar.gz", - "$DepsDir\libffi.tar.gz" + $Archive ) } - cmake -E tar xzf "$DepsDir\libffi.tar.gz" + $LibFFIArchiveHash = (Get-FileHash -Path $Archive -Algorithm SHA256).Hash.ToLower() + if ($LibFFIArchiveHash -ne $LibFFISha256) { + throw "libffi archive checksum mismatch: expected $LibFFISha256, got $LibFFIArchiveHash." + } + + # Always configure from clean generated directories. This prevents a + # previous shared or failed build from contaminating the static build. + foreach ($GeneratedDir in @($SrcDir, $BuildDir, $DistDir)) { + if (Test-Path -Path $GeneratedDir) { + Remove-Item -Path $GeneratedDir -Recurse -Force + } + } + + cmake -E tar xzf $Archive + if ($LASTEXITCODE -ne 0) { + throw "Failed to extract libffi (exit code $LASTEXITCODE)." + } - $SrcDir = "$DepsDir\libffi-$LibFFIVersion" - $BuildDir = "$RuntimeDir\build" mkdir -Force $BuildDir + mkdir -Force $DistDir $GitBash = "C:\Program Files\Git\bin\bash.exe" - $DistDirUnix = $DistDir.Replace('\', '/') - $BuildDirUnix = $BuildDir.Replace('\', '/') - $SrcDirUnix = $SrcDir.Replace('\', '/') - $MsvccSh = "$SrcDirUnix/msvcc.sh" if (!(Test-Path -Path $GitBash)) { throw "Git Bash is required to build libffi but was not found at '$GitBash'." } - if (!(Test-Path -Path "$SrcDir\configure") -or !(Test-Path -Path "$SrcDir\msvcc.sh")) { - throw "The libffi source archive did not extract the required configure and msvcc.sh files." + $LibFFIRequiredFiles = @( + "configure", + "msvcc.sh", + "ltmain.sh", + "compile", + "missing", + "install-sh", + "config.guess", + "config.sub", + "include\ffi.h.in" + ) + + foreach ($RequiredFile in $LibFFIRequiredFiles) { + if (!(Test-Path -Path "$SrcDir\$RequiredFile")) { + throw "The libffi source archive is missing '$RequiredFile'." + } + } + + foreach ($RequiredCommand in @("cl.exe", "link.exe", "lib.exe", "ml64.exe", "make.exe")) { + if ($null -eq (Get-Command $RequiredCommand -ErrorAction SilentlyContinue)) { + throw "The required libffi build tool '$RequiredCommand' is not available in PATH." + } } - & $GitBash -c "cd '$BuildDirUnix' && '$SrcDirUnix/configure' CC='$MsvccSh -m64' CXX='$MsvccSh -m64' LD=link CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' --prefix='$DistDirUnix' && make && make install" + $env:LIBFFI_SRC = $SrcDir + $env:LIBFFI_BUILD = $BuildDir + $env:LIBFFI_INSTALL = $DistDir + + $LibFFIBuildScript = @' + set -euxo pipefail + + src="$(cygpath -u "$LIBFFI_SRC")" + build="$(cygpath -u "$LIBFFI_BUILD")" + install="$(cygpath -u "$LIBFFI_INSTALL")" + src_native="$(cygpath -m "$LIBFFI_SRC")" + + # The release archive already contains generated Autotools files. Avoid + # timestamp rounding on Windows triggering their regeneration. + find "$src" -name Makefile.in -exec touch {} + + touch "$src/fficonfig.h.in" + sleep 3 + + cd "$build" + + SHELL=/bin/sh CONFIG_SHELL=/bin/sh "$src/configure" \ + CC="$src/msvcc.sh -m64" \ + CXX="$src/msvcc.sh -m64" \ + LD=link \ + CPP="cl -nologo -EP" \ + CXXCPP="cl -nologo -EP" \ + CPPFLAGS="-DFFI_STATIC_BUILD" \ + --disable-docs \ + --disable-shared \ + --enable-static \ + --prefix="$install" + + test -f "$src/include/ffi.h.in" + grep '^SHELL = /bin/sh$' Makefile + + # GNU Make on Windows expands $(SHELL) to Git's installation path, which + # contains spaces. The source archive's generated rules must also remain + # inert so Make cannot launch an Autotools regeneration/recheck loop. + find "$src" "$build" \ + \( -name Makefile.in -o -name Makefile \) -exec \ + sed -i \ + -e 's|$(SHELL)|/bin/sh|g' \ + -e 's|^AUTOMAKE =.*|AUTOMAKE = true|' \ + -e 's|^ACLOCAL =.*|ACLOCAL = true|' \ + -e 's|^AUTOCONF =.*|AUTOCONF = true|' \ + -e 's|^AUTOHEADER =.*|AUTOHEADER = true|' \ + -e 's|^\($(srcdir)/Makefile\.in\):.*|\1:|' \ + -e 's|^\($(top_srcdir)/configure\):.*|\1:|' \ + -e 's|^\($(ACLOCAL_M4)\):.*|\1:|' \ + -e 's|^\($(top_srcdir)/fficonfig\.h\.in\):.*|\1:|' \ + -e 's|^\([^:#]*config\.status\):.*|\1:|' \ + -e 's|^\(Makefile\):.*|\1:|' \ + -e 's|^\([^:#]*stamp-h1\):.*|\1:|' \ + {} + + + # Configure requires MSYS paths, while the native MinGW Make executable + # performs dependency checks using Windows paths. + find "$build" -name Makefile -exec \ + sed -i "s|$src|$src_native|g" {} + + + grep -F '$(srcdir)/Makefile.in:' Makefile + grep -E 'config\.status:$' Makefile + grep '^Makefile:$' Makefile + grep -E 'stamp-h1:$' Makefile + + make V=1 \ + SHELL=/bin/sh \ + CONFIG_SHELL=/bin/sh \ + AUTOMAKE=true \ + ACLOCAL=true \ + AUTOCONF=true \ + AUTOHEADER=true + + make V=1 install \ + SHELL=/bin/sh \ + CONFIG_SHELL=/bin/sh \ + AUTOMAKE=true \ + ACLOCAL=true \ + AUTOCONF=true \ + AUTOHEADER=true + + find "$install" -maxdepth 4 -type f -print +'@ + + & $GitBash -lc $LibFFIBuildScript if ($LASTEXITCODE -ne 0) { throw "Failed to configure, build, or install libffi (exit code $LASTEXITCODE)." } $LibFFIHeader = Get-ChildItem -Path $DistDir -Filter "ffi.h" -File -Recurse | Select-Object -First 1 + $LibFFITargetHeader = Get-ChildItem -Path $DistDir -Filter "ffitarget.h" -File -Recurse | Select-Object -First 1 $LibFFILibrary = Get-ChildItem -Path $DistDir -Filter "*.lib" -File -Recurse | Where-Object { $_.Name -match '^libffi' } | Select-Object -First 1 - if (($null -eq $LibFFIHeader) -or ($null -eq $LibFFILibrary)) { - throw "libffi installation is incomplete: expected ffi.h and an MSVC libffi .lib file under '$DistDir'." + if (($null -eq $LibFFIHeader) -or ($null -eq $LibFFITargetHeader) -or ($null -eq $LibFFILibrary)) { + throw "libffi installation is incomplete: expected ffi.h, ffitarget.h, and an MSVC libffi .lib file under '$DistDir'." } $EnvOpts = "$ROOT_DIR\build\CMakeConfig.txt" @@ -310,6 +429,7 @@ function Set-C { Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFIIncludeDir""" >> $EnvOpts Write-Output "-DLIBFFI_LIBRARY=""$LibFFILibraryPath""" >> $EnvOpts + Write-Output "-DLIBFFI_STATIC_BUILD=On" >> $EnvOpts # Download official LLVM prebuilt archive (includes libclang.lib + headers) # Using clang+llvm archive which contains libraries needed for development From 4649cd92d9c87809bf6f320e5de6dabeb2e9c356 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 10:31:05 +0500 Subject: [PATCH 37/43] Fix Windows environment setup failures --- tools/metacall-environment.ps1 | 54 ++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1 index 2484bf34f..7d3bc3c7e 100755 --- a/tools/metacall-environment.ps1 +++ b/tools/metacall-environment.ps1 @@ -134,17 +134,32 @@ function Set-Nodejs { if (!(Test-Path -Path "$DepsDir\libgit2")) { # Clone libgit2 git clone --depth 1 --branch v1.8.4 https://github.com/libgit2/libgit2 + if ($LASTEXITCODE -ne 0) { + throw "Failed to clone libgit2 (exit code $LASTEXITCODE)." + } } $InstallDir = "$DepsDir\libgit2\build\dist" + $LibGit2Config = "Debug" mkdir "$DepsDir\libgit2\build" mkdir "$InstallDir" Set-Location "$DepsDir\libgit2\build" - cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=OFF -DBUILD_CLI=OFF .. - cmake --build . "-j$((Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors)" - cmake --install . --prefix "$InstallDir" + cmake "-DCMAKE_BUILD_TYPE=$LibGit2Config" -DBUILD_TESTS=OFF -DBUILD_CLI=OFF .. + if ($LASTEXITCODE -ne 0) { + throw "Failed to configure libgit2 (exit code $LASTEXITCODE)." + } + + cmake --build . --config $LibGit2Config --parallel $((Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors) + if ($LASTEXITCODE -ne 0) { + throw "Failed to build libgit2 (exit code $LASTEXITCODE)." + } + + cmake --install . --config $LibGit2Config --prefix "$InstallDir" + if ($LASTEXITCODE -ne 0) { + throw "Failed to install libgit2 (exit code $LASTEXITCODE)." + } Write-Output "-DLibGit2_LIBRARY=""$InstallDir\lib\git2.lib""" >> $EnvOpts Write-Output "-DLibGit2_INCLUDE_DIR=""$InstallDir\include""" >> $EnvOpts @@ -168,7 +183,11 @@ function Set-Java { Expand-Archive -Path "openjdk.zip" -DestinationPath "$RuntimeDir" robocopy /move /e "$RuntimeDir\jdk-$JAVA_VERSION+8" "$RuntimeDir" /NFL /NDL /NJH /NJS /NC /NS /NP - Add-to-Path "JAVA_HOME=$RuntimeDir" + $Env:JAVA_HOME = $RuntimeDir + if ($Null -ne $Env:GITHUB_ENV) { + Write-Output "JAVA_HOME=$RuntimeDir" >> $Env:GITHUB_ENV + } + Add-to-Path "$RuntimeDir\bin" Add-to-Path "$RuntimeDir\bin\server" } @@ -274,7 +293,21 @@ function Set-C { ) } - $LibFFIArchiveHash = (Get-FileHash -Path $Archive -Algorithm SHA256).Hash.ToLower() + $LibFFIHashAlgorithm = [System.Security.Cryptography.SHA256]::Create() + try { + $LibFFIArchiveStream = [System.IO.File]::OpenRead($Archive) + try { + $LibFFIHashBytes = $LibFFIHashAlgorithm.ComputeHash($LibFFIArchiveStream) + $LibFFIArchiveHash = ([System.BitConverter]::ToString($LibFFIHashBytes)).Replace("-", "").ToLowerInvariant() + } + finally { + $LibFFIArchiveStream.Dispose() + } + } + finally { + $LibFFIHashAlgorithm.Dispose() + } + if ($LibFFIArchiveHash -ne $LibFFISha256) { throw "libffi archive checksum mismatch: expected $LibFFISha256, got $LibFFIArchiveHash." } @@ -458,16 +491,19 @@ function Add-to-Path { $GivenPath = $args[0] $NewPath = "$GivenPath;$Env:PATH" - setx /M PATH $NewPath $Env:PATH = $NewPath - $GivenPath >> $env:GITHUB_PATH + + if ($Null -ne $Env:GITHUB_PATH) { + $GivenPath >> $Env:GITHUB_PATH + } + else { + [Environment]::SetEnvironmentVariable("PATH", $NewPath, [EnvironmentVariableTarget]::Machine) + } if ($Null -ne $Env:GITHUB_ENV) { Write-Output "PATH=$Env:PATH" >> $Env:GITHUB_ENV } - refreshenv - Write-Output "PATH:: " $Env:PATH } From 1cf53e2b3365598dd975206f38eda05027473c29 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 11:08:14 +0500 Subject: [PATCH 38/43] Fix libffi Bash invocation on Windows --- tools/metacall-environment.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1 index 7d3bc3c7e..ee4481835 100755 --- a/tools/metacall-environment.ps1 +++ b/tools/metacall-environment.ps1 @@ -442,7 +442,11 @@ function Set-C { find "$install" -maxdepth 4 -type f -print '@ - & $GitBash -lc $LibFFIBuildScript + # Passing the program through bash -c causes PowerShell to reinterpret the + # nested quotes in the script. Execute an ASCII script file instead. + $LibFFIBuildScriptPath = "$BuildDir\\build-libffi.sh" + [System.IO.File]::WriteAllText($LibFFIBuildScriptPath, $LibFFIBuildScript, [System.Text.Encoding]::ASCII) + & $GitBash $LibFFIBuildScriptPath if ($LASTEXITCODE -ne 0) { throw "Failed to configure, build, or install libffi (exit code $LASTEXITCODE)." From be96a388d134f345ff7fdbb6994ce084d16e8239 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 11:22:05 +0500 Subject: [PATCH 39/43] Link c_loader with TinyCC import library on Windows --- cmake/InstallLibTCC.cmake | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index 306926425..dde1f7395 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -138,12 +138,15 @@ if(PROJECT_OS_FAMILY STREQUAL macos) set(LIBTTC_LIBRARY_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}tcc${CMAKE_STATIC_LIBRARY_SUFFIX}") elseif(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) set(LIBTTC_LIBRARY_NAME "libtcc.dll") + set(LIBTTC_LINK_LIBRARY_NAME "libtcc.lib") else() set(LIBTTC_LIBRARY_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}tcc${CMAKE_SHARED_LIBRARY_SUFFIX}") endif() set(LIBTTC_LIBRARY_PATH "${PROJECT_OUTPUT_DIR}/${LIBTTC_LIBRARY_NAME}") if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) set(LIBTTC_LIBRARY_SOURCE_PATH "${LIBTCC_INSTALL_PREFIX}/${LIBTTC_LIBRARY_NAME}") + set(LIBTTC_LINK_LIBRARY_PATH "${PROJECT_OUTPUT_DIR}/${LIBTTC_LINK_LIBRARY_NAME}") + set(LIBTTC_LINK_LIBRARY_SOURCE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${LIBTCC_TARGET}-prefix/src/${LIBTCC_TARGET}/win32/${LIBTTC_LINK_LIBRARY_NAME}") else() set(LIBTTC_LIBRARY_SOURCE_PATH "${LIBTCC_INSTALL_PREFIX}/lib/${LIBTTC_LIBRARY_NAME}") endif() @@ -160,6 +163,13 @@ set(LIBTTC_RUNTIME_FILES "${LIBTTC_RUNTIME_PATH}/bt-log.o" ) +set(LIBTCC_COPY_LINK_LIBRARY_COMMAND) +if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) + set(LIBTCC_COPY_LINK_LIBRARY_COMMAND + COMMAND ${CMAKE_COMMAND} -E copy "${LIBTTC_LINK_LIBRARY_SOURCE_PATH}" "${LIBTTC_LINK_LIBRARY_PATH}" + ) +endif() + # LibTCC Proejct ExternalProject_Add(${LIBTCC_TARGET} DOWNLOAD_NAME tinycc.tar.gz @@ -172,6 +182,7 @@ ExternalProject_Add(${LIBTCC_TARGET} UPDATE_COMMAND "" INSTALL_COMMAND ${LIBTCC_INSTALL} COMMAND ${CMAKE_COMMAND} -E copy "${LIBTTC_LIBRARY_SOURCE_PATH}" "${LIBTTC_LIBRARY_PATH}" + ${LIBTCC_COPY_LINK_LIBRARY_COMMAND} COMMAND ${CMAKE_COMMAND} -E copy ${LIBTTC_RUNTIME_FILES} "${PROJECT_OUTPUT_DIR}" ) @@ -205,7 +216,11 @@ if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) else() set(LIBTCC_INCLUDE_DIR "${LIBTCC_INSTALL_PREFIX}/include") endif() -set(LIBTCC_LIBRARY "${LIBTTC_LIBRARY_PATH}") +if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) + set(LIBTCC_LIBRARY "${LIBTTC_LINK_LIBRARY_PATH}") +else() + set(LIBTCC_LIBRARY "${LIBTTC_LIBRARY_PATH}") +endif() set(LIBTCC_FOUND TRUE) mark_as_advanced(LIBTCC_INCLUDE_DIR LIBTCC_LIBRARY) From 6ead5109102257ecd461a83452ebc978d5d47447 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 11:52:20 +0500 Subject: [PATCH 40/43] Fix failing tests --- cmake/InstallLibTCC.cmake | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake index dde1f7395..5ce114c0a 100644 --- a/cmake/InstallLibTCC.cmake +++ b/cmake/InstallLibTCC.cmake @@ -152,10 +152,11 @@ else() endif() if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) set(LIBTTC_RUNTIME_PATH "${LIBTCC_INSTALL_PREFIX}/lib") + set(LIBTTC_RUNTIME_INCLUDE_PATH "${LIBTCC_INSTALL_PREFIX}/include") else() set(LIBTTC_RUNTIME_PATH "${LIBTCC_INSTALL_PREFIX}/lib/tcc") + set(LIBTTC_RUNTIME_INCLUDE_PATH "${LIBTTC_RUNTIME_PATH}/include") endif() -set(LIBTTC_RUNTIME_INCLUDE_PATH "${LIBTTC_RUNTIME_PATH}/include") set(LIBTTC_RUNTIME_FILES "${LIBTTC_RUNTIME_PATH}/libtcc1.a" "${LIBTTC_RUNTIME_PATH}/bcheck.o" @@ -170,6 +171,17 @@ if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) ) endif() +if(PROJECT_OS_FAMILY STREQUAL win32 AND NOT PROJECT_OS_NAME STREQUAL MinGW) + set(LIBTCC_COPY_RUNTIME_FILES_COMMAND + COMMAND ${CMAKE_COMMAND} -E copy_directory "${LIBTTC_RUNTIME_INCLUDE_PATH}" "${PROJECT_OUTPUT_DIR}/include" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${LIBTTC_RUNTIME_PATH}" "${PROJECT_OUTPUT_DIR}/lib" + ) +else() + set(LIBTCC_COPY_RUNTIME_FILES_COMMAND + COMMAND ${CMAKE_COMMAND} -E copy ${LIBTTC_RUNTIME_FILES} "${PROJECT_OUTPUT_DIR}" + ) +endif() + # LibTCC Proejct ExternalProject_Add(${LIBTCC_TARGET} DOWNLOAD_NAME tinycc.tar.gz @@ -183,7 +195,7 @@ ExternalProject_Add(${LIBTCC_TARGET} INSTALL_COMMAND ${LIBTCC_INSTALL} COMMAND ${CMAKE_COMMAND} -E copy "${LIBTTC_LIBRARY_SOURCE_PATH}" "${LIBTTC_LIBRARY_PATH}" ${LIBTCC_COPY_LINK_LIBRARY_COMMAND} - COMMAND ${CMAKE_COMMAND} -E copy ${LIBTTC_RUNTIME_FILES} "${PROJECT_OUTPUT_DIR}" + ${LIBTCC_COPY_RUNTIME_FILES_COMMAND} ) # Install Library From be8be3422a2342e49c7af6eeabe3f0fb2f6f7679 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 12:29:58 +0500 Subject: [PATCH 41/43] Fix Windows TinyCC resolution of libffi symbols --- source/loaders/c_loader/source/c_loader_impl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/loaders/c_loader/source/c_loader_impl.cpp b/source/loaders/c_loader/source/c_loader_impl.cpp index 3f1401d3c..7f79d2d93 100644 --- a/source/loaders/c_loader/source/c_loader_impl.cpp +++ b/source/loaders/c_loader/source/c_loader_impl.cpp @@ -264,6 +264,11 @@ struct loader_impl_c_handle_tcc_type : T /* JIT the code into memory */ tcc_set_output_type(this->state, TCC_OUTPUT_MEMORY); + if (tcc_add_symbol(this->state, "ffi_call", reinterpret_cast(ffi_call)) != 0) + { + return false; + } + /* Register runtime path for TCC (in order to find libtcc1.a and runtime objects) */ if (!c_impl->libtcc_runtime_path.empty()) { @@ -284,6 +289,7 @@ struct loader_impl_c_handle_tcc_type : T #endif */ + // metacall-ai-generated /* Error handling */ tcc_set_error_func(this->state, nullptr, [](void *, const char *msg) { log_write("metacall", LOG_LEVEL_ERROR, "TCC Error: %s", msg); From 99557e206b63a03e391baff4dd45665499ed2225 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 13:05:56 +0500 Subject: [PATCH 42/43] Small Fix --- source/loaders/c_loader/source/c_loader_impl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/loaders/c_loader/source/c_loader_impl.cpp b/source/loaders/c_loader/source/c_loader_impl.cpp index 7f79d2d93..de89ead6c 100644 --- a/source/loaders/c_loader/source/c_loader_impl.cpp +++ b/source/loaders/c_loader/source/c_loader_impl.cpp @@ -289,7 +289,6 @@ struct loader_impl_c_handle_tcc_type : T #endif */ - // metacall-ai-generated /* Error handling */ tcc_set_error_func(this->state, nullptr, [](void *, const char *msg) { log_write("metacall", LOG_LEVEL_ERROR, "TCC Error: %s", msg); From 0641ce1698228b511de58ee3afce8b0e9298f910 Mon Sep 17 00:00:00 2001 From: shaheeramjad Date: Thu, 30 Jul 2026 13:08:18 +0500 Subject: [PATCH 43/43] Remove investigation workflow --- .../workflows/libffi-msvc-investigation.yml | 229 ------------------ 1 file changed, 229 deletions(-) delete mode 100644 .github/workflows/libffi-msvc-investigation.yml diff --git a/.github/workflows/libffi-msvc-investigation.yml b/.github/workflows/libffi-msvc-investigation.yml deleted file mode 100644 index b22259404..000000000 --- a/.github/workflows/libffi-msvc-investigation.yml +++ /dev/null @@ -1,229 +0,0 @@ - name: libffi MSVC investigation - - on: - workflow_dispatch: - - jobs: - build-libffi: - runs-on: windows-2022 - timeout-minutes: 30 - - steps: - - name: Activate MSVC - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: amd64 - - - name: Download and inspect libffi - shell: pwsh - run: | - $Version = "3.5.2" - $Archive = "$env:RUNNER_TEMP\libffi-$Version.tar.gz" - $Source = "$env:RUNNER_TEMP\libffi-$Version" - $Build = "$env:RUNNER_TEMP\libffi-build" - $Install = "$env:RUNNER_TEMP\libffi-install" - - Invoke-WebRequest ` - "https://github.com/libffi/libffi/releases/download/v$Version/libffi-$Version.tar.gz" ` - -OutFile $Archive - - $Expected = "f3a3082a23b37c293a4fcd1053147b371f2ff91fa7ea1b2a52e335676bac82dc" - $Actual = (Get-FileHash $Archive -Algorithm SHA256).Hash.ToLower() - - if ($Actual -ne $Expected) { - throw "Checksum mismatch: expected $Expected, got $Actual" - } - - tar -xzf $Archive -C $env:RUNNER_TEMP - - $Required = @( - "configure", - "msvcc.sh", - "ltmain.sh", - "compile", - "missing", - "install-sh", - "config.guess", - "config.sub", - "include\ffi.h.in" - ) - - foreach ($File in $Required) { - if (!(Test-Path "$Source\$File")) { - throw "Missing required file: $Source\$File" - } - } - - New-Item -ItemType Directory -Force $Build, $Install - - "LIBFFI_SRC=$Source" >> $env:GITHUB_ENV - "LIBFFI_BUILD=$Build" >> $env:GITHUB_ENV - "LIBFFI_INSTALL=$Install" >> $env:GITHUB_ENV - - - name: Inspect Windows and Git Bash paths - shell: pwsh - run: | - Write-Host "PowerShell source path: $env:LIBFFI_SRC" - - & "C:\Program Files\Git\bin\bash.exe" -lc @' - set -eux - - src="$(cygpath -u "$LIBFFI_SRC")" - build="$(cygpath -u "$LIBFFI_BUILD")" - install="$(cygpath -u "$LIBFFI_INSTALL")" - - printf "src=%s\nbuild=%s\ninstall=%s\n" \ - "$src" "$build" "$install" - - test -f "$src/configure" - test -f "$src/msvcc.sh" - test -f "$src/ltmain.sh" - test -f "$src/compile" - test -f "$src/missing" - test -f "$src/install-sh" - test -f "$src/config.guess" - test -f "$src/config.sub" - '@ - - - name: Inspect build tools - shell: pwsh - run: | - where.exe cl - where.exe link - where.exe ml64 - where.exe bash - - $Make = Get-Command make -ErrorAction SilentlyContinue - if (!$Make) { - throw "GNU make is unavailable on this runner" - } - - where.exe make - - - name: Configure and build libffi - shell: pwsh - run: | - & "C:\Program Files\Git\bin\bash.exe" -lc @' - set -euxo pipefail - - src="$(cygpath -u "$LIBFFI_SRC")" - build="$(cygpath -u "$LIBFFI_BUILD")" - install="$(cygpath -u "$LIBFFI_INSTALL")" - src_native="$(cygpath -m "$LIBFFI_SRC")" - - # The release archive already contains generated Autotools files. - # Avoid timestamp rounding on Windows triggering their regeneration. - find "$src" -name Makefile.in -exec touch {} + - touch "$src/fficonfig.h.in" - sleep 3 - - cd "$build" - - SHELL=/bin/sh CONFIG_SHELL=/bin/sh "$src/configure" \ - CC="$src/msvcc.sh -m64" \ - CXX="$src/msvcc.sh -m64" \ - LD=link \ - CPP="cl -nologo -EP" \ - CXXCPP="cl -nologo -EP" \ - CPPFLAGS="-DFFI_STATIC_BUILD" \ - --disable-docs \ - --disable-shared \ - --enable-static \ - --prefix="$install" - - test -f "$src/include/ffi.h.in" - - grep '^SHELL = /bin/sh$' Makefile - - # GNU Make on Windows expands $(SHELL) to Git's installation path, - # which contains spaces. - find "$src" "$build" \ - \( -name Makefile.in -o -name Makefile \) -exec \ - sed -i \ - -e 's|$(SHELL)|/bin/sh|g' \ - -e 's|^AUTOMAKE =.*|AUTOMAKE = true|' \ - -e 's|^ACLOCAL =.*|ACLOCAL = true|' \ - -e 's|^AUTOCONF =.*|AUTOCONF = true|' \ - -e 's|^AUTOHEADER =.*|AUTOHEADER = true|' \ - -e 's|^\($(srcdir)/Makefile\.in\):.*|\1:|' \ - -e 's|^\($(top_srcdir)/configure\):.*|\1:|' \ - -e 's|^\($(ACLOCAL_M4)\):.*|\1:|' \ - -e 's|^\($(top_srcdir)/fficonfig\.h\.in\):.*|\1:|' \ - -e 's|^\([^:#]*config\.status\):.*|\1:|' \ - -e 's|^\(Makefile\):.*|\1:|' \ - -e 's|^\([^:#]*stamp-h1\):.*|\1:|' \ - {} + - - # Configure requires MSYS paths, while the native MinGW Make - # executable performs dependency checks using Windows paths. - find "$build" -name Makefile -exec \ - sed -i "s|$src|$src_native|g" {} + - - # Verify that the top-level generated-file rules have no - # prerequisites and therefore cannot start a remake/recheck loop. - grep -F '$(srcdir)/Makefile.in:' Makefile - grep -E 'config\.status:$' Makefile - grep '^Makefile:$' Makefile - grep -E 'stamp-h1:$' Makefile - - make V=1 \ - SHELL=/bin/sh \ - CONFIG_SHELL=/bin/sh \ - AUTOMAKE=true \ - ACLOCAL=true \ - AUTOCONF=true \ - AUTOHEADER=true - - make V=1 install \ - SHELL=/bin/sh \ - CONFIG_SHELL=/bin/sh \ - AUTOMAKE=true \ - ACLOCAL=true \ - AUTOCONF=true \ - AUTOHEADER=true - - find "$install" -maxdepth 4 -type f -print - '@ - - if ($LASTEXITCODE -ne 0) { - throw "libffi build/install failed with exit code $LASTEXITCODE" - } - - - name: Verify installation - shell: pwsh - run: | - Get-ChildItem $env:LIBFFI_INSTALL -Recurse - - $Header = Get-ChildItem ` - $env:LIBFFI_INSTALL -Recurse -Filter ffi.h | - Select-Object -First 1 - - $Library = Get-ChildItem ` - $env:LIBFFI_INSTALL -Recurse -Filter *.lib | - Where-Object Name -Match '^libffi' | - Select-Object -First 1 - - if (!$Header) { - throw "ffi.h was not installed" - } - - if (!$Library) { - throw "No libffi MSVC library was installed" - } - - Write-Host "Header: $($Header.FullName)" - Write-Host "Library: $($Library.FullName)" - dumpbin /headers $Library.FullName - - - name: Upload investigation results - if: always() - uses: actions/upload-artifact@v4 - with: - name: libffi-msvc-investigation - path: | - ${{ runner.temp }}/libffi-build/config.log - ${{ runner.temp }}/libffi-build/config.status - ${{ runner.temp }}/libffi-build/Makefile - ${{ runner.temp }}/libffi-build/fficonfig.h - ${{ runner.temp }}/libffi-build/libtool - ${{ runner.temp }}/libffi-install