Skip to content

Commit

Permalink
Add Windows Clang build to CI
Browse files Browse the repository at this point in the history
Also bump SBCL versions to 2.4.6.
  • Loading branch information
kartik-s committed Jul 5, 2024
1 parent 52e9bf8 commit 2258f78
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v1
with:
repository: sbcl/sbcl
ref: sbcl-2.4.5
ref: sbcl-2.4.6
path: sbcl
- name: install host sbcl
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v1
with:
repository: sbcl/sbcl
ref: ${{ matrix.arch == 'arm64' && 'sbcl-2.4.5' || 'x86-null-tn' }}
ref: ${{ matrix.arch == 'arm64' && 'sbcl-2.4.6' || 'x86-null-tn' }}
path: sbcl
- name: install host sbcl
run: brew install sbcl
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ jobs:

runs-on: windows-latest

timeout-minutes: 60
strategy:
matrix:
cc: [gcc, clang]
fail-fast: false

defaults:
run:
shell: msys2 {0}
Expand All @@ -16,11 +22,11 @@ jobs:
- uses: actions/checkout@v1
with:
repository: sbcl/sbcl
ref: sbcl-2.4.5
ref: sbcl-2.4.6
path: sbcl
- uses: msys2/setup-msys2@v2
with:
install: mingw-w64-x86_64-gcc make diffutils git python3
install: mingw-w64-x86_64-gcc mingw-w64-x86_64-clang mingw-w64-x86_64-lld make diffutils git python3 dos2unix

- name: install host sbcl
shell: pwsh
Expand All @@ -34,7 +40,9 @@ jobs:
run: |
PATH=$PATH:"/c/Program Files/Steel Bank Common Lisp/1.4.14"
export PATH
./make.sh --xc-host='sbcl --lose-on-corruption --disable-ldb --disable-debugger' --with-sb-linkable-runtime
dos2unix '${{ github.workspace }}\patches\win32-clang-build.patch'
if [ "clang" = "${{ matrix.cc }}" ]; then git apply --verbose '${{ github.workspace }}\patches\win32-clang-build.patch'; fi
CC=${{ matrix.cc }} ./make.sh --xc-host='sbcl --lose-on-corruption --disable-ldb --disable-debugger' --with-sb-linkable-runtime
- name: install quicklisp
working-directory: ../sbcl
run: |
Expand All @@ -48,8 +56,8 @@ jobs:
MSYS2_PATH_TYPE: inherit
run: |
$SBCL_SRC/run-sbcl.sh --script script.lisp
gcc -Wall -fPIC -shared -Wl,--export-all-symbols -o libcalc.dll libcalc.c -Wl,--whole-archive $SBCL_SRC/src/runtime/libsbcl.a -Wl,--no-whole-archive -ladvapi32 -lsynchronization -lws2_32 -lzstd
gcc -Wall -o example example.c -lcalc -L.
${{ matrix.cc }} -Wall -fPIC -shared -Wl,--export-all-symbols -o libcalc.dll libcalc.c -Wl,--whole-archive $SBCL_SRC/src/runtime/libsbcl.a -Wl,--no-whole-archive -ladvapi32 -lsynchronization -lws2_32 -lzstd
${{ matrix.cc }} -Wall -o example example.c -lcalc -L.
mv libcalc.dll $MSYSTEM_PREFIX/bin
cp libcalc.core $MSYSTEM_PREFIX/bin
echo "(+ 1 2)" | ./example.exe | tr -d '\r\n' | grep "> 3> "
Expand Down
58 changes: 58 additions & 0 deletions patches/win32-clang-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
From 4a4dc050d49789e60ab3a71ea85502caf42755e4 Mon Sep 17 00:00:00 2001
From: Kartik Singh <[email protected]>
Date: Fri, 5 Jul 2024 14:22:35 -0700
Subject: [PATCH] Support Clang + PDB on Windows

---
src/runtime/Config.x86-64-win32 | 18 ++++++++++++++++--
src/runtime/hopscotch.c | 3 +--
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/runtime/Config.x86-64-win32 b/src/runtime/Config.x86-64-win32
index 3c922ffd3..b2c75ddd0 100644
--- a/src/runtime/Config.x86-64-win32
+++ b/src/runtime/Config.x86-64-win32
@@ -56,10 +56,24 @@ CFLAGS += -g -W -Wall \
-Wno-unused-function -Wno-unused-parameter -Wno-cast-function-type \
-Wno-type-limits \
-fno-omit-frame-pointer \
- -O5 -m64 -DWINVER=0x0501 \
+ -O3 -m64 -DWINVER=0x0501 \
-D__W32API_USE_DLLIMPORT__

-CC = gcc
+CC ?= gcc
+
+ifeq ($(CC),clang)
+ifneq ($(shell ld.lld --version | head -n 1 | grep LLD),)
+LD=ld.lld
+CFLAGS += -fuse-ld=lld
+endif
+endif
+
+ifeq ($(shell $(CC) -gcodeview 2>&1 | grep codeview),)
+ifeq ($(shell $(LD) -pdb= 2>&1 | grep -- -pdb=),)
+CFLAGS += -gcodeview
+LINKFLAGS += -Wl,-pdb=
+endif
+endif

ifeq ($(shell $(LD) --disable-dynamicbase 2>&1 | grep disable-dynamicbase),)
LINKFLAGS += -Wl,--disable-dynamicbase
diff --git a/src/runtime/hopscotch.c b/src/runtime/hopscotch.c
index 0c8330d65..ccbb53ddc 100644
--- a/src/runtime/hopscotch.c
+++ b/src/runtime/hopscotch.c
@@ -22,8 +22,7 @@
#include <stdint.h>
#include <stdio.h>
#ifdef LISP_FEATURE_WIN32
-/* I don't know where ffs() is prototyped */
-extern int ffs(int);
+#define ffs(x) __builtin_ffs(x)
#else
/* https://www.freebsd.org/cgi/man.cgi?query=fls&sektion=3&manpath=FreeBSD+7.1-RELEASE
says strings.h */
--
2.32.1 (Apple Git-133)

0 comments on commit 2258f78

Please sign in to comment.