From 611ecf5e0f4cf2ecad70d8e864f31eaca7a48f4f Mon Sep 17 00:00:00 2001
From: Bishoywadea <bishoyw.fathy@gmail.com>
Date: Sun, 9 Feb 2025 03:28:35 +0200
Subject: [PATCH 01/22] add Set-C function from PR #458

---
 tools/metacall-environment.ps1 | 82 ++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1
index dd2191520..54e90e26f 100755
--- a/tools/metacall-environment.ps1
+++ b/tools/metacall-environment.ps1
@@ -202,6 +202,73 @@ function Set-Ruby {
 	Write-Output "-DRuby_LIBRARY_NAME=""$RubyDir/bin/x64-vcruntime140-ruby310.dll""" >> $EnvOpts
 }
 
+function Set-C {
+	Write-Output "Install C depenendencies"
+
+	Set-Location $ROOT_DIR
+
+	$DepsDir = "$ROOT_DIR\dependencies"
+	$repositoryUrl = "https://github.com/newlawrence/Libffi.git"
+	$destinationPath = "$DepsDir\libffi"
+	Clone-GitRepository -repositoryUrl $repositoryUrl -destinationPath $destinationPath
+
+	
+	mkdir "$destinationPath\build"
+	Set-Location "$destinationPath\build"
+
+	cmake .. -G"Visual Studio 16 2019"
+
+	cmake --build . --target ffi
+
+	Set-Choco
+
+	# choco install llvm -y
+	choco install llvm -y
+
+
+	$Env_Opts = "$ROOT_DIR\build\CMakeConfig.txt"
+
+	$LLVM_Dir1 = "$env:ProgramW6432/LLVM".Replace('\', '/')
+	#  find a way to pass multiple locations to cmake
+	# $LLVM_Dir2 = "$env:ProgramFiles/LLVM".Replace('\', '/')
+	$LibFFI_Dir = $destinationPath.Replace('\','/')
+
+	Write-Output "-DLIBFFI_LIBRARY=""$LibFFI_Dir/build/lib/libffi.lib""" >> $Env_Opts
+	Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFI_Dir/build/include/""" >> $Env_Opts
+	Write-Output "-DLibClang_INCLUDE_DIR=""$LLVM_Dir1/include/clang""" >> $Env_Opts
+
+}
+
+function Clone-GitRepository {
+    param (
+        [string]$repositoryUrl,
+        [string]$destinationPath
+    )
+
+    # Check if Git is installed
+    if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
+        Write-Error "Git is not installed. Please install Git and try again."
+        return
+    }
+
+    # Check if the destination path already exists
+    if (Test-Path $destinationPath) {
+        Write-Error "Destination path already exists. Please provide a different path."
+        return
+    }
+
+    # Clone the repository using Git
+    & git clone $repositoryUrl $destinationPath
+
+    # Check if the cloning was successful
+    if ($LASTEXITCODE -ne 0) {
+        Write-Error "Failed to clone the repository."
+        return
+    }
+
+    Write-Output "Repository cloned successfully."
+}
+
 function Set-TypeScript {
 	Write-Output "Install TypeScript"
 	npm i react@latest -g
@@ -279,6 +346,21 @@ function Set-Base {
 	}
 }
 
+function Set-Choco {
+	# Set directory for installation - Chocolatey does not lock
+	# down the directory if not the default
+	$InstallDir='C:\ProgramData\chocoportable'
+	$env:ChocolateyInstall="$InstallDir"
+
+	# If your PowerShell Execution policy is restrictive, you may
+	# not be able to get around that. Try setting your session to
+	# Bypass.
+	Set-ExecutionPolicy Bypass -Scope Process -Force;
+
+	# All install options - offline, proxy, etc at
+	# https://chocolatey.org/install
+	iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
+}
 # Configure
 function Configure {
 	# Create option variables file 

From f221f5cfbad6c4f5fa618967a3f936707e6e000a Mon Sep 17 00:00:00 2001
From: Bishoywadea <bishoyw.fathy@gmail.com>
Date: Mon, 10 Feb 2025 02:12:22 +0200
Subject: [PATCH 02/22] refactor: C dependency setup

---
 tools/dependencies/tcc         |   1 +
 tools/dependencies/vcpkg       |   1 +
 tools/metacall-environment.ps1 | 121 +++++++++++++++++++++++++--------
 3 files changed, 95 insertions(+), 28 deletions(-)
 create mode 160000 tools/dependencies/tcc
 create mode 160000 tools/dependencies/vcpkg

diff --git a/tools/dependencies/tcc b/tools/dependencies/tcc
new file mode 160000
index 000000000..f6385c053
--- /dev/null
+++ b/tools/dependencies/tcc
@@ -0,0 +1 @@
+Subproject commit f6385c05308f715bdd2c06336801193a21d69b50
diff --git a/tools/dependencies/vcpkg b/tools/dependencies/vcpkg
new file mode 160000
index 000000000..74ec888e3
--- /dev/null
+++ b/tools/dependencies/vcpkg
@@ -0,0 +1 @@
+Subproject commit 74ec888e385d189b42d6b398d0bbaa6f1b1d3b0e
diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1
index 54e90e26f..c390426cf 100755
--- a/tools/metacall-environment.ps1
+++ b/tools/metacall-environment.ps1
@@ -202,42 +202,106 @@ function Set-Ruby {
 	Write-Output "-DRuby_LIBRARY_NAME=""$RubyDir/bin/x64-vcruntime140-ruby310.dll""" >> $EnvOpts
 }
 
-function Set-C {
-	Write-Output "Install C depenendencies"
-
-	Set-Location $ROOT_DIR
-
-	$DepsDir = "$ROOT_DIR\dependencies"
-	$repositoryUrl = "https://github.com/newlawrence/Libffi.git"
-	$destinationPath = "$DepsDir\libffi"
-	Clone-GitRepository -repositoryUrl $repositoryUrl -destinationPath $destinationPath
-
-	
-	mkdir "$destinationPath\build"
-	Set-Location "$destinationPath\build"
-
-	cmake .. -G"Visual Studio 16 2019"
+function Install-VS {
+    Write-Output "Checking for preinstalled Visual Studio Build Tools..."
+    
+    # Path to vswhere.exe
+    $vsWherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
+    
+    # Use vswhere to search for a Visual Studio instance with the VC++ tools
+    if (Test-Path $vsWherePath) {
+        $vsInstance = & $vsWherePath -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
+    }
+    
+    if (-not $vsInstance) {
+        Write-Output "Visual Studio Build Tools with VC++ components not found. Installing..."
+        choco install visualstudio2019buildtools -y
+        Write-Output "Installation initiated. Please reboot if required and re-run the script."
+    } else {
+        Write-Output "Found Visual Studio at: $vsInstance"
+    }
+}
 
-	cmake --build . --target ffi
+function Set-C {
+    $ErrorActionPreference = "Stop"
+    Write-Output "Installing C dependencies..."
+
+    # Ensure Chocolatey is set up
+    Set-Choco
+
+    # Install Visual Studio Build Tools
+    Install-VS
+
+    # Set directories
+    Set-Location $ROOT_DIR
+    $DepsDir = Join-Path $ROOT_DIR 'dependencies'
+    $vcpkgDir = Join-Path $DepsDir 'vcpkg'
+
+	# Install vcpkg if missing
+    if (-not (Test-Path (Join-Path $vcpkgDir 'vcpkg.exe'))) {
+        Write-Output "Cloning vcpkg into $vcpkgDir..."
+        git clone https://github.com/microsoft/vcpkg.git $vcpkgDir
+        & (Join-Path $vcpkgDir 'bootstrap-vcpkg.bat')
+        & (Join-Path $vcpkgDir 'vcpkg.exe') integrate install
+    } else {
+        Write-Output "vcpkg already installed."
+    }
 
-	Set-Choco
+    # Install libffi using vcpkg
+    Write-Output "Installing libffi using vcpkg..."
+    & (Join-Path $vcpkgDir 'vcpkg.exe') install libffi
+
+    # Install LLVM using Chocolatey
+    Write-Output "Installing LLVM..."
+    choco install llvm -y
+
+    # Clone and build libtcc
+    $tccRepoUrl = "https://github.com/TinyCC/tinycc.git"
+    $tccDestination = "$DepsDir\tcc"
+    if (-not (Test-Path "$tccDestination\.git")) {
+        Write-Output "Cloning libtcc..."
+        git clone $tccRepoUrl $tccDestination
+    } else {
+        Write-Output "libtcc already cloned."
+    }
 
-	# choco install llvm -y
-	choco install llvm -y
+    # Build libtcc using Git Bash
+    $gitBashPath = "C:\Program Files\Git\bin\bash.exe"
+    if ($gitBashPath) {
+        Write-Output "Building libtcc..."
+        Set-Location $tccDestination
+		& "$gitBashPath" -c "git config --global core.autocrlf input"
+		$bashCommand = "cd /c/gcc-14.2.0/bin/ && gcc --version"
+        & "$gitBashPath" -c "$bashCommand" | Tee-Object -Variable output
+		& "$gitBashPath" -c "sed -i 's/\r$//' configure"
+        & "$gitBashPath" -c "ls && ./configure && make && make test && make install" | Tee-Object -Variable output
+    } else {
+        Write-Output "Git Bash not found. Please install Git for Windows."
+    }
 
+    # Write environment options for CMake configuration
+    $Env_Opts = "$ROOT_DIR\build\CMakeConfig.txt"
+    $LLVM_Dir = "$env:ProgramFiles\LLVM"
+    $vcpkgLibDir = "$DepsDir\vcpkg\installed\x64-windows\lib"
+    $vcpkgIncludeDir = "$DepsDir\vcpkg\installed\x64-windows\include"
+    $tccLib = "$tccDestination\lib\tcc.lib"
+    $tccInclude = "$tccDestination\include"
+
+    $cmakeOptions = @(
+        "-DLIBFFI_LIBRARY=$vcpkgLibDir\libffi.lib"
+        "-DLIBFFI_INCLUDE_DIR=$vcpkgIncludeDir"
+        "-DLibClang_INCLUDE_DIR=$LLVM_Dir\include\clang"
+        "-DLIBCLANG_LIBRARY=$LLVM_Dir\lib\libclang.lib"
+        "-DTCC_LIBRARY=$tccLib"
+        "-DTCC_INCLUDE_DIR=$tccInclude"
+    )
 
-	$Env_Opts = "$ROOT_DIR\build\CMakeConfig.txt"
+    $cmakeOptions | Out-File -Append -FilePath $Env_Opts
 
-	$LLVM_Dir1 = "$env:ProgramW6432/LLVM".Replace('\', '/')
-	#  find a way to pass multiple locations to cmake
-	# $LLVM_Dir2 = "$env:ProgramFiles/LLVM".Replace('\', '/')
-	$LibFFI_Dir = $destinationPath.Replace('\','/')
+    Write-Output "All dependencies installed and configured successfully."
+}
 
-	Write-Output "-DLIBFFI_LIBRARY=""$LibFFI_Dir/build/lib/libffi.lib""" >> $Env_Opts
-	Write-Output "-DLIBFFI_INCLUDE_DIR=""$LibFFI_Dir/build/include/""" >> $Env_Opts
-	Write-Output "-DLibClang_INCLUDE_DIR=""$LLVM_Dir1/include/clang""" >> $Env_Opts
 
-}
 
 function Clone-GitRepository {
     param (
@@ -434,6 +498,7 @@ function Configure {
 		}
 		if ("$var" -eq 'c') {
 			Write-Output "c selected"
+			Set-C
 		}
 		if ("$var" -eq 'cobol') {
 			Write-Output "cobol selected"

From 21ebab095ce10d1003db87cc855e0bf4ca845ad4 Mon Sep 17 00:00:00 2001
From: Bishoywadea <bishoyw.fathy@gmail.com>
Date: Thu, 13 Feb 2025 05:49:06 +0200
Subject: [PATCH 03/22] adding c to windows ci

---
 .github/workflows/windows-test.yml | 4 ++--
 tools/dependencies/tcc             | 1 -
 tools/dependencies/vcpkg           | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)
 delete mode 160000 tools/dependencies/tcc
 delete mode 160000 tools/dependencies/vcpkg

diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml
index c7af6e0ee..f9db06953 100644
--- a/.github/workflows/windows-test.yml
+++ b/.github/workflows/windows-test.yml
@@ -48,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 funchook swig pack # clangformat v8rep51 coverage
+          METACALL_INSTALL_OPTIONS: c python nodejs java ruby typescript wasm rpc file # netcore5 java cobol rust rapidjson funchook swig pack # clangformat v8rep51 coverage
 
       - name: Configure
         run: |
@@ -57,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 c python nodejs java ruby typescript wasm rpc file # netcore5 java cobol rust examples install pack benchmarks # v8 coverage
 
       - name: Build
         working-directory: ./build
diff --git a/tools/dependencies/tcc b/tools/dependencies/tcc
deleted file mode 160000
index f6385c053..000000000
--- a/tools/dependencies/tcc
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit f6385c05308f715bdd2c06336801193a21d69b50
diff --git a/tools/dependencies/vcpkg b/tools/dependencies/vcpkg
deleted file mode 160000
index 74ec888e3..000000000
--- a/tools/dependencies/vcpkg
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 74ec888e385d189b42d6b398d0bbaa6f1b1d3b0e

From 0f4ab47a22e320b0bdd185278f231bb5bbc9e3fd Mon Sep 17 00:00:00 2001
From: Bishoywadea <bishoyw.fathy@gmail.com>
Date: Mon, 17 Feb 2025 16:26:33 +0200
Subject: [PATCH 04/22] add install llvm in powershell script + fixing
 threading error

---
 cmake/Warnings.cmake                          |   4 +-
 source/log/include/log/log_preprocessor.h     |  22 ++--
 .../include/threading/threading_atomic.h      | 110 +++++++++---------
 tools/metacall-environment.ps1                | 108 ++++++++---------
 4 files changed, 115 insertions(+), 129 deletions(-)

diff --git a/cmake/Warnings.cmake b/cmake/Warnings.cmake
index 5c9b44da7..aa78a1844 100644
--- a/cmake/Warnings.cmake
+++ b/cmake/Warnings.cmake
@@ -85,7 +85,7 @@ if(WARNINGS_ENABLED)
 		string(REPLACE "/W1" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
 		string(REPLACE "/W2" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
 		string(REPLACE "/W3" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
-		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /Wall")
+		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W2 /Wall")
 		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CTR_NONSTDC_NO_WARNINGS=1")
 		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CTR_SECURE_NO_WARNINGS=1")
 		set(WARNINGS_C_AVAILABLE 1)
@@ -105,7 +105,7 @@ if(WARNINGS_ENABLED)
 		string(REPLACE "/W1" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
 		string(REPLACE "/W2" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
 		string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /Wall")
+		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2 /Wall")
 		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _CTR_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1")
 		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _CTR_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1")
 		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _CTR_NONSTDC_NO_WARNINGS=1")
diff --git a/source/log/include/log/log_preprocessor.h b/source/log/include/log/log_preprocessor.h
index e2dfb62dc..a41511be5 100644
--- a/source/log/include/log/log_preprocessor.h
+++ b/source/log/include/log/log_preprocessor.h
@@ -18,7 +18,7 @@
  *
  */
 
-#ifndef LOG_PREPROCESSOR_H
+ #ifndef LOG_PREPROCESSOR_H
 #define LOG_PREPROCESSOR_H 1
 
 /* -- Headers -- */
@@ -39,19 +39,15 @@ extern "C" {
 /* -- Macros -- */
 
 #define log_configure(name, ...) \
-	log_configure_impl(name, PREPROCESSOR_ARGS_COUNT(__VA_ARGS__), __VA_ARGS__)
-
-#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
-	(defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
-	#define log_write(name, level, ...) \
-		PREPROCESSOR_IF(PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__), \
-			log_write_impl(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, __VA_ARGS__), \
-			log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, __VA_ARGS__))
+    log_configure_impl(name, PREPROCESSOR_ARGS_COUNT(__VA_ARGS__), ##__VA_ARGS__)
+
+/* Unified log_write macro that works across all compilers */
+#if defined(_MSC_VER) && !defined(__clang__)
+    #define log_write(name, level, format, ...) \
+        log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, format, ##__VA_ARGS__)
 #else
-	#define log_write(name, level, message, ...) \
-		PREPROCESSOR_IF(PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__), \
-			log_write_impl(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, message), \
-			log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, message, __VA_ARGS__))
+    #define log_write(name, level, ...) \
+        log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, __VA_ARGS__)
 #endif
 
 #ifdef __cplusplus
diff --git a/source/threading/include/threading/threading_atomic.h b/source/threading/include/threading/threading_atomic.h
index a2b870d3a..3c4e9a2c8 100644
--- a/source/threading/include/threading/threading_atomic.h
+++ b/source/threading/include/threading/threading_atomic.h
@@ -18,58 +18,58 @@
  *
  */
 
-#ifndef THREADING_ATOMIC_H
-#define THREADING_ATOMIC_H 1
-
-/* -- Headers -- */
-
-#include <threading/threading_api.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* -- Definitions -- */
-
-#if defined(__STDC_VERSION__)
-	#if __STDC_VERSION__ - 0L >= 201112L
-		/* C11 support */
-		#if defined(__STDC_NO_ATOMICS__)
-			/* TODO: C11 atomics not supported, check the platform and implement support if needed */
-			#define THREADING_ATOMIC 0
-		#elif defined __has_include
-			#if __has_include(<stdatomic.h>)
-				#include <stdatomic.h>
-				#define THREADING_ATOMIC 1
-			#endif
-		#else
-			#include <stdatomic.h>
-			#define THREADING_ATOMIC 1
-		#endif
-	#else
-		/* TODO: C11 is not supported, check the platform and implement support if needed */
-		#define THREADING_ATOMIC 0
-	#endif
-#elif defined(_WIN32) && defined(_MSC_VER)
-	#if (_MSC_VER < 1930)
-		/* Before Visual Studio 2022 atomics are not supported, use fallback solution */
-		#include <threading/threading_atomic_win32.h>
-		#define THREADING_ATOMIC 1
-	#else
-		#include <stdatomic.h>
-		#define THREADING_ATOMIC 1
-	#endif
-#else
-	/* TODO: Unknown compiler and platform, check the platform and compiler, then implement support if needed */
-	#define THREADING_ATOMIC 0
-#endif
-
-#if !defined(THREADING_ATOMIC) || (defined(THREADING_ATOMIC) && THREADING_ATOMIC == 0)
-	#error "Thread atomic support not implemented."
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* THREADING_ATOMIC_H */
+ #ifndef THREADING_ATOMIC_H
+ #define THREADING_ATOMIC_H 1
+ 
+ /* -- Headers -- */
+ 
+ #include <threading/threading_api.h>
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ /* -- Definitions -- */
+ 
+ /* Check for C11 support and atomics availability */
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+	 #if defined(__STDC_NO_ATOMICS__)
+		 /* C11 atomics not supported, use platform-specific implementation */
+		 #if defined(_WIN32) && defined(_MSC_VER)
+			 #include <threading/threading_atomic_win32.h>
+		 #else
+			 #error "Atomic operations not supported on this platform"
+		 #endif
+		 #define THREADING_ATOMIC 1
+	 #else
+		 /* C11 atomics are supported */
+		 #include <stdatomic.h>
+		 #include <threads.h>
+		 #define THREADING_ATOMIC 1
+	 #endif
+ #elif defined(_WIN32) && defined(_MSC_VER)
+	 /* Handle MSVC specific cases */
+	 #if (_MSC_VER < 1930)
+		 /* Before Visual Studio 2022, use Win32 atomic implementation */
+		 #include <threading/threading_atomic_win32.h>
+		 #define THREADING_ATOMIC 1
+	 #else
+		 /* Visual Studio 2022 and later */
+		 #include <stdatomic.h>
+		 #include <threads.h>
+		 #define THREADING_ATOMIC 1
+	 #endif
+ #else
+	 /* Platform not explicitly supported */
+	 #error "Atomic operations not supported on this platform"
+ #endif
+ 
+ #ifndef THREADING_ATOMIC
+	 #error "Thread atomic support not properly configured"
+ #endif
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif /* THREADING_ATOMIC_H */
diff --git a/tools/metacall-environment.ps1 b/tools/metacall-environment.ps1
index c390426cf..faa2dc12a 100755
--- a/tools/metacall-environment.ps1
+++ b/tools/metacall-environment.ps1
@@ -202,25 +202,6 @@ function Set-Ruby {
 	Write-Output "-DRuby_LIBRARY_NAME=""$RubyDir/bin/x64-vcruntime140-ruby310.dll""" >> $EnvOpts
 }
 
-function Install-VS {
-    Write-Output "Checking for preinstalled Visual Studio Build Tools..."
-    
-    # Path to vswhere.exe
-    $vsWherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
-    
-    # Use vswhere to search for a Visual Studio instance with the VC++ tools
-    if (Test-Path $vsWherePath) {
-        $vsInstance = & $vsWherePath -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
-    }
-    
-    if (-not $vsInstance) {
-        Write-Output "Visual Studio Build Tools with VC++ components not found. Installing..."
-        choco install visualstudio2019buildtools -y
-        Write-Output "Installation initiated. Please reboot if required and re-run the script."
-    } else {
-        Write-Output "Found Visual Studio at: $vsInstance"
-    }
-}
 
 function Set-C {
     $ErrorActionPreference = "Stop"
@@ -229,9 +210,6 @@ function Set-C {
     # Ensure Chocolatey is set up
     Set-Choco
 
-    # Install Visual Studio Build Tools
-    Install-VS
-
     # Set directories
     Set-Location $ROOT_DIR
     $DepsDir = Join-Path $ROOT_DIR 'dependencies'
@@ -240,7 +218,7 @@ function Set-C {
 	# Install vcpkg if missing
     if (-not (Test-Path (Join-Path $vcpkgDir 'vcpkg.exe'))) {
         Write-Output "Cloning vcpkg into $vcpkgDir..."
-        git clone https://github.com/microsoft/vcpkg.git $vcpkgDir
+        git clone --depth=1 https://github.com/microsoft/vcpkg.git $vcpkgDir
         & (Join-Path $vcpkgDir 'bootstrap-vcpkg.bat')
         & (Join-Path $vcpkgDir 'vcpkg.exe') integrate install
     } else {
@@ -251,49 +229,63 @@ function Set-C {
     Write-Output "Installing libffi using vcpkg..."
     & (Join-Path $vcpkgDir 'vcpkg.exe') install libffi
 
-    # Install LLVM using Chocolatey
-    Write-Output "Installing LLVM..."
-    choco install llvm -y
 
-    # Clone and build libtcc
-    $tccRepoUrl = "https://github.com/TinyCC/tinycc.git"
-    $tccDestination = "$DepsDir\tcc"
-    if (-not (Test-Path "$tccDestination\.git")) {
-        Write-Output "Cloning libtcc..."
-        git clone $tccRepoUrl $tccDestination
-    } else {
-        Write-Output "libtcc already cloned."
-    }
+	# Define LLVM version and download URL
+	$llvmVersion = "19.1.7"
+	$llvmArchiveUrl = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/clang+llvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz"
+	$archivePath = "$env:TEMP\clang+llvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz"
+	$extractPath = "$env:TEMP\clang+llvm-$llvmVersion"
+	$finalPath = Join-Path $DepsDir 'llvm'
 
-    # Build libtcc using Git Bash
-    $gitBashPath = "C:\Program Files\Git\bin\bash.exe"
-    if ($gitBashPath) {
-        Write-Output "Building libtcc..."
-        Set-Location $tccDestination
-		& "$gitBashPath" -c "git config --global core.autocrlf input"
-		$bashCommand = "cd /c/gcc-14.2.0/bin/ && gcc --version"
-        & "$gitBashPath" -c "$bashCommand" | Tee-Object -Variable output
-		& "$gitBashPath" -c "sed -i 's/\r$//' configure"
-        & "$gitBashPath" -c "ls && ./configure && make && make test && make install" | Tee-Object -Variable output
-    } else {
-        Write-Output "Git Bash not found. Please install Git for Windows."
-    }
+	# Ensure dependencies directory exists
+	if (!(Test-Path $DepsDir)) {
+		New-Item -ItemType Directory -Path $DepsDir -Force | Out-Null
+	}
+
+	Download LLVM archive
+	Write-Output "Downloading LLVM $llvmVersion archive..."
+	Invoke-WebRequest -Uri $llvmArchiveUrl -OutFile $archivePath
+
+	# Extract the .xz file
+	Write-Output "Extracting .xz archive..."
+	tar -xf $archivePath -C $env:TEMP
+	$tarFile = $archivePath -replace '\.xz$', ''  # Remove .xz extension
+
+	# Extract the .tar file
+	Write-Output "Extracting .tar archive..."
+	tar -xf $tarFile -C $env:TEMP
+
+	# Find the extracted folder
+	$extractedFolder = Get-ChildItem -Path $env:TEMP -Directory | Where-Object { $_.Name -match "clang\+llvm-$llvmVersion-x86_64-pc-windows-msvc" } | Select-Object -First 1
+
+	if ($extractedFolder) {
+		Write-Output "Moving extracted LLVM to $finalPath..."
+		Move-Item -Path $extractedFolder.FullName -Destination $finalPath -Force
+	} else {
+		Write-Output "Extracted LLVM folder not found!"
+	}
+
+	# Clean up
+	Write-Output "Cleaning up downloaded files..."
+	Remove-Item -Path $archivePath, $tarFile -Force
+
+	Write-Output "LLVM $llvmVersion successfully installed at $finalPath!"
 
     # Write environment options for CMake configuration
     $Env_Opts = "$ROOT_DIR\build\CMakeConfig.txt"
-    $LLVM_Dir = "$env:ProgramFiles\LLVM"
     $vcpkgLibDir = "$DepsDir\vcpkg\installed\x64-windows\lib"
     $vcpkgIncludeDir = "$DepsDir\vcpkg\installed\x64-windows\include"
-    $tccLib = "$tccDestination\lib\tcc.lib"
-    $tccInclude = "$tccDestination\include"
 
     $cmakeOptions = @(
-        "-DLIBFFI_LIBRARY=$vcpkgLibDir\libffi.lib"
-        "-DLIBFFI_INCLUDE_DIR=$vcpkgIncludeDir"
-        "-DLibClang_INCLUDE_DIR=$LLVM_Dir\include\clang"
-        "-DLIBCLANG_LIBRARY=$LLVM_Dir\lib\libclang.lib"
-        "-DTCC_LIBRARY=$tccLib"
-        "-DTCC_INCLUDE_DIR=$tccInclude"
+		"set(OPTION_BUILD_LOADERS_C ON CACHE BOOL `"Build C loaders`")"
+
+		"set(LIBFFI_LIBRARY `"$vcpkgLibDir\ffi.lib`" CACHE STRING `"Path to libffi library`")"
+		"set(LIBFFI_INCLUDE_DIR `"$vcpkgIncludeDir`" CACHE STRING `"Path to libffi include directory`")"
+
+		"set(LibClang_INCLUDE_DIR `"$finalPath\include`" CACHE STRING `"Path to libclang include directory`")"
+		"set(LIBCLANG_LIBRARY `"$finalPath\lib\libclang.lib`" CACHE STRING `"Path to libclang library`")"
+
+		"set(CMAKE_TOOLCHAIN_FILE `"$vcpkgDir\scripts\buildsystems\vcpkg.cmake`" CACHE STRING `"Path to vcpkg toolchain file`")"
     )
 
     $cmakeOptions | Out-File -Append -FilePath $Env_Opts
@@ -301,8 +293,6 @@ function Set-C {
     Write-Output "All dependencies installed and configured successfully."
 }
 
-
-
 function Clone-GitRepository {
     param (
         [string]$repositoryUrl,

From 6df452c3450d9e9b072c10692304028e991792cb Mon Sep 17 00:00:00 2001
From: -NoName <108888519+Bishoywadea@users.noreply.github.com>
Date: Wed, 19 Feb 2025 19:10:26 +0200
Subject: [PATCH 05/22] undo last change in log_preprocessor.h

---
 source/log/include/log/log_preprocessor.h | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/source/log/include/log/log_preprocessor.h b/source/log/include/log/log_preprocessor.h
index a41511be5..e2dfb62dc 100644
--- a/source/log/include/log/log_preprocessor.h
+++ b/source/log/include/log/log_preprocessor.h
@@ -18,7 +18,7 @@
  *
  */
 
- #ifndef LOG_PREPROCESSOR_H
+#ifndef LOG_PREPROCESSOR_H
 #define LOG_PREPROCESSOR_H 1
 
 /* -- Headers -- */
@@ -39,15 +39,19 @@ extern "C" {
 /* -- Macros -- */
 
 #define log_configure(name, ...) \
-    log_configure_impl(name, PREPROCESSOR_ARGS_COUNT(__VA_ARGS__), ##__VA_ARGS__)
-
-/* Unified log_write macro that works across all compilers */
-#if defined(_MSC_VER) && !defined(__clang__)
-    #define log_write(name, level, format, ...) \
-        log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, format, ##__VA_ARGS__)
+	log_configure_impl(name, PREPROCESSOR_ARGS_COUNT(__VA_ARGS__), __VA_ARGS__)
+
+#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
+	(defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
+	#define log_write(name, level, ...) \
+		PREPROCESSOR_IF(PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__), \
+			log_write_impl(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, __VA_ARGS__), \
+			log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, __VA_ARGS__))
 #else
-    #define log_write(name, level, ...) \
-        log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, __VA_ARGS__)
+	#define log_write(name, level, message, ...) \
+		PREPROCESSOR_IF(PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__), \
+			log_write_impl(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, message), \
+			log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, message, __VA_ARGS__))
 #endif
 
 #ifdef __cplusplus

From 952b09663c5a1e9657269b9d61d210a9fcacaa9c Mon Sep 17 00:00:00 2001
From: -NoName <108888519+Bishoywadea@users.noreply.github.com>
Date: Wed, 19 Feb 2025 19:11:52 +0200
Subject: [PATCH 06/22] undo last change in threading_atomic.h

---
 .../include/threading/threading_atomic.h      | 110 +++++++++---------
 1 file changed, 55 insertions(+), 55 deletions(-)

diff --git a/source/threading/include/threading/threading_atomic.h b/source/threading/include/threading/threading_atomic.h
index 3c4e9a2c8..a2b870d3a 100644
--- a/source/threading/include/threading/threading_atomic.h
+++ b/source/threading/include/threading/threading_atomic.h
@@ -18,58 +18,58 @@
  *
  */
 
- #ifndef THREADING_ATOMIC_H
- #define THREADING_ATOMIC_H 1
- 
- /* -- Headers -- */
- 
- #include <threading/threading_api.h>
- 
- #ifdef __cplusplus
- extern "C" {
- #endif
- 
- /* -- Definitions -- */
- 
- /* Check for C11 support and atomics availability */
- #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
-	 #if defined(__STDC_NO_ATOMICS__)
-		 /* C11 atomics not supported, use platform-specific implementation */
-		 #if defined(_WIN32) && defined(_MSC_VER)
-			 #include <threading/threading_atomic_win32.h>
-		 #else
-			 #error "Atomic operations not supported on this platform"
-		 #endif
-		 #define THREADING_ATOMIC 1
-	 #else
-		 /* C11 atomics are supported */
-		 #include <stdatomic.h>
-		 #include <threads.h>
-		 #define THREADING_ATOMIC 1
-	 #endif
- #elif defined(_WIN32) && defined(_MSC_VER)
-	 /* Handle MSVC specific cases */
-	 #if (_MSC_VER < 1930)
-		 /* Before Visual Studio 2022, use Win32 atomic implementation */
-		 #include <threading/threading_atomic_win32.h>
-		 #define THREADING_ATOMIC 1
-	 #else
-		 /* Visual Studio 2022 and later */
-		 #include <stdatomic.h>
-		 #include <threads.h>
-		 #define THREADING_ATOMIC 1
-	 #endif
- #else
-	 /* Platform not explicitly supported */
-	 #error "Atomic operations not supported on this platform"
- #endif
- 
- #ifndef THREADING_ATOMIC
-	 #error "Thread atomic support not properly configured"
- #endif
- 
- #ifdef __cplusplus
- }
- #endif
- 
- #endif /* THREADING_ATOMIC_H */
+#ifndef THREADING_ATOMIC_H
+#define THREADING_ATOMIC_H 1
+
+/* -- Headers -- */
+
+#include <threading/threading_api.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* -- Definitions -- */
+
+#if defined(__STDC_VERSION__)
+	#if __STDC_VERSION__ - 0L >= 201112L
+		/* C11 support */
+		#if defined(__STDC_NO_ATOMICS__)
+			/* TODO: C11 atomics not supported, check the platform and implement support if needed */
+			#define THREADING_ATOMIC 0
+		#elif defined __has_include
+			#if __has_include(<stdatomic.h>)
+				#include <stdatomic.h>
+				#define THREADING_ATOMIC 1
+			#endif
+		#else
+			#include <stdatomic.h>
+			#define THREADING_ATOMIC 1
+		#endif
+	#else
+		/* TODO: C11 is not supported, check the platform and implement support if needed */
+		#define THREADING_ATOMIC 0
+	#endif
+#elif defined(_WIN32) && defined(_MSC_VER)
+	#if (_MSC_VER < 1930)
+		/* Before Visual Studio 2022 atomics are not supported, use fallback solution */
+		#include <threading/threading_atomic_win32.h>
+		#define THREADING_ATOMIC 1
+	#else
+		#include <stdatomic.h>
+		#define THREADING_ATOMIC 1
+	#endif
+#else
+	/* TODO: Unknown compiler and platform, check the platform and compiler, then implement support if needed */
+	#define THREADING_ATOMIC 0
+#endif
+
+#if !defined(THREADING_ATOMIC) || (defined(THREADING_ATOMIC) && THREADING_ATOMIC == 0)
+	#error "Thread atomic support not implemented."
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* THREADING_ATOMIC_H */

From c2e77ddc52460391e04e0c3381e4c4388e1c8e79 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Wed, 19 Feb 2025 20:16:34 +0200
Subject: [PATCH 07/22] enable c in macos ci and updating tcc

---
 .github/workflows/macos-test.yml | 4 ++--
 cmake/InstallLibTCC.cmake        | 6 +++---
 tools/metacall-environment.sh    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index 64a768757..ebce9fa31 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -77,7 +77,7 @@ jobs:
       - name: Set up the environment
         run: sh ./tools/metacall-environment.sh $METACALL_INSTALL_OPTIONS
         env:
-          METACALL_INSTALL_OPTIONS: base python nodejs typescript java ruby wasm rpc file cobol go backtrace #netcore5 c rust rapidjson funchook swig pack # clangformat v8rep51 coverage
+          METACALL_INSTALL_OPTIONS: base python nodejs typescript java ruby wasm rpc file cobol go backtrace c #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
 
       - name: Configure
         run: |
@@ -85,7 +85,7 @@ jobs:
           . .env
           bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS
         env:
-          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs typescript java ruby wasm rpc file cobol go benchmarks install # netcore5 c rust examples pack # v8 coverage
+          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs typescript java ruby wasm rpc file cobol go benchmarks install  c # netcore5 rust examples pack # v8 coverage
 
       - name: Build
         working-directory: ./build
diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake
index 096f447c9..582a84043 100644
--- a/cmake/InstallLibTCC.cmake
+++ b/cmake/InstallLibTCC.cmake
@@ -125,7 +125,7 @@ else()
 endif()
 
 set(LIBTCC_TARGET libtcc-depends)
-set(LIBTCC_COMMIT_SHA "afc1362")
+set(LIBTCC_COMMIT_SHA "f8bd136")
 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}")
@@ -145,8 +145,8 @@ set(LIBTTC_RUNTIME_FILES
 # LibTCC Proejct
 ExternalProject_Add(${LIBTCC_TARGET}
 	DOWNLOAD_NAME		tinycc.tar.gz
-	URL					https://github.com/metacall/tinycc/archive/${LIBTCC_COMMIT_SHA}.tar.gz
-	URL_MD5				5582b17ee5848aeec28bee13773843f7
+	URL					https://github.com/Bishoywadea/tinycc/archive/${LIBTCC_COMMIT_SHA}.tar.gz
+	URL_MD5				1031bd56e751ce19bae85bd86a82f107
 	CONFIGURE_COMMAND	${LIBTCC_CONFIGURE}
 	BUILD_COMMAND		${LIBTCC_BUILD}
 	BUILD_IN_SOURCE		true
diff --git a/tools/metacall-environment.sh b/tools/metacall-environment.sh
index d2983330b..2324484f5 100755
--- a/tools/metacall-environment.sh
+++ b/tools/metacall-environment.sh
@@ -696,7 +696,7 @@ sub_c(){
 			$SUDO_CMD apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing tcc
 			$SUDO_CMD apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main clang-libs=13.0.1-r1 clang-dev=13.0.1-r1
 		fi
-	elif [ "${OPERATIVE_SYSTEM}" = "Darwin" ]; then
+	elif [[ $OSTYPE == 'darwin'* ]]; then
 		brew install libffi
 		brew install llvm@$LLVM_VERSION_STRING
 		brew link llvm@$LLVM_VERSION_STRING --force --overwrite

From e2604c449e64f3f017384afe809374364c0f663d Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Wed, 19 Feb 2025 20:27:33 +0200
Subject: [PATCH 08/22] fix LLVM_VERSION_STRING: unbound variable bug

---
 tools/metacall-environment.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/metacall-environment.sh b/tools/metacall-environment.sh
index 2324484f5..699cf0b50 100755
--- a/tools/metacall-environment.sh
+++ b/tools/metacall-environment.sh
@@ -650,9 +650,9 @@ sub_java(){
 # C
 sub_c(){
 	echo "configure c"
-
+	LLVM_VERSION_STRING=14
 	if [ "${OPERATIVE_SYSTEM}" = "Linux" ]; then
-		LLVM_VERSION_STRING=14
+		
 
 		if [ "${LINUX_DISTRO}" = "debian" ]; then
 			UBUNTU_CODENAME=""

From 8c31e873018ff4bcdb9248b8871256b4198de0c5 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Wed, 19 Feb 2025 22:57:46 +0200
Subject: [PATCH 09/22] remove other langs from ci

---
 .github/workflows/macos-test.yml | 4 ++--
 tools/metacall-environment.sh    | 9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index ebce9fa31..30585443a 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -77,7 +77,7 @@ jobs:
       - name: Set up the environment
         run: sh ./tools/metacall-environment.sh $METACALL_INSTALL_OPTIONS
         env:
-          METACALL_INSTALL_OPTIONS: base python nodejs typescript java ruby wasm rpc file cobol go backtrace c #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
+          METACALL_INSTALL_OPTIONS: base  c #python nodejs typescript java ruby wasm rpc file cobol go backtrace netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
 
       - name: Configure
         run: |
@@ -85,7 +85,7 @@ jobs:
           . .env
           bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS
         env:
-          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs typescript java ruby wasm rpc file cobol go benchmarks install  c # netcore5 rust examples pack # v8 coverage
+          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests  benchmarks install  c #python nodejs typescript java ruby wasm rpc file cobol go netcore5 rust examples pack # v8 coverage
 
       - name: Build
         working-directory: ./build
diff --git a/tools/metacall-environment.sh b/tools/metacall-environment.sh
index 699cf0b50..29adbad87 100755
--- a/tools/metacall-environment.sh
+++ b/tools/metacall-environment.sh
@@ -652,8 +652,6 @@ sub_c(){
 	echo "configure c"
 	LLVM_VERSION_STRING=14
 	if [ "${OPERATIVE_SYSTEM}" = "Linux" ]; then
-		
-
 		if [ "${LINUX_DISTRO}" = "debian" ]; then
 			UBUNTU_CODENAME=""
 			CODENAME_FROM_ARGUMENTS=""
@@ -699,10 +697,13 @@ sub_c(){
 	elif [[ $OSTYPE == 'darwin'* ]]; then
 		brew install libffi
 		brew install llvm@$LLVM_VERSION_STRING
-		brew link llvm@$LLVM_VERSION_STRING --force --overwrite
+		# brew link llvm@$LLVM_VERSION_STRING --force --overwrite
 		mkdir -p "$ROOT_DIR/build"
-		CMAKE_CONFIG_PATH="$ROOT_DIR/build/CMakeConfig.txt"
 		LIBCLANG_PREFIX=$(brew --prefix llvm@$LLVM_VERSION_STRING)
+		export PATH="$LIBCLANG_PREFIX/bin:$PATH"
+		export CPATH="$LIBCLANG_PREFIX/include:$CPATH"
+		export LIBRARY_PATH="$LIBCLANG_PREFIX/lib:$LIBRARY_PATH"
+		CMAKE_CONFIG_PATH="$ROOT_DIR/build/CMakeConfig.txt"
 		echo "-DLibClang_INCLUDE_DIR=${LIBCLANG_PREFIX}/include" >> $CMAKE_CONFIG_PATH
 		echo "-DLibClang_LIBRARY=${LIBCLANG_PREFIX}/lib/libclang.dylib" >> $CMAKE_CONFIG_PATH
 	fi

From 4ea02237a4817f2f1b1b2009096ad505fbed44ca Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Wed, 19 Feb 2025 23:11:20 +0200
Subject: [PATCH 10/22] add debugging prints

---
 tools/metacall-environment.sh | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/tools/metacall-environment.sh b/tools/metacall-environment.sh
index 29adbad87..7b0b4ceb8 100755
--- a/tools/metacall-environment.sh
+++ b/tools/metacall-environment.sh
@@ -652,6 +652,7 @@ sub_c(){
 	echo "configure c"
 	LLVM_VERSION_STRING=14
 	if [ "${OPERATIVE_SYSTEM}" = "Linux" ]; then
+
 		if [ "${LINUX_DISTRO}" = "debian" ]; then
 			UBUNTU_CODENAME=""
 			CODENAME_FROM_ARGUMENTS=""
@@ -697,15 +698,22 @@ sub_c(){
 	elif [[ $OSTYPE == 'darwin'* ]]; then
 		brew install libffi
 		brew install llvm@$LLVM_VERSION_STRING
-		# brew link llvm@$LLVM_VERSION_STRING --force --overwrite
-		mkdir -p "$ROOT_DIR/build"
 		LIBCLANG_PREFIX=$(brew --prefix llvm@$LLVM_VERSION_STRING)
-		export PATH="$LIBCLANG_PREFIX/bin:$PATH"
-		export CPATH="$LIBCLANG_PREFIX/include:$CPATH"
-		export LIBRARY_PATH="$LIBCLANG_PREFIX/lib:$LIBRARY_PATH"
+		echo "LLVM Prefix: ${LIBCLANG_PREFIX}"
+		brew link llvm@$LLVM_VERSION_STRING --force --overwrite
+		CLANG_C_HEADERS="${LIBCLANG_PREFIX}/include/clang-c"
+		echo "Checking for clang-c headers in: ${CLANG_C_HEADERS}"
+		if ! ls "${CLANG_C_HEADERS}"; then
+			echo "Error: clang-c headers not found in ${CLANG_C_HEADERS}"
+			exit 1
+		fi
+		mkdir -p "$ROOT_DIR/build"
 		CMAKE_CONFIG_PATH="$ROOT_DIR/build/CMakeConfig.txt"
+		echo "CMake config path: ${CMAKE_CONFIG_PATH}"
 		echo "-DLibClang_INCLUDE_DIR=${LIBCLANG_PREFIX}/include" >> $CMAKE_CONFIG_PATH
 		echo "-DLibClang_LIBRARY=${LIBCLANG_PREFIX}/lib/libclang.dylib" >> $CMAKE_CONFIG_PATH
+		echo "CMake config contents:"
+		cat $CMAKE_CONFIG_PATH
 	fi
 }
 

From 112ab5374c8bce83ce2c4aa61c606dbb1404f9d3 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Wed, 19 Feb 2025 23:22:13 +0200
Subject: [PATCH 11/22] undo removing langs in configuration actions

---
 .github/workflows/macos-test.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index 30585443a..c47650a2b 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -85,7 +85,7 @@ jobs:
           . .env
           bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS
         env:
-          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests  benchmarks install  c #python nodejs typescript java ruby wasm rpc file cobol go netcore5 rust examples pack # v8 coverage
+          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs typescript java ruby wasm rpc file cobol go benchmarks install  c # netcore5 rust examples pack # v8 coverage
 
       - name: Build
         working-directory: ./build

From dc46479dcbd10ab42ad041aa46a147f5311843bb Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Wed, 19 Feb 2025 23:26:03 +0200
Subject: [PATCH 12/22] undo removing langs from ci

---
 .github/workflows/macos-test.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index c47650a2b..ebce9fa31 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -77,7 +77,7 @@ jobs:
       - name: Set up the environment
         run: sh ./tools/metacall-environment.sh $METACALL_INSTALL_OPTIONS
         env:
-          METACALL_INSTALL_OPTIONS: base  c #python nodejs typescript java ruby wasm rpc file cobol go backtrace netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
+          METACALL_INSTALL_OPTIONS: base python nodejs typescript java ruby wasm rpc file cobol go backtrace c #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
 
       - name: Configure
         run: |

From 00a42f6ae2567641328d7f4fbfa0676685c80730 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Wed, 19 Feb 2025 23:38:21 +0200
Subject: [PATCH 13/22] making c in the first in the queue of langs

---
 .github/workflows/macos-test.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index ebce9fa31..3a58a4093 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -77,7 +77,7 @@ jobs:
       - name: Set up the environment
         run: sh ./tools/metacall-environment.sh $METACALL_INSTALL_OPTIONS
         env:
-          METACALL_INSTALL_OPTIONS: base python nodejs typescript java ruby wasm rpc file cobol go backtrace c #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
+          METACALL_INSTALL_OPTIONS: base python c nodejs typescript java ruby wasm rpc file cobol go backtrace #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
 
       - name: Configure
         run: |
@@ -85,7 +85,7 @@ jobs:
           . .env
           bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS
         env:
-          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs typescript java ruby wasm rpc file cobol go benchmarks install  c # netcore5 rust examples pack # v8 coverage
+          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python c nodejs typescript java ruby wasm rpc file cobol go benchmarks install # netcore5 rust examples pack # v8 coverage
 
       - name: Build
         working-directory: ./build

From c7fc9d35876649e9407db81cc12b73c00cf5cbd7 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Thu, 20 Feb 2025 01:32:04 +0200
Subject: [PATCH 14/22] trying to solve can't cross compile long double
 constant

---
 cmake/InstallLibTCC.cmake     |  4 ++--
 tools/metacall-environment.sh | 12 +-----------
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake
index 582a84043..6a8c913ca 100644
--- a/cmake/InstallLibTCC.cmake
+++ b/cmake/InstallLibTCC.cmake
@@ -84,8 +84,8 @@ elseif(PROJECT_OS_FAMILY STREQUAL macos)
 	# AddressSanitizer can not provide additional info.
 	# SUMMARY: AddressSanitizer: BUS (libsystem_c.dylib:x86_64+0x3647db0f) in off32
 
-	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross) # --disable-static
-elseif(PROJECT_OS_FAMILY STREQUAL win32)
+	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross --extra-cflags="-arch x86_64 -mlong-double-64" --extra-ldflags="-arch x86_64" --cpu=x86_64)
+	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()
diff --git a/tools/metacall-environment.sh b/tools/metacall-environment.sh
index 7b0b4ceb8..76d16e018 100755
--- a/tools/metacall-environment.sh
+++ b/tools/metacall-environment.sh
@@ -698,22 +698,12 @@ sub_c(){
 	elif [[ $OSTYPE == 'darwin'* ]]; then
 		brew install libffi
 		brew install llvm@$LLVM_VERSION_STRING
-		LIBCLANG_PREFIX=$(brew --prefix llvm@$LLVM_VERSION_STRING)
-		echo "LLVM Prefix: ${LIBCLANG_PREFIX}"
 		brew link llvm@$LLVM_VERSION_STRING --force --overwrite
-		CLANG_C_HEADERS="${LIBCLANG_PREFIX}/include/clang-c"
-		echo "Checking for clang-c headers in: ${CLANG_C_HEADERS}"
-		if ! ls "${CLANG_C_HEADERS}"; then
-			echo "Error: clang-c headers not found in ${CLANG_C_HEADERS}"
-			exit 1
-		fi
 		mkdir -p "$ROOT_DIR/build"
 		CMAKE_CONFIG_PATH="$ROOT_DIR/build/CMakeConfig.txt"
-		echo "CMake config path: ${CMAKE_CONFIG_PATH}"
+		LIBCLANG_PREFIX=$(brew --prefix llvm@$LLVM_VERSION_STRING)
 		echo "-DLibClang_INCLUDE_DIR=${LIBCLANG_PREFIX}/include" >> $CMAKE_CONFIG_PATH
 		echo "-DLibClang_LIBRARY=${LIBCLANG_PREFIX}/lib/libclang.dylib" >> $CMAKE_CONFIG_PATH
-		echo "CMake config contents:"
-		cat $CMAKE_CONFIG_PATH
 	fi
 }
 

From 0a35f11df518d0f0945508e89820cafcf4a17ac6 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Thu, 20 Feb 2025 02:41:02 +0200
Subject: [PATCH 15/22] remove langs from ci for faster runs

---
 .github/workflows/macos-test.yml | 4 ++--
 cmake/InstallLibTCC.cmake        | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index 3a58a4093..544ff5e02 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -77,7 +77,7 @@ jobs:
       - name: Set up the environment
         run: sh ./tools/metacall-environment.sh $METACALL_INSTALL_OPTIONS
         env:
-          METACALL_INSTALL_OPTIONS: base python c nodejs typescript java ruby wasm rpc file cobol go backtrace #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
+          METACALL_INSTALL_OPTIONS: base c rpc file backtrace #cobol go nodejs typescript java ruby wasm python netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
 
       - name: Configure
         run: |
@@ -85,7 +85,7 @@ jobs:
           . .env
           bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS
         env:
-          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python c nodejs typescript java ruby wasm rpc file cobol go benchmarks install # netcore5 rust examples pack # v8 coverage
+          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests c rpc file benchmarks install #cobol go python nodejs typescript java ruby wasm netcore5 rust examples pack # v8 coverage
 
       - name: Build
         working-directory: ./build
diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake
index 6a8c913ca..664bd5de1 100644
--- a/cmake/InstallLibTCC.cmake
+++ b/cmake/InstallLibTCC.cmake
@@ -84,7 +84,7 @@ elseif(PROJECT_OS_FAMILY STREQUAL macos)
 	# AddressSanitizer can not provide additional info.
 	# SUMMARY: AddressSanitizer: BUS (libsystem_c.dylib:x86_64+0x3647db0f) in off32
 
-	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross --extra-cflags="-arch x86_64 -mlong-double-64" --extra-ldflags="-arch x86_64" --cpu=x86_64)
+	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross --extra-cflags="-arch x86_64" --extra-ldflags="-arch x86_64" --cpu=x86_64)
 	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)

From 0fcd022374c4189967850aca46748eb745ac8bc4 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Thu, 20 Feb 2025 02:45:33 +0200
Subject: [PATCH 16/22] fixing error

---
 .github/workflows/macos-test.yml | 54 ++++++++++++++++----------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index 544ff5e02..771ed2978 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -40,36 +40,36 @@ jobs:
         with:
           fetch-depth: 0
 
-      - name: Uninstall NodeJS and NPM
-        run: |
-          npm uninstall npm -g
-          rm -rf /usr/local/lib/node_modules/npm
+      # - name: Uninstall NodeJS and NPM
+      #   run: |
+      #     npm uninstall npm -g
+      #     rm -rf /usr/local/lib/node_modules/npm
 
-      - name: Uninstall Ruby
-        run: |
-          brew uninstall --force --ignore-dependencies ruby
-          brew cleanup -s ruby
-          brew cleanup --prune-prefix
-          RUBY_FRAMEWORK_DIR=$(xcrun --sdk macosx --show-sdk-path)/System/Library/Frameworks/Ruby.framework
-          sudo rm -rf $RUBY_FRAMEWORK_DIR
+      # - name: Uninstall Ruby
+      #   run: |
+      #     brew uninstall --force --ignore-dependencies ruby
+      #     brew cleanup -s ruby
+      #     brew cleanup --prune-prefix
+      #     RUBY_FRAMEWORK_DIR=$(xcrun --sdk macosx --show-sdk-path)/System/Library/Frameworks/Ruby.framework
+      #     sudo rm -rf $RUBY_FRAMEWORK_DIR
 
-      - name: Uninstall Go
-        run: |
-          brew uninstall --force go
-          brew autoremove
-          sudo rm -rf /usr/local/Cellar/go
-          sudo rm -rf /usr/local/go
-          sudo rm -rf /usr/local/opt/go
-          sudo rm -rf /etc/paths.d/go
-          sudo rm -rf /usr/local/bin/go
-          sudo rm -rf /usr/local/bin/gofmt
+      # - name: Uninstall Go
+      #   run: |
+      #     brew uninstall --force go
+      #     brew autoremove
+      #     sudo rm -rf /usr/local/Cellar/go
+      #     sudo rm -rf /usr/local/go
+      #     sudo rm -rf /usr/local/opt/go
+      #     sudo rm -rf /etc/paths.d/go
+      #     sudo rm -rf /usr/local/bin/go
+      #     sudo rm -rf /usr/local/bin/gofmt
 
-      - name: Uninstall Java
-        run: |
-          sudo rm -rf /Library/Java/JavaVirtualMachines/*
-          sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
-          sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
-          unset JAVA_HOME
+      # - name: Uninstall Java
+      #   run: |
+      #     sudo rm -rf /Library/Java/JavaVirtualMachines/*
+      #     sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
+      #     sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
+      #     unset JAVA_HOME
 
       - name: Export XCode SDK Root
         run: echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV

From 9b03a3c7dae77881dc872e8442b1e4fc6ab3378e Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Thu, 20 Feb 2025 03:14:25 +0200
Subject: [PATCH 17/22] undo changes in laguages

---
 .github/workflows/macos-test.yml | 58 ++++++++++++++++----------------
 tools/metacall-environment.sh    |  2 +-
 2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index 771ed2978..db694903a 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -40,36 +40,36 @@ jobs:
         with:
           fetch-depth: 0
 
-      # - name: Uninstall NodeJS and NPM
-      #   run: |
-      #     npm uninstall npm -g
-      #     rm -rf /usr/local/lib/node_modules/npm
+      - name: Uninstall NodeJS and NPM
+        run: |
+          npm uninstall npm -g
+          rm -rf /usr/local/lib/node_modules/npm
 
-      # - name: Uninstall Ruby
-      #   run: |
-      #     brew uninstall --force --ignore-dependencies ruby
-      #     brew cleanup -s ruby
-      #     brew cleanup --prune-prefix
-      #     RUBY_FRAMEWORK_DIR=$(xcrun --sdk macosx --show-sdk-path)/System/Library/Frameworks/Ruby.framework
-      #     sudo rm -rf $RUBY_FRAMEWORK_DIR
+      - name: Uninstall Ruby
+        run: |
+          brew uninstall --force --ignore-dependencies ruby
+          brew cleanup -s ruby
+          brew cleanup --prune-prefix
+          RUBY_FRAMEWORK_DIR=$(xcrun --sdk macosx --show-sdk-path)/System/Library/Frameworks/Ruby.framework
+          sudo rm -rf $RUBY_FRAMEWORK_DIR
 
-      # - name: Uninstall Go
-      #   run: |
-      #     brew uninstall --force go
-      #     brew autoremove
-      #     sudo rm -rf /usr/local/Cellar/go
-      #     sudo rm -rf /usr/local/go
-      #     sudo rm -rf /usr/local/opt/go
-      #     sudo rm -rf /etc/paths.d/go
-      #     sudo rm -rf /usr/local/bin/go
-      #     sudo rm -rf /usr/local/bin/gofmt
+      - name: Uninstall Go
+        run: |
+          brew uninstall --force go
+          brew autoremove
+          sudo rm -rf /usr/local/Cellar/go
+          sudo rm -rf /usr/local/go
+          sudo rm -rf /usr/local/opt/go
+          sudo rm -rf /etc/paths.d/go
+          sudo rm -rf /usr/local/bin/go
+          sudo rm -rf /usr/local/bin/gofmt
 
-      # - name: Uninstall Java
-      #   run: |
-      #     sudo rm -rf /Library/Java/JavaVirtualMachines/*
-      #     sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
-      #     sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
-      #     unset JAVA_HOME
+      - name: Uninstall Java
+        run: |
+          sudo rm -rf /Library/Java/JavaVirtualMachines/*
+          sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
+          sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
+          unset JAVA_HOME
 
       - name: Export XCode SDK Root
         run: echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
@@ -77,7 +77,7 @@ jobs:
       - name: Set up the environment
         run: sh ./tools/metacall-environment.sh $METACALL_INSTALL_OPTIONS
         env:
-          METACALL_INSTALL_OPTIONS: base c rpc file backtrace #cobol go nodejs typescript java ruby wasm python netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
+          METACALL_INSTALL_OPTIONS: base python nodejs typescript java ruby wasm rpc file cobol go backtrace c #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
 
       - name: Configure
         run: |
@@ -85,7 +85,7 @@ jobs:
           . .env
           bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS
         env:
-          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests c rpc file benchmarks install #cobol go python nodejs typescript java ruby wasm netcore5 rust examples pack # v8 coverage
+          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs typescript java ruby wasm rpc file cobol go benchmarks install c # netcore5 rust examples pack # v8 coverage
 
       - name: Build
         working-directory: ./build
diff --git a/tools/metacall-environment.sh b/tools/metacall-environment.sh
index 76d16e018..f77e8bbda 100755
--- a/tools/metacall-environment.sh
+++ b/tools/metacall-environment.sh
@@ -695,7 +695,7 @@ sub_c(){
 			$SUDO_CMD apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing tcc
 			$SUDO_CMD apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main clang-libs=13.0.1-r1 clang-dev=13.0.1-r1
 		fi
-	elif [[ $OSTYPE == 'darwin'* ]]; then
+	elif [ "${OPERATIVE_SYSTEM}" = "Darwin" ]; then
 		brew install libffi
 		brew install llvm@$LLVM_VERSION_STRING
 		brew link llvm@$LLVM_VERSION_STRING --force --overwrite

From edb25258683583e476751bfb1ab03c3b20e1a0fe Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Thu, 20 Feb 2025 04:53:08 +0200
Subject: [PATCH 18/22] fix bug

---
 cmake/InstallLibTCC.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 mode change 100644 => 100755 cmake/InstallLibTCC.cmake

diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake
old mode 100644
new mode 100755
index 664bd5de1..c956a7d1b
--- a/cmake/InstallLibTCC.cmake
+++ b/cmake/InstallLibTCC.cmake
@@ -84,7 +84,7 @@ elseif(PROJECT_OS_FAMILY STREQUAL macos)
 	# AddressSanitizer can not provide additional info.
 	# SUMMARY: AddressSanitizer: BUS (libsystem_c.dylib:x86_64+0x3647db0f) in off32
 
-	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross --extra-cflags="-arch x86_64" --extra-ldflags="-arch x86_64" --cpu=x86_64)
+	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross --cpu=x86_64)
 	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)

From 759d632f316c7c1e421c42c9c0711ed1c1412873 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Thu, 20 Feb 2025 06:10:43 +0200
Subject: [PATCH 19/22] the unix way

---
 .github/workflows/macos-test.yml                 | 4 ++--
 cmake/InstallLibTCC.cmake                        | 4 ++--
 source/loaders/c_loader/source/c_loader_impl.cpp | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/macos-test.yml b/.github/workflows/macos-test.yml
index db694903a..2f86c4e2a 100644
--- a/.github/workflows/macos-test.yml
+++ b/.github/workflows/macos-test.yml
@@ -77,7 +77,7 @@ jobs:
       - name: Set up the environment
         run: sh ./tools/metacall-environment.sh $METACALL_INSTALL_OPTIONS
         env:
-          METACALL_INSTALL_OPTIONS: base python nodejs typescript java ruby wasm rpc file cobol go backtrace c #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
+          METACALL_INSTALL_OPTIONS: base python nodejs typescript java ruby c wasm rpc file cobol go backtrace #netcore5 rust rapidjson funchook swig pack # clangformat v8rep51 coverage
 
       - name: Configure
         run: |
@@ -85,7 +85,7 @@ jobs:
           . .env
           bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS
         env:
-          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs typescript java ruby wasm rpc file cobol go benchmarks install c # netcore5 rust examples pack # v8 coverage
+          METACALL_CONFIGURE_OPTIONS: ${{ matrix.options.build }} ${{ matrix.options.sanitizer }} scripts ports tests python nodejs typescript java ruby c wasm rpc file cobol go benchmarks install # netcore5 rust examples pack # v8 coverage
 
       - name: Build
         working-directory: ./build
diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake
index c956a7d1b..75511dd6c 100755
--- a/cmake/InstallLibTCC.cmake
+++ b/cmake/InstallLibTCC.cmake
@@ -40,7 +40,7 @@ else()
 endif()
 
 # Configure
-if(PROJECT_OS_FAMILY STREQUAL unix)
+if(PROJECT_OS_FAMILY STREQUAL unix OR PROJECT_OS_FAMILY STREQUAL macos)
 	if(OPTION_BUILD_MUSL)
 		set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --disable-static --config-musl)
 	else()
@@ -101,7 +101,7 @@ ProcessorCount(N)
 # Build
 if(PROJECT_OS_BSD)
 	set(LIBTCC_BUILD gmake -j${N})
-elseif(PROJECT_OS_FAMILY STREQUAL unix)
+elseif(PROJECT_OS_FAMILY STREQUAL unix OR PROJECT_OS_FAMILY STREQUAL macos)
 	set(LIBTCC_BUILD make -j${N})
 elseif(PROJECT_OS_FAMILY STREQUAL macos)
 	set(LIBTCC_BUILD make -j${N} MACOSX_DEPLOYMENT_TARGET=${PROJECT_OS_VERSION})
diff --git a/source/loaders/c_loader/source/c_loader_impl.cpp b/source/loaders/c_loader/source/c_loader_impl.cpp
index 4ad6689bf..a506a8d17 100644
--- a/source/loaders/c_loader/source/c_loader_impl.cpp
+++ b/source/loaders/c_loader/source/c_loader_impl.cpp
@@ -64,8 +64,8 @@ namespace fs = std::experimental::filesystem;
 #include <libtcc.h>
 
 /* LibClang */
-#include <clang-c/CXString.h>
 #include <clang-c/Index.h>
+#include <clang-c/CXString.h>
 
 typedef struct loader_impl_c_type
 {

From 33034f26d6a122cc9cb6010c10bb5e2a195ed96f Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Thu, 20 Feb 2025 06:11:46 +0200
Subject: [PATCH 20/22] undo changes made in macos part

---
 cmake/InstallLibTCC.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake
index 75511dd6c..d7269b2d2 100755
--- a/cmake/InstallLibTCC.cmake
+++ b/cmake/InstallLibTCC.cmake
@@ -84,7 +84,7 @@ elseif(PROJECT_OS_FAMILY STREQUAL macos)
 	# AddressSanitizer can not provide additional info.
 	# SUMMARY: AddressSanitizer: BUS (libsystem_c.dylib:x86_64+0x3647db0f) in off32
 
-	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross --cpu=x86_64)
+	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross)
 	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)

From cdb8d8b991dc649b96a88fb4df9ec4e58dc253c3 Mon Sep 17 00:00:00 2001
From: bishoy <bishoyw.fathy@gmail.com>
Date: Thu, 20 Feb 2025 09:06:16 +0200
Subject: [PATCH 21/22] adding debuging prints

---
 cmake/InstallLibTCC.cmake              | 7 ++++---
 source/loaders/c_loader/CMakeLists.txt | 4 +++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake
index d7269b2d2..2537423b4 100755
--- a/cmake/InstallLibTCC.cmake
+++ b/cmake/InstallLibTCC.cmake
@@ -40,7 +40,7 @@ else()
 endif()
 
 # Configure
-if(PROJECT_OS_FAMILY STREQUAL unix OR PROJECT_OS_FAMILY STREQUAL macos)
+if(PROJECT_OS_FAMILY STREQUAL unix)
 	if(OPTION_BUILD_MUSL)
 		set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --disable-static --config-musl)
 	else()
@@ -83,8 +83,9 @@ elseif(PROJECT_OS_FAMILY STREQUAL macos)
 	# r12 = 0x0000000000000000  r13 = 0x00007ffee8c29fe0  r14 = 0x000000010bb13c50  r15 = 0x000000000000053b
 	# AddressSanitizer can not provide additional info.
 	# SUMMARY: AddressSanitizer: BUS (libsystem_c.dylib:x86_64+0x3647db0f) in off32
-
-	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross)
+	set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
+    message(STATUS "macOS universal (x86_64 / arm64) build")
+	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} CMAKE_OSX_ARCHITECTURES "x86_64" --enable-cross)
 	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)
diff --git a/source/loaders/c_loader/CMakeLists.txt b/source/loaders/c_loader/CMakeLists.txt
index cc2c09210..509e17dce 100644
--- a/source/loaders/c_loader/CMakeLists.txt
+++ b/source/loaders/c_loader/CMakeLists.txt
@@ -17,12 +17,14 @@ endif()
 find_package(LibTCC)
 
 if(NOT LIBTCC_FOUND)
+	message(Status "###########checking in install libtcc###########")
 	include(InstallLibTCC)
-
+	message(Status "###########Done checking###########")
 	if(NOT LIBTCC_FOUND)
 		message(SEND_ERROR "TCC library not found")
 		return()
 	endif()
+	message(Status "###########Lib tcc found###########")
 endif()
 
 find_package(LibClang)

From 9d1398c2153cdb9995055602df846cdd1919516f Mon Sep 17 00:00:00 2001
From: Bishoywadea <bishoyw.fathy@gmail.com>
Date: Fri, 21 Feb 2025 01:48:45 +0200
Subject: [PATCH 22/22] trying with older version of tcc

---
 cmake/InstallLibTCC.cmake | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/cmake/InstallLibTCC.cmake b/cmake/InstallLibTCC.cmake
index 2537423b4..523166170 100755
--- a/cmake/InstallLibTCC.cmake
+++ b/cmake/InstallLibTCC.cmake
@@ -83,10 +83,9 @@ elseif(PROJECT_OS_FAMILY STREQUAL macos)
 	# r12 = 0x0000000000000000  r13 = 0x00007ffee8c29fe0  r14 = 0x000000010bb13c50  r15 = 0x000000000000053b
 	# AddressSanitizer can not provide additional info.
 	# SUMMARY: AddressSanitizer: BUS (libsystem_c.dylib:x86_64+0x3647db0f) in off32
-	set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
-    message(STATUS "macOS universal (x86_64 / arm64) build")
-	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} CMAKE_OSX_ARCHITECTURES "x86_64" --enable-cross)
-	elseif(PROJECT_OS_FAMILY STREQUAL win32)
+
+	set(LIBTCC_CONFIGURE ./configure --prefix=${LIBTCC_INSTALL_PREFIX} ${LIBTCC_DEBUG} --enable-cross) # --disable-static
+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()
@@ -102,7 +101,7 @@ ProcessorCount(N)
 # Build
 if(PROJECT_OS_BSD)
 	set(LIBTCC_BUILD gmake -j${N})
-elseif(PROJECT_OS_FAMILY STREQUAL unix OR PROJECT_OS_FAMILY STREQUAL macos)
+elseif(PROJECT_OS_FAMILY STREQUAL unix)
 	set(LIBTCC_BUILD make -j${N})
 elseif(PROJECT_OS_FAMILY STREQUAL macos)
 	set(LIBTCC_BUILD make -j${N} MACOSX_DEPLOYMENT_TARGET=${PROJECT_OS_VERSION})
@@ -126,7 +125,7 @@ else()
 endif()
 
 set(LIBTCC_TARGET libtcc-depends)
-set(LIBTCC_COMMIT_SHA "f8bd136")
+set(LIBTCC_COMMIT_SHA "afc1362")
 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}")
@@ -146,8 +145,8 @@ set(LIBTTC_RUNTIME_FILES
 # LibTCC Proejct
 ExternalProject_Add(${LIBTCC_TARGET}
 	DOWNLOAD_NAME		tinycc.tar.gz
-	URL					https://github.com/Bishoywadea/tinycc/archive/${LIBTCC_COMMIT_SHA}.tar.gz
-	URL_MD5				1031bd56e751ce19bae85bd86a82f107
+	URL					https://github.com/metacall/tinycc/archive/${LIBTCC_COMMIT_SHA}.tar.gz
+	URL_MD5				5582b17ee5848aeec28bee13773843f7
 	CONFIGURE_COMMAND	${LIBTCC_CONFIGURE}
 	BUILD_COMMAND		${LIBTCC_BUILD}
 	BUILD_IN_SOURCE		true
@@ -189,4 +188,4 @@ set(LIBTCC_FOUND		TRUE)
 
 mark_as_advanced(LIBTCC_INCLUDE_DIR LIBTCC_LIBRARY)
 
-message(STATUS "Installing LibTCC ${LIBTCC_COMMIT_SHA}")
+message(STATUS "Installing LibTCC ${LIBTCC_COMMIT_SHA}")
\ No newline at end of file