Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d420577
Add libffi build support for Windows C loader
shaheeramjad Jul 11, 2026
5f0b22b
Enable C loader in Windows CI workflow
shaheeramjad Jul 13, 2026
f35b24d
Add libffi and LLVM/libclang setup for Windows C loader
shaheeramjad Jul 15, 2026
9f6cd5e
Fix libclang setup: use official LLVM prebuilt archive instead of choco
shaheeramjad Jul 15, 2026
2bb872a
Fix libtcc Windows MSVC: skip CMake configure step
shaheeramjad Jul 15, 2026
15b1084
Fix libtcc Windows build: use cl compiler in build-tcc.bat
shaheeramjad Jul 15, 2026
c6ab9a6
Fix libtcc Windows build: run build-tcc.bat from win32 directory
shaheeramjad Jul 15, 2026
43cdf09
Fix libtcc Windows install: convert path separators for build-tcc.bat
shaheeramjad Jul 15, 2026
c25e41a
Fix libtcc Windows: correct dll name and install path for build-tcc.b…
shaheeramjad Jul 16, 2026
a4bd56f
Fix libtcc Windows runtime path: build-tcc.bat puts files in lib/ not…
shaheeramjad Jul 16, 2026
3bfa700
Fix libtcc Windows include dir: use libtcc/ instead of include/ to av…
shaheeramjad Jul 16, 2026
5d00a8f
Add debug step to check libffi output structure
shaheeramjad Jul 16, 2026
bd55f22
Add debug step to inspect libffi output and CMakeConfig
shaheeramjad Jul 16, 2026
d2db712
Remove debug step to inspect libffi output and CMakeConfig
shaheeramjad Jul 17, 2026
56269a2
Fix: Apply Set-C hardening
shaheeramjad Jul 23, 2026
621dee8
Add Test Workflow
shaheeramjad Jul 30, 2026
c618cc2
Make some changes in test file
shaheeramjad Jul 30, 2026
1eb0351
Make some changes in test file
shaheeramjad Jul 30, 2026
9ddb78f
Make some changes in test file
shaheeramjad Jul 30, 2026
f7c4a0d
Make some changes in test file
shaheeramjad Jul 30, 2026
a243077
Make some changes in test file
shaheeramjad Jul 30, 2026
35f6d92
Make some changes in test file
shaheeramjad Jul 30, 2026
3b2be70
Make some changes in test file
shaheeramjad Jul 30, 2026
ba763c0
Make some changes in test file
shaheeramjad Jul 30, 2026
d6e0022
Make some changes in test file
shaheeramjad Jul 30, 2026
c731865
Make some changes in test file
shaheeramjad Jul 30, 2026
e43852f
Make some changes in test file
shaheeramjad Jul 30, 2026
48560c6
Make some changes in test file
shaheeramjad Jul 30, 2026
6f0ab36
Make some changes in test file
shaheeramjad Jul 30, 2026
c1a4032
Make some changes in test file
shaheeramjad Jul 30, 2026
2c353eb
Make some changes in test file
shaheeramjad Jul 30, 2026
688c56e
Fix libffi header template setup
shaheeramjad Jul 30, 2026
2e335a3
Make some changes in test file
shaheeramjad Jul 30, 2026
e5a119a
Make some changes in test file
shaheeramjad Jul 30, 2026
9c1f10c
Define static linkage for libffi MSVC build
shaheeramjad Jul 30, 2026
f2b85d1
Fix Windows C loader libffi static build
shaheeramjad Jul 30, 2026
4649cd9
Fix Windows environment setup failures
shaheeramjad Jul 30, 2026
1cf53e2
Fix libffi Bash invocation on Windows
shaheeramjad Jul 30, 2026
be96a38
Link c_loader with TinyCC import library on Windows
shaheeramjad Jul 30, 2026
6ead510
Fix failing tests
shaheeramjad Jul 30, 2026
be8be34
Fix Windows TinyCC resolution of libffi symbols
shaheeramjad Jul 30, 2026
99557e2
Small Fix
shaheeramjad Jul 30, 2026
0641ce1
Remove investigation workflow
shaheeramjad Jul 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/windows-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,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 # 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: |
Expand All @@ -58,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 # 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
Expand All @@ -81,4 +81,4 @@ jobs:
workflow_file_name: ci.yml
wait_workflow: true
client_payload: '{"ref": "${{ github.head_ref || github.ref_name }}"}'
ref: master
ref: master
59 changes: 51 additions & 8 deletions cmake/InstallLibTCC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 ./win32/build-tcc.bat -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")
Expand All @@ -135,19 +136,52 @@ 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")
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}")
set(LIBTTC_RUNTIME_PATH "${LIBTCC_INSTALL_PREFIX}/lib/tcc")
set(LIBTTC_RUNTIME_INCLUDE_PATH "${LIBTTC_RUNTIME_PATH}/include")
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()
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_FILES
"${LIBTTC_RUNTIME_PATH}/libtcc1.a"
"${LIBTTC_RUNTIME_PATH}/bcheck.o"
"${LIBTTC_RUNTIME_PATH}/bt-exe.o"
"${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()

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
Expand All @@ -159,8 +193,9 @@ 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_RUNTIME_FILES} "${PROJECT_OUTPUT_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy "${LIBTTC_LIBRARY_SOURCE_PATH}" "${LIBTTC_LIBRARY_PATH}"
${LIBTCC_COPY_LINK_LIBRARY_COMMAND}
${LIBTCC_COPY_RUNTIME_FILES_COMMAND}
)

# Install Library
Expand Down Expand Up @@ -188,8 +223,16 @@ install(DIRECTORY
COMPONENT runtime
)

set(LIBTCC_INCLUDE_DIR "${LIBTCC_INSTALL_PREFIX}/include")
set(LIBTCC_LIBRARY "${LIBTTC_LIBRARY_PATH}")
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()
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)
Expand Down
1 change: 1 addition & 0 deletions source/loaders/c_loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ target_link_libraries(${target}

target_compile_definitions(${target}
PRIVATE
$<$<BOOL:${LIBFFI_STATIC_BUILD}>:FFI_STATIC_BUILD>

PUBLIC
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:${target_upper}_STATIC_DEFINE>
Expand Down
5 changes: 5 additions & 0 deletions source/loaders/c_loader/source/c_loader_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const void *>(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())
{
Expand Down
Loading