windows: support bun:ffi (#8114)

* compile tcc

* initial linking

* ffi and stuff

* swag

* wala

* Update settings.json

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
dave caruso
2024-01-13 19:14:29 -08:00
committed by GitHub
parent be0896e204
commit 5fc4538477
12 changed files with 143 additions and 111 deletions

View File

@@ -65,9 +65,9 @@ Build-Dependency `
Build-Dependency `
-Script "mimalloc" `
-Outputs @("mimalloc.lib")
# Build-Dependency `
# -Script "tinycc" `
# -Outputs @("tcc.lib")
Build-Dependency `
-Script "tinycc" `
-Outputs @("tcc.lib")
Build-Dependency `
-Script "zlib" `
-Outputs @("zlib.lib")

30
scripts/build-tinycc.ps1 Normal file
View File

@@ -0,0 +1,30 @@
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
. (Join-Path $PSScriptRoot "env.ps1")
Push-Location (Join-Path $BUN_DEPS_DIR 'tinycc')
try {
cd win32
Run .\build-tcc.bat -clean
cd ..
Set-Content -Path config.h -Value @"
#define TCC_VERSION "$(Get-Content VERSION)"
#define TCC_GITHASH "$(git rev-parse --short HEAD)"
#define CONFIG_TCCDIR "$((Get-Location).Path.Replace('\', '/'))"
#define CONFIG_TCC_PREDEFS 1
#ifdef TCC_TARGET_X86_64
#define CONFIG_TCC_CROSSPREFIX "$PX%-"
#endif
"@
Run clang-cl -DTCC_TARGET_PE -DTCC_TARGET_X86_64 config.h -DC2STR -o c2str.exe conftest.c
Run .\c2str.exe .\include\tccdefs.h tccdefs_.h
# TODO: -MT
Run clang-cl libtcc.c -o tcc.obj "-DTCC_TARGET_PE" "-DTCC_TARGET_X86_64" "-O2" "-W2" "-Zi" "-MD" "-GS-" "-c"
Run lib "tcc.obj" "-OUT:tcc.lib"
Copy-Item tcc.obj $BUN_DEPS_OUT_DIR/tcc.lib
Write-Host "-> tcc.lib"
} finally { Pop-Location }