From 368d079d24b593b1d2b58f89018840cc40c4f3fa Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 22 Oct 2018 17:45:04 -0600 Subject: [PATCH 1/6] adjust build for BSDs, MinGW cross-compile, and more configuration Includes joint work with @abmclin, @pmatos, and @jessealama. original commit: 2649600c68ff57efb63d6d5d10c9d9f73368f59a --- BUILDING | 91 +++++++++++++++++++++++++++++++++----- LOG | 7 +++ c/Mf-a6fb | 13 +++--- c/Mf-a6le | 13 +++--- c/Mf-a6nb | 12 ++++-- c/Mf-a6nt | 28 +++++++++++- c/Mf-a6ob | 13 +++--- c/Mf-a6osx | 13 +++--- c/Mf-a6s2 | 13 +++--- c/Mf-arm32le | 13 +++--- c/Mf-base | 16 +++++-- c/Mf-i3fb | 13 +++--- c/Mf-i3le | 13 +++--- c/Mf-i3nb | 12 ++++-- c/Mf-i3nt | 28 +++++++++++- c/Mf-i3ob | 13 +++--- c/Mf-i3osx | 13 +++--- c/Mf-i3qnx | 13 +++--- c/Mf-i3s2 | 13 +++--- c/Mf-ppc32le | 13 +++--- c/Mf-ta6fb | 13 +++--- c/Mf-ta6le | 13 +++--- c/Mf-ta6nb | 12 ++++-- c/Mf-ta6nt | 28 +++++++++++- c/Mf-ta6ob | 13 +++--- c/Mf-ta6osx | 13 +++--- c/Mf-ta6s2 | 13 +++--- c/Mf-ti3fb | 13 +++--- c/Mf-ti3le | 13 +++--- c/Mf-ti3nb | 12 ++++-- c/Mf-ti3nt | 28 +++++++++++- c/Mf-ti3ob | 13 +++--- c/Mf-ti3osx | 13 +++--- c/Mf-ti3s2 | 13 +++--- c/Mf-tppc32le | 13 +++--- c/build.bat | 30 +++++++++++++ c/expeditor.c | 17 +++++++- c/externs.h | 15 ++++--- c/globals.h | 2 +- c/main.c | 5 ++- c/nocurses.h | 24 +++++++++++ c/scheme.c | 7 ++- c/schsig.c | 2 +- c/segment.h | 6 ++- c/statics.c | 5 +++ c/stats.c | 51 ++++++++++++++++++++-- c/system.h | 4 ++ c/thread.c | 4 ++ c/types.h | 20 +++++++-- c/version.h | 20 +++++++-- configure | 96 +++++++++++++++++++++++++++++++++++++++-- makefiles/Makefile.in | 13 ++++++ makefiles/Mf-install.in | 22 +++++++++- s/a6nb.def | 2 +- s/a6ob.def | 2 +- s/i3nt.def | 4 +- s/ta6nb.def | 2 +- s/ta6ob.def | 2 +- s/ti3nt.def | 4 +- 59 files changed, 753 insertions(+), 192 deletions(-) create mode 100644 c/build.bat create mode 100644 c/nocurses.h diff --git a/BUILDING b/BUILDING index 89b1b40224..1a7b85ddc2 100644 --- a/BUILDING +++ b/BUILDING @@ -40,8 +40,8 @@ Prerequisites: * GNU Make * gcc -* Header files and libraries for ncurses -* Header files and libraries for X windows +* Header files and libraries for ncurses [unless --disable-curses] +* Header files and libraries for X windows [unless --disable-x11] * Header files and libraries for uuid Uninstalling on Unix-like systems is as simple as running: @@ -75,7 +75,7 @@ That's why the boot and header files are packaged with the sources. if successful, creates several files and directories: * The directory nanopass containing the Nanopass Infrastructure, - retrieved from github. + retrieved from GitHub. * A make file, Makefile, in the root (top level) directory. @@ -117,9 +117,18 @@ The make file supports several targets: Set SCHEMEHEAPDIRS to /usr/lib/csv%v/%m:/usr/local/lib/csv%v/%m on Unix-like systems and to %x/../../boot/%m on Windows systems. - To run Chez Scheme without installing, you need to tell the executable - where to find the boot files. This can be done via command-line - arguments, e.g.: + Alternatively, if you have a build before the changes at full path + , use + + make from-orig ORIG= + + To run Chez Scheme without installing, you need to tell the + executable where to find the boot files. The run target of the + makefile will do that + + make run + + or this can be done manually via command-line arguments, e.g.: $W/bin/$M/scheme -b $W/boot/$M/petite.boot -b $W/boot/$M/scheme.boot @@ -194,15 +203,41 @@ The make file supports several targets: 'make distclean' removes nanopass, Makefile, and all workareas. +OTHER UNIX VARIANTS + +To build on Unix variants other than Linux and OS X, you will first +need to build boot files on a Linux or OS X machine. On that machine, +after building Chez Scheme, create boot files for the target machine + with: + + make boot XM= + +Copy the generated boot/ directory to the target machine, +adding to or replacing the boot directory with pre-built boot files +there, and then build as on Linux. + +Remember to use gmake if make is not GNU make. If you run into linker +trouble, try running configure with --libkernel so that the build +avoids running ld directly. + +On OpenBSD, Chez Scheme must be built and installed on a filesystem +that is mounted with wxneeded. + +On NetNSD, note that the makefiles run "paxctl +m" to enable WX pages +(i.e., pages that have both write and execute enabled). + WINDOWS Building Chez Scheme under 64-bit Windows with Bash/WSL, MinGW/MSYS, or Cygwin follows the instructions above, except that 'make install' -and 'make uninstall' are not supported. On Bash/WSL, the build -directory must be in a location with a Windows path such as /mnt/c, -and the 'OS' environment variable must be set to 'Windows_NT' to -indicate a build for Windows, as opposed to a build for Linux on -Windows: +and 'make uninstall' are not supported. Alternatively, the main Chez +Scheme executable can be built from the Windows command line or +cross-compiled using MinGW as described further below. + +On Bash/WSL, the build directory must be in a location with a Windows +path such as /mnt/c, and the 'OS' environment variable must be set to +'Windows_NT' to indicate a build for Windows, as opposed to a build +for Linux on Windows: env OS=Windows_NT ./configure env OS=Windows_NT make @@ -267,3 +302,37 @@ the Cygwin values are incompatible with the Microsoft C Runtime Library. Use 'make test' described above to run the tests. + +WINDOWS EXECUTABLE VIA COMMAND PROMPT + +To build the Chez Scheme executable using Microsoft Visual Studio, +first set up command-line tools. The c\vs.bat script can help if you +supply amd64 for a 64-bit build or x86 for a 32-bit build: + + c\vs.bat amd64 + +Then, run c\build/bat with a machine name, either ta6nt (64-bit +threaded), a6nt (64-bit non-threaded), ti3nt (32-bit threaded), or +i3nt (32-bit non-threaded): + + c\build.bat ta6nt + +The resulting executable in \bin\ relies on +bootfiles in ..\boot\ relative to the executable. + +CROSS-COMPILING THE WINDOWS EXECUTABLE + +To cross-compile the main Chez Scheme executable for Windows using +MinGW, specify suitable build tools to configure, perhaps using +--toolprefix= like this: + + ./configure -m=ta6nt --threads --toolprefix=x86_64-w64-mingw32- + +Then, make with c/Mf- while supplying cross=t and o=o, +possibly like this: + + (cd ta6nt/c && make -f Mf-ta6nt cross=t o=o) + +The executable is written to /bin/, and it should be +installed with bootfiles in ../boot// relative to the +executable. diff --git a/LOG b/LOG index 75de93e72d..092a722f10 100644 --- a/LOG +++ b/LOG @@ -1374,3 +1374,10 @@ BUILDING, c/vs.bat, wininstall/locate-vcredist.bat - fixed open-string-input-port on immutable strings cpnanopass.ss, io.ms, release_notes.stex +- restore {Free,Open,Net}BSD build, support Windows cross-compile + via MinGW, add configuration options, and add helper makefile targets + expenditor.c, thread.c, stats.c, statics.c, scheme.c, main.c, types.h, + externs.h, globals.h, nocurses.h, version.h, system.h, segment.h, + a6ob.def, ta6ob.def, a6nb.def, ta6nb.def, i3nt.def, ti3nt.def, + c/Mf-*, build.bat, makefiles/Makefile.in, makefiles/Mf-install.in, + s/update-revision, BUILDING diff --git a/c/Mf-a6fb b/c/Mf-a6fb index 92bffb6814..43bf5900ba 100644 --- a/c/Mf-a6fb +++ b/c/Mf-a6fb @@ -17,7 +17,7 @@ m = a6fb Cpu = X86_64 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm -lncurses +mdclib = -L/usr/local/lib -liconv -lm ${ncursesLib} -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Wextra -Werror -O ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-a6le b/c/Mf-a6le index 1959da5af5..1564cce947 100644 --- a/c/Mf-a6le +++ b/c/Mf-a6le @@ -16,7 +16,7 @@ m = a6le Cpu = X86_64 -mdclib = -lm -ldl -lncurses -lrt -luuid +mdclib = -lm -ldl ${ncursesLib} -lrt -luuid C = ${CC} ${CPPFLAGS} -m64 -msse2 -Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough -O2 ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -melf_x86_64 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -melf_x86_64 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-a6nb b/c/Mf-a6nb index 5cf2ec043f..42b5483d60 100644 --- a/c/Mf-a6nb +++ b/c/Mf-a6nb @@ -31,11 +31,15 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} + paxctl +m ${Scheme} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-a6nt b/c/Mf-a6nt index a38cc91f58..3e96e0e64a 100644 --- a/c/Mf-a6nt +++ b/c/Mf-a6nt @@ -21,10 +21,11 @@ o = obj mdobj=windows.$o mdsrc=windows.c Makefile.$m cs.ico scheme.rc make.bat mdclean=vs.bat make.bat scheme.res ../bin/$m/*.exp mtscheme.exe* mdscheme.exe* +cross=f include Mf-base -${Scheme}: make.bat +${Scheme}${cross:f=}: make.bat cmd.exe /c make.bat cp ../bin/$m/scheme.exe ../bin/$m/petite.exe cp ../bin/$m/scheme.pdb ../bin/$m/petite.pdb @@ -34,3 +35,28 @@ make.bat: vs.bat echo 'set MAKEFLAGS=' >> $@ echo 'vs.bat amd64 && nmake /f Makefile.$m /nologo %*' >> $@ chmod +x $@ + +# ------------------------------------------------------- +# For cross-compilation, triggered by setting cross=t o=o + +C = ${CC} ${CPPFLAGS} -O2 ${CFLAGS} + +${Scheme}${cross:t=}: ${Main} ${Kernel} ${KernelLinkDeps} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} -lshell32 -luser32 -lole32 -lrpcrt4 -luuid + +.c.$o: + $C -c -D${Cpu} -I${Include} ${zlibInc} ${LZ4Inc} $*.c + +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} + +../zlib/configure.log: + echo "all:" >> ../zlib/Makefile + echo '\t$$(MAKE) -f win32/Makefile.gcc CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" RC="$(WINDRES)"' >> ../zlib/Makefile + touch ../zlib/configure.log + +../lz4/lib/liblz4.a: ${LZ4Sources} + (cd ../lz4/lib; CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ${MAKE} liblz4.a) diff --git a/c/Mf-a6ob b/c/Mf-a6ob index 12fa15eab1..fe117c67f1 100644 --- a/c/Mf-a6ob +++ b/c/Mf-a6ob @@ -17,7 +17,7 @@ m = a6ob Cpu = X86_64 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm -lncurses +mdclib = -L/usr/local/lib -liconv -lm ${ncursesLib} -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Werror -O ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -Wl,--export-dynamic -Wl,-zwxneeded -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-a6osx b/c/Mf-a6osx index a776bd3fd0..1977f3cf28 100644 --- a/c/Mf-a6osx +++ b/c/Mf-a6osx @@ -16,7 +16,7 @@ m = a6osx Cpu = X86_64 -mdclib = -liconv -lm -lncurses +mdclib = -liconv -lm ${ncursesLib} C = ${CC} ${CPPFLAGS} -m64 -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -Werror -O2 -I/opt/X11/include/ ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-a6s2 b/c/Mf-a6s2 index e3e6a1b8bf..6a8e403656 100644 --- a/c/Mf-a6s2 +++ b/c/Mf-a6s2 @@ -16,7 +16,7 @@ m = a6s2 Cpu = X86_64 -mdclib = -lnsl -ldl -lm -lcurses -lrt +mdclib = -lnsl -ldl -lm ${cursesLib} -lrt C = ${CC} ${CPPFLAGS} -m64 -Wpointer-arith -Wextra -Werror -O ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -melf_x86_64 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -melf_x86_64 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-arm32le b/c/Mf-arm32le index 7cc8a6e620..699f49a318 100644 --- a/c/Mf-arm32le +++ b/c/Mf-arm32le @@ -16,7 +16,7 @@ m = arm32le Cpu = ARMV6 -mdclib = -lm -ldl -lncurses -lrt -luuid +mdclib = -lm -ldl ${ncursesLib} -lrt -luuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Wextra -Werror -Wno-implicit-fallthrough -O2 ${CFLAGS} o = o mdsrc = arm32le.c @@ -30,11 +30,14 @@ mdobj = arm32le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; ./configure) diff --git a/c/Mf-base b/c/Mf-base index b1232c5b9a..0cfd7216be 100644 --- a/c/Mf-base +++ b/c/Mf-base @@ -18,17 +18,27 @@ include Mf-config Include=../boot/$m PetiteBoot=../boot/$m/petite.boot SchemeBoot=../boot/$m/scheme.boot -Kernel=../boot/$m/kernel.$o Main=../boot/$m/main.$o Scheme=../bin/$m/scheme +# One of these sets is referenced in Mf-config to select between +# linking with kernel.o or libkernel.a + +KernelO=../boot/$m/kernel.$o +KernelOLinkDeps= +KernelOLinkLibs= + +KernelLib=../boot/$m/libkernel.a +KernelLibLinkDeps=${zlibDep} ${LZ4Dep} +KernelLibLinkLibs=${zlibLib} ${LZ4Lib} + kernelsrc=statics.c segment.c alloc.c symbol.c intern.c gcwrapper.c gc-ocd.c gc-oce.c\ number.c schsig.c io.c new-io.c print.c fasl.c stats.c foreign.c prim.c prim5.c flushcache.c\ schlib.c thread.c expeditor.c scheme.c compress-io.c kernelobj=${kernelsrc:%.c=%.$o} ${mdobj} -kernelhdr=system.h types.h version.h globals.h externs.h segment.h gc.c sort.h thread.h config.h compress-io.h itest.c +kernelhdr=system.h types.h version.h globals.h externs.h segment.h gc.c sort.h thread.h config.h compress-io.h itest.c nocurses.h mainsrc=main.c @@ -51,7 +61,7 @@ endif scheme.o: itest.c scheme.o main.o: config.h -${kernelobj}: system.h types.h version.h externs.h globals.h segment.h thread.h sort.h compress-io.h +${kernelobj}: system.h types.h version.h externs.h globals.h segment.h thread.h sort.h compress-io.h nocurses.h ${kernelobj}: ${Include}/equates.h ${Include}/scheme.h ${mainobj}: ${Include}/scheme.h ${kernelobj}: ${zlibHeaderDep} ${LZ4HeaderDep} diff --git a/c/Mf-i3fb b/c/Mf-i3fb index 32f7042bf4..187e03624f 100644 --- a/c/Mf-i3fb +++ b/c/Mf-i3fb @@ -17,7 +17,7 @@ m = i3fb Cpu = I386 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm -lncurses +mdclib = -L/usr/local/lib -liconv -lm ${ncursesLib} -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Wextra -Werror -O ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-i3le b/c/Mf-i3le index 5bf9ab44b3..1cd31eb623 100644 --- a/c/Mf-i3le +++ b/c/Mf-i3le @@ -16,7 +16,7 @@ m = i3le Cpu = I386 -mdclib = -lm -ldl -lncurses -lrt -luuid +mdclib = -lm -ldl ${ncursesLib} -lrt -luuid C = ${CC} ${CPPFLAGS} -m32 -msse2 -Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough -O2 -fno-stack-protector ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -melf_i386 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -melf_i386 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-i3nb b/c/Mf-i3nb index f0cfca976d..05592cf5eb 100644 --- a/c/Mf-i3nb +++ b/c/Mf-i3nb @@ -31,11 +31,15 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} + paxctl +m ${Scheme} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-i3nt b/c/Mf-i3nt index 9b37d41d47..dee0ff05bb 100644 --- a/c/Mf-i3nt +++ b/c/Mf-i3nt @@ -21,10 +21,11 @@ o = obj mdobj=windows.$o mdsrc=windows.c Makefile.$m cs.ico scheme.rc make.bat mdclean=vs.bat make.bat scheme.res ../bin/$m/*.exp mtscheme.exe* mdscheme.exe* +cross=f include Mf-base -${Scheme}: make.bat +${Scheme}${cross:f=}: make.bat cmd.exe /c make.bat cp ../bin/$m/scheme.exe ../bin/$m/petite.exe cp ../bin/$m/scheme.pdb ../bin/$m/petite.pdb @@ -34,3 +35,28 @@ make.bat: vs.bat echo 'set MAKEFLAGS=' >> $@ echo 'vs.bat x86 && nmake /f Makefile.$m /nologo %*' >> $@ chmod +x $@ + +# ------------------------------------------------------- +# For cross-compilation, triggered by setting cross=t o=o + +C = ${CC} ${CPPFLAGS} -O2 ${CFLAGS} + +${Scheme}${cross:t=}: ${Main} ${Kernel} ${KernelLinkDeps} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} -lshell32 -luser32 -lole32 -lrpcrt4 -luuid + +.c.$o: + $C -c -D${Cpu} -I${Include} ${zlibInc} ${LZ4Inc} $*.c + +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} + +../zlib/configure.log: + echo "all:" >> ../zlib/Makefile + echo '\t$$(MAKE) -f win32/Makefile.gcc CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" RC="$(WINDRES)"' >> ../zlib/Makefile + touch ../zlib/configure.log + +../lz4/lib/liblz4.a: ${LZ4Sources} + (cd ../lz4/lib; CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ${MAKE} liblz4.a) diff --git a/c/Mf-i3ob b/c/Mf-i3ob index 237a7b3126..a1a6d39112 100644 --- a/c/Mf-i3ob +++ b/c/Mf-i3ob @@ -17,7 +17,7 @@ m = i3ob Cpu = I386 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm -lncurses +mdclib = -L/usr/local/lib -liconv -lm ${ncursesLib} -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Werror -O ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -Wl,--export-dynamic -Wl,-zwxneeded -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-i3osx b/c/Mf-i3osx index 2c5f4b8ca7..1a4b181d04 100644 --- a/c/Mf-i3osx +++ b/c/Mf-i3osx @@ -16,7 +16,7 @@ m = i3osx Cpu = I386 -mdclib = -liconv -lm -lncurses +mdclib = -liconv -lm ${ncursesLib} C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -Werror -O2 -msse2 -I/opt/X11/include/ ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-i3qnx b/c/Mf-i3qnx index 9c159d34a8..7d03738866 100644 --- a/c/Mf-i3qnx +++ b/c/Mf-i3qnx @@ -16,7 +16,7 @@ m = i3qnx Cpu = I386 -mdclib = -lm /usr/local/lib/libiconv.so -lsocket -lncurses +mdclib = -lm /usr/local/lib/libiconv.so -lsocket ${ncursesLib} C = qcc ${CPPFLAGS} -m32 -Wpointer-arith -Wextra -Werror -O2 -N2048K ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ LocalInclude = /usr/local/include include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -mi386nto -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -mi386nto -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -Wl,--export-dynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-i3s2 b/c/Mf-i3s2 index 5be12fae4d..c0dabc3688 100644 --- a/c/Mf-i3s2 +++ b/c/Mf-i3s2 @@ -16,7 +16,7 @@ m = i3s2 Cpu = I386 -mdclib = -lnsl -ldl -lm -lcurses -lrt +mdclib = -lnsl -ldl -lm ${cursesLib} -lrt C = ${CC} ${CFLAGS} -m32 -Wpointer-arith -Wextra -Werror -O ${CPPFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -melf_i386 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -melf_i386 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-ppc32le b/c/Mf-ppc32le index 91705e772d..66f8753fe6 100644 --- a/c/Mf-ppc32le +++ b/c/Mf-ppc32le @@ -16,7 +16,7 @@ m = ppc32le Cpu = PPC32 -mdclib = -lm -ldl -lncurses -lrt -luuid +mdclib = -lm -ldl ${ncursesLib} -lrt -luuid C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wextra -Werror -Wno-implicit-fallthrough -O2 ${CFLAGS} o = o mdsrc = ppc32.c @@ -30,11 +30,14 @@ mdobj = ppc32.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-ta6fb b/c/Mf-ta6fb index 42a1dbb0fb..6b362e9674 100644 --- a/c/Mf-ta6fb +++ b/c/Mf-ta6fb @@ -17,7 +17,7 @@ m = ta6fb Cpu = X86_64 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm -lncurses -lpthread +mdclib = -L/usr/local/lib -liconv -lm ${ncursesLib} -lpthread -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Wextra -Werror -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-ta6le b/c/Mf-ta6le index ee961471d6..6adb83fb48 100644 --- a/c/Mf-ta6le +++ b/c/Mf-ta6le @@ -16,7 +16,7 @@ m = ta6le Cpu = X86_64 -mdclib = -lm -ldl -lncurses -lpthread -lrt -luuid +mdclib = -lm -ldl ${ncursesLib} -lpthread -lrt -luuid C = ${CC} ${CPPFLAGS} -m64 -msse2 -Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -melf_x86_64 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -melf_x86_64 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-ta6nb b/c/Mf-ta6nb index 168c97103e..6133398e03 100644 --- a/c/Mf-ta6nb +++ b/c/Mf-ta6nb @@ -31,11 +31,15 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} + paxctl +m ${Scheme} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-ta6nt b/c/Mf-ta6nt index 5df2d40d0b..1c9e689884 100644 --- a/c/Mf-ta6nt +++ b/c/Mf-ta6nt @@ -21,10 +21,11 @@ o = obj mdobj=windows.$o mdsrc=windows.c Makefile.$m cs.ico scheme.rc make.bat mdclean=vs.bat make.bat scheme.res ../bin/$m/*.exp mtscheme.exe* mdscheme.exe* +cross=f include Mf-base -${Scheme}: make.bat +${Scheme}${cross:f=}: make.bat cmd.exe /c make.bat cp ../bin/$m/scheme.exe ../bin/$m/petite.exe cp ../bin/$m/scheme.pdb ../bin/$m/petite.pdb @@ -34,3 +35,28 @@ make.bat: vs.bat echo 'set MAKEFLAGS=' >> $@ echo 'vs.bat amd64 && nmake /f Makefile.$m /nologo %*' >> $@ chmod +x $@ + +# ------------------------------------------------------- +# For cross-compilation, triggered by setting cross=t o=o + +C = ${CC} ${CPPFLAGS} -O2 ${CFLAGS} + +${Scheme}${cross:t=}: ${Main} ${Kernel} ${KernelLinkDeps} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} -lshell32 -luser32 -lole32 -lrpcrt4 -luuid + +.c.$o: + $C -c -D${Cpu} -I${Include} ${zlibInc} ${LZ4Inc} $*.c + +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} + +../zlib/configure.log: + echo "all:" >> ../zlib/Makefile + echo '\t$$(MAKE) -f win32/Makefile.gcc CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" RC="$(WINDRES)"' >> ../zlib/Makefile + touch ../zlib/configure.log + +../lz4/lib/liblz4.a: ${LZ4Sources} + (cd ../lz4/lib; CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ${MAKE} liblz4.a) diff --git a/c/Mf-ta6ob b/c/Mf-ta6ob index ef00f655ab..74857da7f8 100644 --- a/c/Mf-ta6ob +++ b/c/Mf-ta6ob @@ -17,7 +17,7 @@ m = ta6ob Cpu = X86_64 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm -lncurses -lpthread +mdclib = -L/usr/local/lib -liconv -lm ${ncursesLib} -lpthread -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Werror -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -Wl,--export-dynamic -Wl,-zwxneeded -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-ta6osx b/c/Mf-ta6osx index d070f3b3d0..10335a8673 100644 --- a/c/Mf-ta6osx +++ b/c/Mf-ta6osx @@ -16,7 +16,7 @@ m = ta6osx Cpu = X86_64 -mdclib = -liconv -lm -lncurses +mdclib = -liconv -lm ${ncursesLib} C = ${CC} ${CPPFLAGS} -m64 -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -Werror -O2 -I/opt/X11/include/ ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-ta6s2 b/c/Mf-ta6s2 index 2e54211373..dbe035fe3f 100644 --- a/c/Mf-ta6s2 +++ b/c/Mf-ta6s2 @@ -16,7 +16,7 @@ m = ta6s2 Cpu = X86_64 -mdclib = -lnsl -ldl -lm -lpthread -lcurses -lrt +mdclib = -lnsl -ldl -lm -lpthread ${cursesLib} -lrt C = ${CC} ${CPPFLAGS} -m64 -Wpointer-arith -Wextra -Werror -O2 -D_REENTRANT ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -melf_x86_64 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -melf_x86_64 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-ti3fb b/c/Mf-ti3fb index ec52090f8e..bb4d8125bb 100644 --- a/c/Mf-ti3fb +++ b/c/Mf-ti3fb @@ -17,7 +17,7 @@ m = ti3fb Cpu = I386 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm -lncurses -lpthread +mdclib = -L/usr/local/lib -liconv -lm ${ncursesLib} -lpthread -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Wextra -Werror -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-ti3le b/c/Mf-ti3le index 4d52e111e1..f923dc25e2 100644 --- a/c/Mf-ti3le +++ b/c/Mf-ti3le @@ -16,7 +16,7 @@ m = ti3le Cpu = I386 -mdclib = -lm -ldl -lncurses -lpthread -lrt -luuid +mdclib = -lm -ldl ${ncursesLib} -lpthread -lrt -luuid C = ${CC} ${CPPFLAGS} -m32 -msse2 -Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -melf_i386 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -melf_i386 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-ti3nb b/c/Mf-ti3nb index 3bbb9d2961..db753ac7dc 100644 --- a/c/Mf-ti3nb +++ b/c/Mf-ti3nb @@ -31,11 +31,15 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -m elf_i386 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -m elf_i386 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} + paxctl +m ${Scheme} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-ti3nt b/c/Mf-ti3nt index 303b0c09ab..030a3d0338 100644 --- a/c/Mf-ti3nt +++ b/c/Mf-ti3nt @@ -21,10 +21,11 @@ o = obj mdobj=windows.$o mdsrc=windows.c Makefile.$m cs.ico scheme.rc make.bat mdclean=vs.bat make.bat scheme.res ../bin/$m/*.exp mtscheme.exe* mdscheme.exe* +cross=f include Mf-base -${Scheme}: make.bat +${Scheme}${cross:f=}: make.bat cmd.exe /c make.bat cp ../bin/$m/scheme.exe ../bin/$m/petite.exe cp ../bin/$m/scheme.pdb ../bin/$m/petite.pdb @@ -34,3 +35,28 @@ make.bat: vs.bat echo 'set MAKEFLAGS=' >> $@ echo 'vs.bat x86 && nmake /f Makefile.$m /nologo %*' >> $@ chmod +x $@ + +# ------------------------------------------------------- +# For cross-compilation, triggered by setting cross=t o=o + +C = ${CC} ${CPPFLAGS} -O2 ${CFLAGS} -D__MINGW_USE_VC2005_COMPAT + +${Scheme}${cross:t=}: ${Main} ${Kernel} ${KernelLinkDeps} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} -lshell32 -luser32 -lole32 -lrpcrt4 -luuid + +.c.$o: + $C -c -D${Cpu} -I${Include} ${zlibInc} ${LZ4Inc} $*.c + +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} + +../zlib/configure.log: + echo "all:" >> ../zlib/Makefile + echo '\t$$(MAKE) -f win32/Makefile.gcc CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" RC="$(WINDRES)"' >> ../zlib/Makefile + touch ../zlib/configure.log + +../lz4/lib/liblz4.a: ${LZ4Sources} + (cd ../lz4/lib; CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" ${MAKE} liblz4.a) diff --git a/c/Mf-ti3ob b/c/Mf-ti3ob index eb622c122a..381ebca0cf 100644 --- a/c/Mf-ti3ob +++ b/c/Mf-ti3ob @@ -17,7 +17,7 @@ m = ti3ob Cpu = I386 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm -lncurses -lpthread +mdclib = -L/usr/local/lib -liconv -lm ${ncursesLib} -lpthread -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Werror -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c @@ -31,11 +31,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -Wl,--export-dynamic -Wl,-zwxneeded -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-ti3osx b/c/Mf-ti3osx index 48662d6df3..1421c07f93 100644 --- a/c/Mf-ti3osx +++ b/c/Mf-ti3osx @@ -16,7 +16,7 @@ m = ti3osx Cpu = I386 -mdclib = -liconv -lm -lncurses +mdclib = -liconv -lm ${ncursesLib} C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -Werror -O2 -msse2 -I/opt/X11/include/ ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-ti3s2 b/c/Mf-ti3s2 index 8430017c6f..a8fd5da99f 100644 --- a/c/Mf-ti3s2 +++ b/c/Mf-ti3s2 @@ -16,7 +16,7 @@ m = ti3s2 Cpu = I386 -mdclib = -lnsl -ldl -lm -lpthread -lcurses -lrt +mdclib = -lnsl -ldl -lm -lpthread ${cursesLib} -lrt C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wextra -Werror -O2 -D_REENTRANT ${CFLAGS} o = o mdsrc = i3le.c @@ -30,11 +30,14 @@ mdobj = i3le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -melf_i386 -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -melf_i386 -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-tppc32le b/c/Mf-tppc32le index cd01f24ab8..486b8524f7 100644 --- a/c/Mf-tppc32le +++ b/c/Mf-tppc32le @@ -16,7 +16,7 @@ m = tppc32le Cpu = PPC32 -mdclib = -lm -ldl -lncurses -lpthread -lrt -luuid +mdclib = -lm -ldl ${ncursesLib} -lpthread -lrt -luuid C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wextra -Werror -Wno-implicit-fallthrough -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = ppc32le.c @@ -30,11 +30,14 @@ mdobj = ppc32le.o include Mf-base -${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} - ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} +${KernelO}: ${kernelobj} ${zlibDep} ${LZ4Dep} + ${LD} -r -X -o ${KernelO} ${kernelobj} ${zlibLib} ${LZ4Lib} -${Scheme}: ${Kernel} ${Main} - $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} +${KernelLib}: ${kernelobj} + ${AR} ${ARFLAGS} ${KernelLib} ${kernelobj} + +${Scheme}: ${Kernel} ${KernelLinkDeps} ${Main} + $C -rdynamic -o ${Scheme} ${Main} ${Kernel} ${mdclib} ${KernelLinkLibs} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/build.bat b/c/build.bat new file mode 100644 index 0000000000..bc4481f69e --- /dev/null +++ b/c/build.bat @@ -0,0 +1,30 @@ +@echo off +setlocal + +set M=%1 +set WORKAREA=%M% + +if "%WORKAREA%"=="" goto needargument + +xcopy /s /i /y c %WORKAREA%\c +xcopy /s /i /y s %WORKAREA%\s +xcopy /s /i /y boot %WORKAREA%\boot +xcopy /s /i /y zlib %WORKAREA%\zlib +xcopy /s /i /y lz4 %WORKAREA%\lz4 + +mkdir %WORKAREA%\bin\%M% + +echo #define SCHEME_SCRIPT "scheme-script" > %WORKAREA%\c\config.h + +cd %WORKAREA%\c +nmake Makefile.%M% +cd ..\.. + +goto donebuilding + +:needargument + +echo Please supply the machine name as an argument +exit /B 1 + +:donebuilding diff --git a/c/expeditor.c b/c/expeditor.c index 7d0fc62cf1..5a6a50788c 100644 --- a/c/expeditor.c +++ b/c/expeditor.c @@ -528,7 +528,9 @@ static void s_ee_write_char(wchar_t c) { #else /* WIN32 */ #include -#ifdef SOLARIS +#ifdef DISABLE_CURSES +#include "nocurses.h" +#elif defined(SOLARIS) #define NCURSES_CONST #define CHTYPE int #include @@ -547,7 +549,7 @@ static void s_ee_write_char(wchar_t c) { #include #include #include -#ifndef __GLIBC__ +#if !defined(__GLIBC__) && !defined(__OpenBSD__) && !defined(__NetBSD__) #include #endif @@ -555,6 +557,17 @@ static void s_ee_write_char(wchar_t c) { #define HANDLE_SIGWINCH #endif +#ifdef USE_MBRTOWC_L +static locale_t the_locale; +static locale_t uselocale_alt(locale_t l) { + locale_t old = the_locale; + the_locale = l; + return old; +} +# define uselocale(v) uselocale_alt(v) +# define mbrtowc(pwc, s, n, ps) mbrtowc_l(pwc, s, n, ps, the_locale) +#endif + /* locally defined functions */ static int eeputc(tputsputcchar c); #ifdef HANDLE_SIGWINCH diff --git a/c/externs.h b/c/externs.h index 42ef835c3b..2c6cb919c9 100644 --- a/c/externs.h +++ b/c/externs.h @@ -314,13 +314,13 @@ extern void S_handle_overflow PROTO((void)); extern void S_handle_overflood PROTO((void)); extern void S_handle_apply_overflood PROTO((void)); extern void S_overflow PROTO((ptr tc, iptr frame_request)); -extern void S_error_reset PROTO((const char *s)); +extern NORETURN void S_error_reset PROTO((const char *s)); extern NORETURN void S_error_abort PROTO((const char *s)); extern NORETURN void S_abnormal_exit PROTO((void)); -extern void S_error PROTO((const char *who, const char *s)); -extern void S_error1 PROTO((const char *who, const char *s, ptr x)); -extern void S_error2 PROTO((const char *who, const char *s, ptr x, ptr y)); -extern void S_error3 PROTO((const char *who, const char *s, ptr x, ptr y, ptr z)); +extern NORETURN void S_error PROTO((const char *who, const char *s)); +extern NORETURN void S_error1 PROTO((const char *who, const char *s, ptr x)); +extern NORETURN void S_error2 PROTO((const char *who, const char *s, ptr x, ptr y)); +extern NORETURN void S_error3 PROTO((const char *who, const char *s, ptr x, ptr y, ptr z)); extern NORETURN void S_boot_error PROTO((const ptr who, ptr s, ptr args)); extern void S_handle_docall_error PROTO((void)); extern void S_handle_arg_error PROTO((void)); @@ -329,7 +329,7 @@ extern void S_handle_values_error PROTO((void)); extern void S_handle_mvlet_error PROTO((void)); extern void S_register_scheme_signal PROTO((iptr sig)); extern void S_fire_collector PROTO((void)); -extern void S_noncontinuable_interrupt PROTO((void)); +extern NORETURN void S_noncontinuable_interrupt PROTO((void)); extern void S_schsig_init PROTO((void)); #ifdef DEFINE_MATHERR #include @@ -402,3 +402,6 @@ extern char *S_windows_getcwd(char *buffer, int maxlen); /* expeditor.c */ extern void S_expeditor_init PROTO((void)); #endif /* FEATURE_EXPEDITOR */ + +/* statics.c */ +extern void scheme_statics(); diff --git a/c/globals.h b/c/globals.h index b0b2979159..7e570628be 100644 --- a/c/globals.h +++ b/c/globals.h @@ -63,7 +63,7 @@ EXTERN ptr S_foreign_dynamic; #endif /* globals that do need to be preserved in a saved heap */ -EXTERN struct { +EXTERN struct S_G_struct { /* scheme.c */ double thread_context[size_tc / sizeof(double)]; ptr active_threads_id; diff --git a/c/main.c b/c/main.c index 080cbb5cb6..de8c71959f 100644 --- a/c/main.c +++ b/c/main.c @@ -59,12 +59,13 @@ static const char *path_last(const char *p) { return p; } -#ifdef WIN32 +#if defined(WIN32) && !defined(__MINGW32__) #define GETENV Sgetenv #define GETENV_FREE free int wmain(int argc, wchar_t* wargv[], wchar_t* wenvp[]) { const char** argv = (char**)malloc((argc + 1) * sizeof(char*)); - for (int i = 0; i < argc; i++) { + int i; + for (i = 0; i < argc; i++) { wchar_t* warg = wargv[i]; if (NULL == (argv[i] = Swide_to_utf8(warg))) { fprintf_s(stderr, "Invalid argument: %S\n", warg); diff --git a/c/nocurses.h b/c/nocurses.h new file mode 100644 index 0000000000..4b17450243 --- /dev/null +++ b/c/nocurses.h @@ -0,0 +1,24 @@ +#ifndef ERR +# define ERR -1 +#endif + +#define setupterm(a, b, e) (*(e) = 0, ERR) +#define tputs(c, x, f) (f(c)) + +#define lines 0 +#define columns 0 + +#define cursor_left 0 +#define cursor_right 0 +#define cursor_up 0 +#define cursor_down 0 +#define enter_am_mode 0 +#define exit_am_mode 0 +#define clr_eos 0 +#define clr_eol 0 +#define clear_screen 0 +#define carriage_return 0 +#define bell 0 +#define scroll_reverse 0 +#define auto_right_margin 0 +#define eat_newline_glitch 0 diff --git a/c/scheme.c b/c/scheme.c index 067e498d2d..bef291d8c6 100644 --- a/c/scheme.c +++ b/c/scheme.c @@ -39,11 +39,16 @@ static void main_init PROTO((void)); static void idiot_checks PROTO((void)); static INT run_script PROTO((const char *who, const char *scriptfile, INT argc, const char *argv[], IBOOL programp)); +extern void scheme_include(void); + static void main_init() { ptr tc = get_thread_context(); ptr p; INT i; + /* create dependency for linker */ + scheme_statics(); + /* force thread inline allocation to go through find_room until ready */ AP(tc) = (ptr)0; EAP(tc) = (ptr)0; @@ -385,7 +390,7 @@ void S_generic_invoke(tc, code) ptr tc; ptr code; { hdr.env = (I32)0; p = (ugly)((I32)&hdr + 2); p(tc); -#elif defined(WIN32) +#elif defined(WIN32) && !defined(__MINGW32__) __try { (*((void (*) PROTO((ptr)))(void *)&CODEIT(code,0)))(tc); } diff --git a/c/schsig.c b/c/schsig.c index 00d7cce4c1..83c8d6f54b 100644 --- a/c/schsig.c +++ b/c/schsig.c @@ -21,7 +21,7 @@ static void S_promote_to_multishot PROTO((ptr k)); static void split PROTO((ptr k, ptr *s)); static void reset_scheme PROTO((void)); -static void do_error PROTO((iptr type, const char *who, const char *s, ptr args)); +static NORETURN void do_error PROTO((iptr type, const char *who, const char *s, ptr args)); static void handle_call_error PROTO((ptr tc, iptr type, ptr x)); static void init_signal_handlers PROTO((void)); static void keyboard_interrupt PROTO((ptr tc)); diff --git a/c/segment.h b/c/segment.h index abe28858b8..0d6c3b0210 100644 --- a/c/segment.h +++ b/c/segment.h @@ -15,8 +15,10 @@ */ #ifdef WIN32 -#undef FORCEINLINE -#define FORCEINLINE static __forceinline +# ifndef __MINGW32__ +# undef FORCEINLINE +# define FORCEINLINE static __forceinline +# endif #else #define FORCEINLINE static inline #endif diff --git a/c/statics.c b/c/statics.c index 542f64ebc3..d13f1697f5 100644 --- a/c/statics.c +++ b/c/statics.c @@ -16,3 +16,8 @@ #define EXTERN #include "system.h" + +/* The C linker may require a reference to a function to pull in all + the common declarations. */ +#include "externs.h" +void scheme_statics() { } diff --git a/c/stats.c b/c/stats.c index ae5640a0df..e254546e73 100644 --- a/c/stats.c +++ b/c/stats.c @@ -65,7 +65,50 @@ ptr S_unique_id() { Sunsigned32(u.foo[3])))); } -#else /* WIN32 */ +#elif defined(USE_OSSP_UUID) /* WIN32 */ + +#include + +ptr S_unique_id() { + uuid_t *uuid; + U32 bin[4]; + void *bin_ptr = &bin; + size_t bin_len = sizeof(bin); + + uuid_create(&uuid); + uuid_make(uuid, UUID_MAKE_V4); + uuid_export(uuid, UUID_FMT_BIN, &bin_ptr, &bin_len); + uuid_destroy(uuid); + + return S_add(S_ash(Sunsigned32(bin[0]), Sinteger(8*3*sizeof(U32))), + S_add(S_ash(Sunsigned32(bin[1]), Sinteger(8*2*sizeof(U32))), + S_add(S_ash(Sunsigned32(bin[2]), Sinteger(8*sizeof(U32))), + Sunsigned32(bin[3])))); +} + +#elif defined(USE_NETBSD_UUID) /* USE_OSSP_UUID */ + +#include + +ptr S_unique_id() { + uuid_t uuid; + uint32_t status; + unsigned char bin[16]; + ptr n; + unsigned int i; + + uuid_create(&uuid, &status); + uuid_enc_le(bin, &uuid); + + n = Sinteger(0); + for (i = 0; i < sizeof(bin); i++) { + n = S_add(n, S_ash(Sinteger(bin[i]), Sinteger(8*i))); + } + + return n; +} + +#else /* USE_NETBSD_UUID */ #include @@ -210,7 +253,8 @@ void S_gettime(INT typeno, struct timespec *tp) { #ifdef CLOCK_THREAD_CPUTIME_ID if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, tp) == 0) return; #endif - /* fall through to utc case in case no thread timer */ + /* fall through */ + /* to utc case in case no thread timer */ case time_process: #ifdef CLOCK_PROCESS_CPUTIME_ID if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, tp) == 0) return; @@ -240,7 +284,8 @@ void S_gettime(INT typeno, struct timespec *tp) { #ifdef CLOCK_HIGHRES if (clock_gettime(CLOCK_HIGHRES, tp) == 0) return; #endif - /* fall through to utc case in case no monotonic timer */ + /* fall through */ + /* to utc case in case no monotonic timer */ case time_utc: #ifdef CLOCK_REALTIME_HR if (clock_gettime(CLOCK_REALTIME_HR, tp) == 0) return; diff --git a/c/system.h b/c/system.h index cdf6f09fcc..868708bfee 100644 --- a/c/system.h +++ b/c/system.h @@ -17,6 +17,10 @@ #include "scheme.h" #include "equates.h" #ifdef FEATURE_WINDOWS +#ifdef __MINGW32__ +# undef WINVER +# undef _WIN32_WINNT +#endif #define WINVER 0x0601 // Windows 7 #define _WIN32_WINNT WINVER #include diff --git a/c/thread.c b/c/thread.c index 5b60d675d2..75200089bc 100644 --- a/c/thread.c +++ b/c/thread.c @@ -433,6 +433,10 @@ IBOOL S_condition_wait(c, m, t) s_thread_cond_t *c; scheme_mutex_t *m; ptr t; { typeno = Sinteger32_value(Srecord_ref(t,0)); sec = Sinteger32_value(Scar(Srecord_ref(t,1))); nsec = Sinteger32_value(Scdr(Srecord_ref(t,1))); + } else { + typeno = 0; + sec = 0; + nsec = 0; } if (c == &S_collect_cond || DISABLECOUNT(tc) == 0) { diff --git a/c/types.h b/c/types.h index 872dc17671..18d3d6f874 100644 --- a/c/types.h +++ b/c/types.h @@ -338,11 +338,23 @@ typedef struct { #define tc_mutex_release() {} #endif +#ifdef __MINGW32__ +/* With MinGW on 64-bit Windows, setjmp/longjmp is not reliable. Using + __builtin_setjmp/__builtin_longjmp is reliable, but + __builtin_longjmp requires 1 as its second argument. So, allocate + room in the buffer for a return value. */ +# define JMPBUF_RET(jb) (*(int *)((char *)(jb)+sizeof(jmp_buf))) +# define CREATEJMPBUF() malloc(sizeof(jmp_buf)+sizeof(int)) +# define FREEJMPBUF(jb) free(jb) +# define SETJMP(jb) (JMPBUF_RET(jb) = 0, __builtin_setjmp(jb), JMPBUF_RET(jb)) +# define LONGJMP(jb,n) (JMPBUF_RET(jb) = n, __builtin_longjmp(jb, 1)) +#else /* assuming malloc will give us required alignment */ -#define CREATEJMPBUF() malloc(sizeof(jmp_buf)) -#define FREEJMPBUF(jb) free(jb) -#define SETJMP(jb) _setjmp(jb) -#define LONGJMP(jb,n) _longjmp(jb, n) +# define CREATEJMPBUF() malloc(sizeof(jmp_buf)) +# define FREEJMPBUF(jb) free(jb) +# define SETJMP(jb) _setjmp(jb) +# define LONGJMP(jb,n) _longjmp(jb, n) +#endif #define DOUNDERFLOW\ &CODEIT(CLOSCODE(S_lookup_library_entry(library_dounderflow, 1)),size_rp_header) diff --git a/c/version.h b/c/version.h index ebb4937a07..9874d3b40c 100644 --- a/c/version.h +++ b/c/version.h @@ -152,6 +152,7 @@ typedef int tputsputcchar; #define NSECMTIME(sb) (sb).st_mtimespec.tv_nsec #define ICONV_INBUF_TYPE char ** #define UNUSED __attribute__((__unused__)) +#define USE_OSSP_UUID #endif #if (machine_type == machine_type_i3nb || machine_type == machine_type_ti3nb || machine_type == machine_type_a6nb || machine_type == machine_type_ta6nb) @@ -169,6 +170,7 @@ typedef int tputsputcchar; #define ARCHYPERBOLIC #define GETPAGESIZE() getpagesize() typedef char *memcpy_t; +struct timespec; #define MAKE_NAN(x) { x = 0.0; x = x / x; } #define GETWD(x) getcwd((x),PATH_MAX) typedef int tputsputcchar; @@ -185,6 +187,8 @@ typedef int tputsputcchar; #define NSECMTIME(sb) (sb).st_mtimespec.tv_nsec #define ICONV_INBUF_TYPE const char ** #define UNUSED __attribute__((__unused__)) +#define USE_NETBSD_UUID +#define USE_MBRTOWC_L #endif #if (machine_type == machine_type_i3nt || machine_type == machine_type_ti3nt || machine_type == machine_type_a6nt || machine_type == machine_type_ta6nt) @@ -199,11 +203,18 @@ typedef int tputsputcchar; #define USE_VIRTUAL_ALLOC #define NAN_INCLUDE #define MAKE_NAN(x) { x = sqrt(-1.0); } -#define PATH_MAX _MAX_PATH +#ifndef PATH_MAX +# define PATH_MAX _MAX_PATH +#endif typedef char *memcpy_t; -#define _setjmp setjmp -#define _longjmp longjmp +struct timespec; +#ifndef __MINGW32__ +# define _setjmp setjmp +# define _longjmp longjmp +#endif +#ifndef __MINGW32__ #define ftruncate _chsize_s +#endif #define LOCK_SH 1 #define LOCK_EX 2 #define LOCK_NB 4 @@ -238,6 +249,7 @@ typedef char *memcpy_t; #define NSECCTIME(sb) 0 #define NSECMTIME(sb) 0 #define ICONV_INBUF_TYPE char ** +struct timespec; #define UNUSED #endif @@ -255,6 +267,7 @@ typedef char *memcpy_t; #define ARCHYPERBOLIC #define GETPAGESIZE() getpagesize() typedef char *memcpy_t; +struct timespec; #define MAKE_NAN(x) { x = 0.0; x = x / x; } #define GETWD(x) getcwd((x),PATH_MAX) typedef int tputsputcchar; @@ -271,6 +284,7 @@ typedef int tputsputcchar; #define NSECMTIME(sb) (sb).st_mtimespec.tv_nsec #define ICONV_INBUF_TYPE char ** #define UNUSED __attribute__((__unused__)) +#define USE_OSSP_UUID #endif #if (machine_type == machine_type_i3osx || machine_type == machine_type_ti3osx || machine_type == machine_type_a6osx || machine_type == machine_type_ta6osx) diff --git a/configure b/configure index 7c3eaea06b..e3c64f79cd 100755 --- a/configure +++ b/configure @@ -38,10 +38,20 @@ installschemename="scheme" installpetitename="petite" installscriptname="scheme-script" disablex11=no +disablecurses=no : ${CC:="gcc"} : ${CPPFLAGS:=""} : ${CFLAGS:=""} +: ${LD:="ld"} : ${LDFLAGS:=""} +: ${AR:="ar"} +: ${ARFLAGS:="rc"} +: ${RANLIB:="ranlib"} +: ${WINDRES:="windres"} +: ${AR:="ar"} +: ${ARFLAGS:="ruv"} +: ${RANLIB:="ranlib"} +: ${WINDRES:="windres"} zlibInc=-I../zlib LZ4Inc=-I../lz4/lib zlibDep=../zlib/libz.a @@ -50,6 +60,10 @@ zlibLib=../zlib/libz.a LZ4Lib=../lz4/lib/liblz4.a zlibHeaderDep="../zlib/zconf.h ../zlib/zlib.h" LZ4HeaderDep="../lz4/lib/lz4.h ../lz4/lib/lz4frame.h" +Kernel=KernelO +installkerneltarget=installkernelobj +installzlibtarget= +installlz4target= # On WSL, set OS to "Windows_NT" to create a Windows # build instead of a Linux (on Windows) build: @@ -194,6 +208,14 @@ while [ $# != 0 ] ; do --installscriptname=*) installscriptname=`echo $1 | sed -e 's/^--installscriptname=//'` ;; + --toolprefix=*) + toolprefix=`echo $1 | sed -e 's/^--toolprefix=//'` + CC="${toolprefix}${CC}" + LD="${toolprefix}${LD}" + AR="${toolprefix}${AR}" + RANLIB="${toolprefix}${RANLIB}" + WINDRES="${toolprefix}${WINDRES}" + ;; --gzip-man-pages) gzipmanpages=yes ;; @@ -212,6 +234,25 @@ while [ $# != 0 ] ; do --disable-x11) disablex11=yes ;; + --disable-curses) + disablecurses=yes + ;; + --libkernel) + Kernel=KernelLib + installkerneltarget=installkernellib + if [ "$zlibInc" != "" ]; then + installzlibtarget=installzlib + fi + if [ "$LZ4Inc" != "" ]; then + installlz4target=installlz4 + fi + ;; + --kernelobj) + Kernel=KernelO + installkerneltarget=installkernelobj + installzlibtarget= + installlz4target= + ;; CC=*) CC=`echo $1 | sed -e 's/^CC=//'` ;; @@ -221,20 +262,37 @@ while [ $# != 0 ] ; do CFLAGS=*) CFLAGS=`echo $1 | sed -e 's/^CFLAGS=//'` ;; + LD=*) + LD=`echo $1 | sed -e 's/^LD=//'` + ;; LDFLAGS=*) LDFLAGS=`echo $1 | sed -e 's/^LDFLAGS=//'` ;; + AR=*) + AR=`echo $1 | sed -e 's/^AR=//'` + ;; + ARFLAGS=*) + ARFLAGS=`echo $1 | sed -e 's/^ARFLAGS=//'` + ;; + RANLIB=*) + RANLIB=`echo $1 | sed -e 's/^RANLIB=//'` + ;; + WINDRES=*) + WINDRES=`echo $1 | sed -e 's/^WINDRES=//'` + ;; ZLIB=*) zlibLib=`echo $1 | sed -e 's/^ZLIB=//'` zlibInc= zlibDep= zlibHeaderDep= + installzlibtarget= ;; LZ4=*) LZ4Lib=`echo $1 | sed -e 's/^LZ4=//'` LZ4Inc= LZ4Dep= LZ4HeaderDep= + installlz4target= ;; *) echo "option '$1' unrecognized or missing an argument; try $0 --help" @@ -298,7 +356,10 @@ if [ "$help" = "yes" ]; then echo " -m= same as --machine ($m)" echo " --threads specify threaded version ($threads)" echo " --32|--64 specify 32/64-bit version ($bits)" - echo " --disable-x11 disabling x11" + echo " --disable-x11 disable X11 support" + echo " --disable-curses disable [n]curses support" + echo " --libkernel build libkernel.a instead of kernel.o" + echo " --kernelobj build kernel.o (the default)" echo " --installprefix= final installation root ($installprefix)" echo " --installbin= bin directory ($installbin)" echo " --installlib= lib directory ($installlib)" @@ -309,13 +370,20 @@ if [ "$help" = "yes" ]; then echo " --installschemename= install with group ($installschemename)" echo " --installpetitename= install with group ($installpetitename)" echo " --installscriptname= install with group ($installscriptname)" + echo " --toolprefix= prefix tool (compiler, linker, ...) names" echo " --[no]gzip-man-pages compress manual pages ($gzipmanpages)" echo " --workarea= build directory ($w)" + echo " CC= C compiler" echo " CPPFLAGS= additional C preprocessor flags ($CPPFLAGS)" echo " CFLAGS= additional C compiler flags ($CFLAGS)" + echo " LD= linker" echo " LDFLAGS= additional linker flags ($LDFLAGS)" - echo " ZLIB= link to static instead of own zlib" - echo " LZ4= link to static instead of own LZ4" + echo " AR= archiver" + echo " ARFLAGS= archiver flags" + echo " RANLIB= archive indexer" + echo " WINDRES= resource compiler" + echo " ZLIB= link to instead of own zlib" + echo " LZ4= link to instead of own LZ4" echo "" echo "Available machine types: $machs" echo "" @@ -402,6 +470,9 @@ sed -e "s;^m=none\$;m=$m;"\ -e "s;^InstallSchemeName=.*$;InstallSchemeName=$installschemename;"\ -e "s;^InstallPetiteName=.*$;InstallPetiteName=$installpetitename;"\ -e "s;^InstallScriptName=.*$;InstallScriptName=$installscriptname;"\ + -e "s;^InstallKernelTarget=.*$;InstallKernelTarget=$installkerneltarget;"\ + -e "s;^InstallZlibTarget=.*$;InstallZlibTarget=$installzlibtarget;"\ + -e "s;^InstallLZ4Target=.*$;InstallLZ4Target=$installlz4target;"\ makefiles/Mf-install.in > $w/Mf-install cat > $w/c/config.h << END @@ -415,11 +486,27 @@ if [ "$disablex11" = "yes" ]; then echo '#define DISABLE_X11' >> $w/c/config.h fi +cursesLib=-lcurses +ncursesLib=-lncurses + +if [ "$disablecurses" = "yes" ]; then + echo '#define DISABLE_CURSES' >> $w/c/config.h + cursesLib= + ncursesLib= +fi + cat > $w/c/Mf-config << END CC=$CC CPPFLAGS=$CPPFLAGS CFLAGS=$CFLAGS +LD=$LD LDFLAGS=$LDFLAGS +AR=$AR +ARFLAGS=$ARFLAGS +RANLIB=$RANLIB +WINDRES=$WINDRES +cursesLib=$cursesLib +ncursesLib=$ncursesLib zlibInc=$zlibInc LZ4Inc=$LZ4Inc zlibDep=$zlibDep @@ -428,4 +515,7 @@ zlibLib=$zlibLib LZ4Lib=$LZ4Lib zlibHeaderDep=$zlibHeaderDep LZ4HeaderDep=$LZ4HeaderDep +Kernel=\${${Kernel}} +KernelLinkDeps=\${${Kernel}LinkDeps} +KernelLinkLibs=\${${Kernel}LinkLibs} END diff --git a/makefiles/Makefile.in b/makefiles/Makefile.in index e28cc4ee65..882e49fb7f 100644 --- a/makefiles/Makefile.in +++ b/makefiles/Makefile.in @@ -18,6 +18,9 @@ MAKEFLAGS += --no-print-directory build: (cd $(workarea) && $(MAKE) build) +run: + env SCHEMEHEAPDIRS=$(workarea)/boot/$(m) $(workarea)/bin/$(m)/scheme + install: (cd $(workarea) && $(MAKE) install) @@ -30,6 +33,16 @@ test: bootfiles: (cd $(workarea) && $(MAKE) bootfiles) +# Supply XM= to build boot files for +boot: build + mkdir -p boot/$(XM) + (cd $(workarea) && $(MAKE) -f Mf-boot $(XM).boot) + +# Supply ORIG= to build using existing at +from-orig: + (cd $(m)/s && $(MAKE) -f Mf-cross m=$(m) xm=$(m) base=$(ORIG)/$(m)) + $(MAKE) build + docs: build (cd csug && $(MAKE) m=$(m)) (cd release_notes && $(MAKE) m=$(m)) diff --git a/makefiles/Mf-install.in b/makefiles/Mf-install.in index a175284da3..4440fc33f4 100644 --- a/makefiles/Mf-install.in +++ b/makefiles/Mf-install.in @@ -51,6 +51,13 @@ InstallSchemeName=scheme InstallPetiteName=petite InstallScriptName=scheme-script +# Whether to install "kernel.o" or "libkernel.a" +InstallKernelTarget=installkernellib + +# Maybe install libz.a and liblz4.a by setting to "installzlib" and "installliz4" +InstallZlibTarget= +InstallLZ4Target= + ############################################################################### # no changes should be needed below this point # ############################################################################### @@ -74,7 +81,7 @@ PetitePath=${Bin}/${InstallPetiteName} SchemePath=${Bin}/${InstallSchemeName} SchemeScriptPath=${Bin}/${InstallScriptName} -install: bininstall libbininstall maninstall liblibinstall +install: bininstall libbininstall maninstall liblibinstall ${InstallKernelTarget} uninstall: rm -rf ${Lib} @@ -116,11 +123,22 @@ libbininstall: ${LibBin} ln -f ${LibBin}/scheme.boot ${LibBin}/${InstallSchemeName}.boot;\ fi ln -f ${LibBin}/scheme.boot ${LibBin}/${InstallScriptName}.boot; - $I -m 444 ${Include}/kernel.o ${LibBin} $I -m 444 ${Include}/main.o ${LibBin} $I -m 444 ${Include}/scheme.h ${LibBin} $I -m 444 ${Revision} ${LibBin}/revision +installkernelobj: ${LibBin} + $I -m 444 ${Include}/kernel.o ${LibBin} + +installkernellib: ${LibBin} ${InstallZlibTarget} ${InstallLZ4Target} + $I -m 444 ${Include}/libkernel.a ${LibBin} + +installzlib: ${LibBin} + $I -m 444 zlib/libz.a ${LibBin} + +installlz4: ${LibBin} + $I -m 444 lz4/lib/liblz4.a ${LibBin} + maninstall: scheme.1 petite.1 ${Man} $I -m 444 scheme.1 ${Man}/${InstallSchemeName}.1 if [ ${GzipManPages} = yes ] ; then gzip -f ${Man}/${InstallSchemeName}.1 ; fi diff --git a/s/a6nb.def b/s/a6nb.def index a2dbd9506b..0ba4e358e4 100644 --- a/s/a6nb.def +++ b/s/a6nb.def @@ -24,7 +24,7 @@ (define-constant size_t-bits 64) (define-constant ptrdiff_t-bits 64) (define-constant wchar-bits 32) -(define-constant time-t-bits 32) +(define-constant time-t-bits 64) (define-constant max-float-alignment 8) (define-constant max-integer-alignment 8) (define-constant asm-arg-reg-max 5) diff --git a/s/a6ob.def b/s/a6ob.def index e207950df5..489085de17 100644 --- a/s/a6ob.def +++ b/s/a6ob.def @@ -24,7 +24,7 @@ (define-constant size_t-bits 64) (define-constant ptrdiff_t-bits 64) (define-constant wchar-bits 32) -(define-constant time-t-bits 32) +(define-constant time-t-bits 64) (define-constant max-float-alignment 8) (define-constant max-integer-alignment 8) (define-constant asm-arg-reg-max 5) diff --git a/s/i3nt.def b/s/i3nt.def index 31f786b28c..1da39fa80c 100644 --- a/s/i3nt.def +++ b/s/i3nt.def @@ -38,8 +38,8 @@ (define-constant typedef-u16 "unsigned short") (define-constant typedef-i32 "int") (define-constant typedef-u32 "unsigned int") -(define-constant typedef-i64 "__int64") -(define-constant typedef-u64 "unsigned __int64") +(define-constant typedef-i64 "long long") +(define-constant typedef-u64 "unsigned long long") (define-constant typedef-string-char "unsigned int") (define-constant thread-handle-uptrs 1) (define-constant native-endianness 'little) diff --git a/s/ta6nb.def b/s/ta6nb.def index 50bd30b6d2..309fb6c547 100644 --- a/s/ta6nb.def +++ b/s/ta6nb.def @@ -24,7 +24,7 @@ (define-constant size_t-bits 64) (define-constant ptrdiff_t-bits 64) (define-constant wchar-bits 32) -(define-constant time-t-bits 32) +(define-constant time-t-bits 64) (define-constant max-float-alignment 8) (define-constant max-integer-alignment 8) (define-constant asm-arg-reg-max 5) diff --git a/s/ta6ob.def b/s/ta6ob.def index 8ff3fbba73..ae40a2b509 100644 --- a/s/ta6ob.def +++ b/s/ta6ob.def @@ -24,7 +24,7 @@ (define-constant size_t-bits 64) (define-constant ptrdiff_t-bits 64) (define-constant wchar-bits 32) -(define-constant time-t-bits 32) +(define-constant time-t-bits 64) (define-constant max-float-alignment 8) (define-constant max-integer-alignment 8) (define-constant asm-arg-reg-max 5) diff --git a/s/ti3nt.def b/s/ti3nt.def index 458fc6ede5..91b3c66f6d 100644 --- a/s/ti3nt.def +++ b/s/ti3nt.def @@ -38,8 +38,8 @@ (define-constant typedef-u16 "unsigned short") (define-constant typedef-i32 "int") (define-constant typedef-u32 "unsigned int") -(define-constant typedef-i64 "__int64") -(define-constant typedef-u64 "unsigned __int64") +(define-constant typedef-i64 "long long") +(define-constant typedef-u64 "unsigned long long") (define-constant typedef-string-char "unsigned int") (define-constant thread-handle-uptrs 2) (define-constant native-endianness 'little) From 8c891262a10b7bf499d8cbc83f90ba2602c480ee Mon Sep 17 00:00:00 2001 From: Alexander Shopov Date: Thu, 11 Jul 2019 23:02:12 +0200 Subject: [PATCH 2/6] Use setenv rather than putenv on non WIN32 environments Signed-off-by: Alexander Shopov original commit: 8bf1e18853d5feeb64aadb631c35641cd0ab4748 --- LOG | 1 + c/prim5.c | 6 +----- csug/system.stex | 2 -- release_notes/release_notes.stex | 6 ++++++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/LOG b/LOG index 75de93e72d..93d2374ba3 100644 --- a/LOG +++ b/LOG @@ -1374,3 +1374,4 @@ BUILDING, c/vs.bat, wininstall/locate-vcredist.bat - fixed open-string-input-port on immutable strings cpnanopass.ss, io.ms, release_notes.stex +- use setenv rather than putenv on non WIN32 environments diff --git a/c/prim5.c b/c/prim5.c index f19ca5492d..541c79d2b0 100644 --- a/c/prim5.c +++ b/c/prim5.c @@ -1372,11 +1372,7 @@ static void s_putenv(name, value) char *name, *value; { if (rc == 0) S_error1("putenv", "environment extension failed: ~a", S_LastErrorString()); #else /* WIN32 */ - iptr n; char *s; - n = strlen(name) + strlen(value) + 2; - if ((s = malloc(n)) == (char *)NULL - || snprintf(s, n, "%s=%s", name, value) < 0 - || putenv(s) != 0) { + if (setenv(name, value, 1) != 0) { ptr msg = S_strerror(errno); if (msg != Sfalse) diff --git a/csug/system.stex b/csug/system.stex index c3ca365755..3c403b52a7 100644 --- a/csug/system.stex +++ b/csug/system.stex @@ -5095,8 +5095,6 @@ is associated with \var{key}. environment of the process, where it is available to the current process (e.g., via \var{getenv}) and any spawned processes. -The key and value are copied into storage allocated outside of -the Scheme heap; this space is never reclaimed on non-Windows systems. \schemedisplay (putenv "SCHEME" "rocks!") diff --git a/release_notes/release_notes.stex b/release_notes/release_notes.stex index 3bc034e0b1..5d35d4eb11 100644 --- a/release_notes/release_notes.stex +++ b/release_notes/release_notes.stex @@ -1695,6 +1695,12 @@ in fasl files does not generally make sense. %----------------------------------------------------------------------------- \section{Bug Fixes}\label{section:bugfixes} +\subsection{\protect\code{putenv} memory leak (9.5.3)} + +\scheme{putenv} now calls the host system's \scheme{setenv} instead of +\scheme{putenv} on non-Windows hosts and avoids allocating memory that +is never freed, although \scheme{setenv} might do so. + \subsection{String ports from immutable strings (9.5.4)} A bug that miscalculated the buffer size for From 2647c0df240cb216959993a10136b55c1f243891 Mon Sep 17 00:00:00 2001 From: tokomikea Date: Fri, 26 Jul 2019 02:41:55 +0800 Subject: [PATCH 3/6] export `ee-backward-delete-sexp` binding in the expression-editor module. (#439) original commit: a851ea3299044c58f559e700004c590dfed462e9 --- LOG | 2 ++ s/expeditor.ss | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/LOG b/LOG index 771159262f..9e6e8730a5 100644 --- a/LOG +++ b/LOG @@ -1383,3 +1383,5 @@ a6ob.def, ta6ob.def, a6nb.def, ta6nb.def, i3nt.def, ti3nt.def, c/Mf-*, build.bat, makefiles/Makefile.in, makefiles/Mf-install.in, s/update-revision, BUILDING +- export `ee-backward-delete-sexp` binding in the expression-editor module. + expeditor.ss diff --git a/s/expeditor.ss b/s/expeditor.ss index fadd08827d..04e554d4b6 100644 --- a/s/expeditor.ss +++ b/s/expeditor.ss @@ -82,8 +82,8 @@ ee-beginning-of-entry ee-end-of-entry ee-delete-to-eol ee-delete-line ee-delete-between-point-and-mark ee-set-mark - ee-delete-entry ee-reset-entry ee-delete-sexp ee-redisplay - ee-yank-kill-buffer ee-yank-selection + ee-delete-entry ee-reset-entry ee-delete-sexp ee-backward-delete-sexp + ee-redisplay ee-yank-kill-buffer ee-yank-selection ee-string-macro ee-eof ee-delete-char ee-eof/delete-char ee-backward-delete-char ee-insert-paren ee-flash-matching-delimiter ee-goto-matching-delimiter From 0df195f06663b85c728124643f4524eba0d6ab52 Mon Sep 17 00:00:00 2001 From: 5pyd3r <5pyd3r.tarsylia@gmail.com> Date: Mon, 5 Dec 2016 14:30:26 +1000 Subject: [PATCH 4/6] fix ee_read_char to handle ^@ properly original commit: e962a03987470d0a3937446c10af3a94793ffc43 --- LOG | 2 ++ c/expeditor.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/LOG b/LOG index 9e6e8730a5..a346112fd7 100644 --- a/LOG +++ b/LOG @@ -1385,3 +1385,5 @@ s/update-revision, BUILDING - export `ee-backward-delete-sexp` binding in the expression-editor module. expeditor.ss +- fix ee_read_char to handle ^@ properly + expeditor.c diff --git a/c/expeditor.c b/c/expeditor.c index 5a6a50788c..c16865bc1e 100644 --- a/c/expeditor.c +++ b/c/expeditor.c @@ -691,11 +691,15 @@ static ptr s_ee_read_char(IBOOL blockp) { #endif /* PTHREADS */ if (n == 1) { - old_locale = uselocale(term_locale); - sz = mbrtowc(&wch, buf, 1, &term_out_mbs); - uselocale(old_locale); - if (sz == 1) { - return Schar(wch); + if (buf[0] == '\0') { + return Schar('\0'); + } else { + old_locale = uselocale(term_locale); + sz = mbrtowc(&wch, buf, 1, &term_out_mbs); + uselocale(old_locale); + if (sz == 1) { + return Schar(wch); + } } } From f3cc313d96d870529f8f38c8ddfd4bde2234e671 Mon Sep 17 00:00:00 2001 From: Alexander Shopov Date: Thu, 25 Jul 2019 21:00:19 +0200 Subject: [PATCH 5/6] Add additional check to prevent going before start of buffer (#446) p is a pointer that iterates over path, which is buffer. We should not try to get to an address preceding its start. Since there was an execution path that leads to that, guard against it with an additional check. Signed-off-by: Alexander Shopov original commit: de8d0e742f44c80735a682bd05019246c2087d56 --- LOG | 2 ++ c/scheme.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/LOG b/LOG index a346112fd7..524bc7d48a 100644 --- a/LOG +++ b/LOG @@ -1387,3 +1387,5 @@ expeditor.ss - fix ee_read_char to handle ^@ properly expeditor.c +- prevent access before start of array + scheme.c diff --git a/c/scheme.c b/c/scheme.c index bef291d8c6..31319ea184 100644 --- a/c/scheme.c +++ b/c/scheme.c @@ -530,7 +530,7 @@ static IBOOL next_path(path, name, ext, sp, dsp) char *path; const char *name, * /* unless entry was null, append name and ext onto path and return true with * updated path, sp, and possibly dsp */ if (s != *sp) { - if (!DIRMARKERP(*(p - 1))) { setp(PATHSEP); } + if ((p > path) && !DIRMARKERP(*(p - 1))) { setp(PATHSEP); } t = name; while (*t != 0) setp(*t++); t = ext; From 3fec9b8bba162fcedca41f9acece797dced1a3dd Mon Sep 17 00:00:00 2001 From: Alexander Shopov Date: Thu, 25 Jul 2019 21:05:48 +0200 Subject: [PATCH 6/6] Try to eliminate dead stores (#444) Signed-off-by: Alexander Shopov original commit: 84a6a6ab36294c73dbdc617d19c42fada42c3a15 --- LOG | 2 ++ c/compress-io.c | 2 +- c/new-io.c | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LOG b/LOG index 524bc7d48a..1e340c71b6 100644 --- a/LOG +++ b/LOG @@ -1389,3 +1389,5 @@ expeditor.c - prevent access before start of array scheme.c +- remove dead stores in files + compress-io.c, new-io.c diff --git a/c/compress-io.c b/c/compress-io.c index 376cd03876..960dfb85b5 100644 --- a/c/compress-io.c +++ b/c/compress-io.c @@ -329,7 +329,7 @@ INT S_glzclose(glzFile glz) { #ifdef EINTR if (r < 0 && errno == EINTR) continue; #endif - if (r == 0) { r = Z_ERRNO; saved_errno = errno; } + if (r == 0) { saved_errno = errno; } break; } (void)LZ4F_freeDecompressionContext(lz4->dctx); diff --git a/c/new-io.c b/c/new-io.c index 2a896c19eb..74ed098b1f 100644 --- a/c/new-io.c +++ b/c/new-io.c @@ -842,8 +842,6 @@ ptr S_bytevector_compress(ptr dest_bv, iptr d_start, iptr d_count, if (!is_valid_lz4_length(s_count)) return Sstring("source bytevector ~s is too large"); - destLen = (int)d_count; - destLen = LZ4_compress_default((char *)&BVIT(src_bv, s_start), (char *)&BVIT(dest_bv, d_start), (int)s_count, (int)d_count); if (destLen > 0)