Skip to content

Commit 1724885

Browse files
committed
Add a CI builder for Windows building WASIp2
Should help fix a few issues that have cropped up on WebAssembly/wasi-sdk#580
1 parent 98f9a6a commit 1724885

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ jobs:
3737
os: windows-2025
3838
clang_version: 20.1.8
3939
upload: windows-clang-20
40-
args: -DBUILD_SHARED=OFF
40+
- name: Build on WASIp2 Windows x86_64
41+
os: windows-2025
42+
clang_version: 20.1.8
43+
args: -DTARGET_TRIPLE=wasm32-wasip2
4144

4245
# Other versions of LLVM
4346
- name: Build with LLVM 11

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ endfunction()
218218
# the sysroot. The `*-shared` library is compiled with `-fPIC`.
219219
function(add_object_library name)
220220
add_library(${name}-shared OBJECT EXCLUDE_FROM_ALL ${ARGN})
221-
set_target_properties(${name}-shared PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
221+
set_pic(${name}-shared)
222222
target_compile_options(${name}-shared PRIVATE -fvisibility=default)
223223
add_dependencies(${name}-shared sysroot_inc)
224224
clang_format_target(${name}-shared)
@@ -243,6 +243,7 @@ endfunction()
243243
# and then ensures compile options are configured.
244244
function(add_internal_shared_library name)
245245
add_library(${name} SHARED EXCLUDE_FROM_ALL ${ARGN})
246+
set_pic(${name})
246247
target_link_libraries(${name} PUBLIC musl-top-half-interface)
247248
add_dependencies(${name} sysroot-c builtins)
248249
target_compile_options(${name} PRIVATE -fvisibility=default)
@@ -278,6 +279,14 @@ function(sysroot_lib target file)
278279
endif()
279280
endfunction()
280281

282+
function(set_pic target)
283+
set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
284+
# Windows needs an extra nudge to pass `-fPIC`
285+
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
286+
target_compile_options(${target} PRIVATE -fPIC)
287+
endif()
288+
endfunction()
289+
281290
# =============================================================================
282291
# subdirectories
283292
#

cmake/ba-download.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ function(ba_download target repo version)
2424
endif()
2525

2626
if (target STREQUAL wasmtime)
27-
set(fmt xz)
27+
set(fmt tar.xz)
28+
elseif ((target STREQUAL wasm-component-ld) AND (os STREQUAL windows))
29+
set(fmt zip)
2830
else()
29-
set(fmt gz)
31+
set(fmt tar.gz)
3032
endif()
3133

3234
if (target STREQUAL wit-bindgen)
@@ -40,7 +42,7 @@ function(ba_download target repo version)
4042
ExternalProject_Add(
4143
${target}
4244
EXCLUDE_FROM_ALL ON
43-
URL "${repo}/releases/download/${tag}/${target}-${version}-${arch}-${os}.tar.${fmt}"
45+
URL "${repo}/releases/download/${tag}/${target}-${version}-${arch}-${os}.${fmt}"
4446
CONFIGURE_COMMAND ""
4547
BUILD_COMMAND ""
4648
INSTALL_COMMAND ""

libc-bottom-half/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ foreach(file crt/crt1.c
198198
# create a custom target for each file
199199
add_library(${filename}.o OBJECT ${file})
200200
target_link_libraries(${filename}.o PUBLIC musl-top-half-interface)
201-
set_target_properties(${filename}.o PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
201+
set_pic(${filename}.o)
202202
target_compile_options(${filename}.o PRIVATE -fvisibility=default)
203203

204204
# add a custom command to compile the file

0 commit comments

Comments
 (0)