Fix windows SDK builds (#126)

* Make build work on Windows

* re-enable windows build workflow

* fix make check

* fix tar_from_installation.sh and dist target

* Review fixups

* No -j4 on Windows

* Get rid of -j4 everywhere in Makefile
pull/128/head
Vladimir Vukicevic 5 years ago committed by GitHub
parent 41a660013f
commit 6c59b6487c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,9 +18,7 @@ jobs:
os:
- ubuntu-latest
- macos-latest
# Build still fails on windows - sysroot path passed to compiler-rt
# is incorrect.
# - windows-latest
- windows-latest
steps:
- uses: actions/checkout@v1
with:
@ -35,10 +33,10 @@ jobs:
run: sudo apt install ninja-build
if: matrix.os == 'ubuntu-latest'
- name: Build
run: sudo make -j4 package
run: sudo make package
if: matrix.os != 'windows-latest'
- name: Build
run: make -j4 package
run: make package
shell: bash
if: matrix.os == 'windows-latest'
- name: Run the testsuite

1
.gitignore vendored

@ -1 +1,2 @@
build
dist

@ -3,17 +3,43 @@
ROOT_DIR=${CURDIR}
LLVM_PROJ_DIR?=$(ROOT_DIR)/src/llvm-project
# Windows needs munging
ifeq ($(OS),Windows_NT)
PREFIX?=c:/wasi-sdk
# we need to explicitly call bash -c for makefile $(shell ...), otherwise we'll try under
# who knows what
BASH?=bash -c
ifeq (x$(MSYSTEM),x)
$(error On Windows, this Makefile only works in MSYS2 environments such as git-bash.)
endif
# msys needs any /-prefixed arguments, or =/ containing, to turn into //
# because it tries to path-expand the / into the msys root. // escapes this.
ESCAPE_SLASH=/
# assuming we're running under msys2 (git-bash), PATH needs /c/foo format directories (because
# it itself is :-delimited)
PATH_PREFIX=$(shell cygpath.exe -u $(PREFIX))
endif
PREFIX?=/opt/wasi-sdk
PATH_PREFIX?=$(PREFIX)
ESCAPE_SLASH?=
BASH?=
CLANG_VERSION=$(shell ./llvm_version.sh $(LLVM_PROJ_DIR))
VERSION:=$(shell ./version.sh)
CLANG_VERSION=$(shell $(BASH) ./llvm_version.sh $(LLVM_PROJ_DIR))
VERSION:=$(shell $(BASH) ./version.sh)
DEBUG_PREFIX_MAP=-fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION)
default: build
@echo "Use -fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION)"
check:
cd tests && PATH="$(PREFIX)/bin:$$PATH" ./run.sh
cd tests && PATH="$(PATH_PREFIX)/bin:$$PATH" ./run.sh
clean:
rm -rf build $(PREFIX)
@ -109,7 +135,7 @@ build/libcxx.BUILT: build/llvm.BUILT build/compiler-rt.BUILT build/wasi-libc.BUI
cd build/libcxx && cmake -G Ninja $(LIBCXX_CMAKE_FLAGS) \
-DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP)" \
-DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP)" \
-DLIBCXX_LIBDIR_SUFFIX=/wasm32-wasi \
-DLIBCXX_LIBDIR_SUFFIX=$(ESCAPE_SLASH)/wasm32-wasi \
$(LLVM_PROJ_DIR)/libcxx
ninja $(NINJA_FLAGS) -v -C build/libcxx
# Do the install.
@ -147,7 +173,7 @@ build/libcxxabi.BUILT: build/libcxx.BUILT build/llvm.BUILT
cd build/libcxxabi && cmake -G Ninja $(LIBCXXABI_CMAKE_FLAGS) \
-DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP)" \
-DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP)" \
-DLIBCXXABI_LIBDIR_SUFFIX=/wasm32-wasi \
-DLIBCXXABI_LIBDIR_SUFFIX=$(ESCAPE_SLASH)/wasm32-wasi \
$(LLVM_PROJ_DIR)/libcxxabi
ninja $(NINJA_FLAGS) -v -C build/libcxxabi
# Do the install.
@ -171,7 +197,7 @@ package: build/package.BUILT
build/package.BUILT: build strip
mkdir -p dist
command -v dpkg-deb >/dev/null && ./deb_from_installation.sh $(shell pwd)/dist || true
./tar_from_installation.sh $(shell pwd)/dist
./tar_from_installation.sh "$(shell pwd)/dist" "$(VERSION)" "$(PATH_PREFIX)"
touch build/package.BUILT
.PHONY: default clean build strip package check

@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -ex
if [ -n "$1" ]; then
OUTDIR=$1
else
@ -12,6 +13,12 @@ else
VERSION=`./version.sh`
fi
if [ -n "$3" ]; then
INSTALL_DIR="$3"
else
INSTALL_DIR=/opt/wasi-sdk
fi
PKGDIR=build/wasi-sdk-$VERSION
case "$(uname -s)" in
@ -22,8 +29,13 @@ case "$(uname -s)" in
*) MACHINE="UNKNOWN"
esac
if [ ! -d $INSTALL_DIR ] ; then
echo "Directory $INSTALL_DIR doesn't exist. Nothing to copy from."
exit 1
fi
rm -rf $PKGDIR
cp -R /opt/wasi-sdk $PKGDIR
cp -R $INSTALL_DIR $PKGDIR
cd build
tar czf $OUTDIR/wasi-sdk-$VERSION\-$MACHINE.tar.gz wasi-sdk-$VERSION

@ -8,10 +8,16 @@ set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR wasm32)
set(triple wasm32-wasi)
set(CMAKE_C_COMPILER ${WASI_SDK_PREFIX}/bin/clang)
set(CMAKE_CXX_COMPILER ${WASI_SDK_PREFIX}/bin/clang++)
set(CMAKE_AR ${WASI_SDK_PREFIX}/bin/llvm-ar CACHE STRING "wasi-sdk build")
set(CMAKE_RANLIB ${WASI_SDK_PREFIX}/bin/llvm-ranlib CACHE STRING "wasi-sdk build")
if(WIN32)
set(WASI_HOST_EXE_SUFFIX ".exe")
else()
set(WASI_HOST_EXE_SUFFIX "")
endif()
set(CMAKE_C_COMPILER ${WASI_SDK_PREFIX}/bin/clang${WASI_HOST_EXE_SUFFIX})
set(CMAKE_CXX_COMPILER ${WASI_SDK_PREFIX}/bin/clang++${WASI_HOST_EXE_SUFFIX})
set(CMAKE_AR ${WASI_SDK_PREFIX}/bin/llvm-ar${WASI_HOST_EXE_SUFFIX} CACHE STRING "wasi-sdk build")
set(CMAKE_RANLIB ${WASI_SDK_PREFIX}/bin/llvm-ranlib${WASI_HOST_EXE_SUFFIX} CACHE STRING "wasi-sdk build")
set(CMAKE_C_COMPILER_TARGET ${triple} CACHE STRING "wasi-sdk build")
set(CMAKE_CXX_COMPILER_TARGET ${triple} CACHE STRING "wasi-sdk build")
set(CMAKE_C_FLAGS "-v" CACHE STRING "wasi-sdk build")

Loading…
Cancel
Save