[Sbcl-devel] HOWTO: Building on Windows

398 views
Skip to first unread message

Dave Richards

unread,
Jan 25, 2015, 11:27:48 PM1/25/15
to Sbcl-...@lists.sourceforge.net
This message discusses how to build SBCL on Windows using the mingw-w64
toolchain. It requires the use of either Cygwin or MSYS in order to run the
various scripts and makefiles. I chose to use MSYS as it is small and very
easy to install.

The web site:

http://win-builds.org/1.5.0/msys-cygwin.html#_msys_installation

describes how to install either Cygwin or MSYS with mingw-w64.

Follow the 10 steps in:

1.2. MSYS Installation

The default installation folder is C:\MinwGW, but I elected to use C:\MSYS.
According to the documentation, it doesn't matter very much, as long as you
avoid paths with spaces and such.

Upon successful installation, you now have a basic MSYS environment ready.
The next logical step is to install the mingw-w64 toolchain. There are two
approaches you can use:

1. You can follow the steps:

2. Win-builds Installation
3. Change toolchain on-the-fly
4. Set a default toolchain (optional)
5. Check gcc works

>From http://win-builds.org/1.5.0/msys-cygwin.html#_msys_installation. In my
opinion, this is the easier approach. Or,

2. You can go to:

http://mingw-w64.sourceforge.net/download.php

and download the toolchain from the Mingw-builds project - native
toolchains using trunk section of the download page. This is what I did,
because I installed mingw-w64 before I wanted to install MSYS.

If you wish to build both 32-bit and 64-bit versions of SBCL,
you'll need to download both the 32-bit and 64-bit toolchains.

If you use this approach, you'll need to set your path so MSYS
can find the mingw-w64 toolchain of your choice. I added the following to
my .profile in my home directory:

# PATH=.:'/C/Program Files
(x86)/mingw-w64/i686-4.9.2-win32-dwarf-rt_v3-rev1/mingw32/bin':${PATH}

PATH=.:"/C/Program
Files/mingw-w64/x86_64-4.9.2-win32-seh-rt_v3-rev1/mingw64/bin":${PATH}

export PATH

thus, making it easy to switch between toolchains prior to
launching the MSYS shell.

N.B.: MSYS paths don't use drive letters and colons and '\' path component
separators. Drives are specified as /<drive-letter> and path components use
the UNIX '/' convention.

The next step (although I'd be surprised that you would not have already
done this) is to install SBCL, itself: For your convenience, it is located
at:

http://www.sbcl.org/platform-table.html

You now have all of the development tools you need:

1. MSYS,
2. mingw-w64 (either 32-bit and/or 64-bit), and
3. SBCL

By downloading and extracting the SBCL source into a directory of your
choice, the build steps are very easy:

% cd sbcl-1.2.7 (or whichever version you are building)
% sh make.sh (for 32-bit builds)
% sh make.sh --arch=x86-64 (for 64-bit builds)

Before you attempt this on 1.2.7, however, I recommend that you apply the
patches below. It appears that mingw-w64 has gotten rid of signal
emulation, or at least the sigset_t data type. These patches allow the SBCL
run-time to build on mingw-w64.

Good luck!

Dave


diff -rc sbcl-1.2.7/src/runtime/backtrace.c
sbcl-1.2.7.new/src/runtime/backtrace.c
*** sbcl-1.2.7/src/runtime/backtrace.c Wed Dec 31 11:09:09 2014
--- sbcl-1.2.7.new/src/runtime/backtrace.c Sun Jan 25 17:12:02 2015
***************
*** 498,504 ****
--- 498,506 ----
void
describe_thread_state(void)
{
+ #ifndef LISP_FEATURE_WIN32
sigset_t mask;
+ #endif
struct thread *thread = arch_os_get_current_thread();
struct interrupt_data *data = thread->interrupt_data;
#ifndef LISP_FEATURE_WIN32
diff -rc sbcl-1.2.7/src/runtime/pthreads_win32.h
sbcl-1.2.7.new/src/runtime/pthreads_win32.h
*** sbcl-1.2.7/src/runtime/pthreads_win32.h Wed Dec 31 11:09:10 2014
--- sbcl-1.2.7.new/src/runtime/pthreads_win32.h Sun Jan 25 17:30:37 2015
***************
*** 94,100 ****
#define SIG_UNBLOCK 2
#define SIG_SETMASK 3
#ifdef PTHREAD_INTERNALS
- int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
#endif

/* 1a - Thread non-portable */
--- 94,99 ----
***************
*** 362,387 ****
int sem_destroy(sem_t *sem);

#ifndef PTHREAD_INTERNALS
- static inline int pthread_sigmask(int how, const sigset_t *set, sigset_t
*oldset)
- {
- pthread_t self = pthread_self();
- if (oldset)
- *oldset = self->blocked_signal_set;
- if (set) {
- switch (how) {
- case SIG_BLOCK:
- self->blocked_signal_set |= *set;
- break;
- case SIG_UNBLOCK:
- self->blocked_signal_set &= ~(*set);
- break;
- case SIG_SETMASK:
- self->blocked_signal_set = *set;
- break;
- }
- }
- return 0;
- }

/* Make speed-critical TLS access inline.

--- 361,366 ----


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Sbcl-devel mailing list
Sbcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-devel

Fanael Linithien

unread,
Jan 26, 2015, 9:27:44 AM1/26/15
to Sbcl-...@lists.sourceforge.net
2015-01-26 5:26 GMT+01:00 Dave Richards <da...@synergy.org>:
> Before you attempt this on 1.2.7, however, I recommend that you apply the
> patches below. It appears that mingw-w64 has gotten rid of signal
> emulation, or at least the sigset_t data type. These patches allow the SBCL
> run-time to build on mingw-w64.
>
> [snip]

It hasn't, sigset_t is still where it always was, in sys/types.h.
If the problem you're seeing is what I think it is, cherry pick
"cd4ef0868 Fix Win32 build failure when winpthreads are installed"
instead.
Reply all
Reply to author
Forward
0 new messages