[MLton] Patches needed for MLton in debian/stretch
"Wesley W. Terpstra" <[email protected]> Sat, 17 Dec 2016 14:24:30 -0800
| Newsgroups | gmane.comp.lang.ml.mlton.devel |
|---|---|
| Message-ID | <CAA-O0Xi+SgrEAj7GBrTpf0oWbmUkQP9H69DWiC=G6y=NANA=Mw@mail.gmail.com> |
Hey, I had to make a few minor changes to MLton to get it to build on all the current debian architectures. I leave it up to your discretion if any should be merged upstream. I believe you already have the arm64.patch, but not the rest. The patch which turns PIC on by default for linux should probably come with a corresponding option to turn PIC off. However, since binaries in debian are now required by policy to turn on PIC, I did not include a new command-line option. Also, there is currently a regression causing every world* test to fail on every architecture. I have not yet investigated, as this little-used feature does not seem to affect the compiler negatively, I suspect it's related to the security improvements made to debian, and it the deadline to get MLton into stretch is Dec 24th (Jan 5th - 10 days waiting time). ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ MLton-devel mailing list [email protected]; [email protected] https://lists.sourceforge.net/lists/listinfo/mlton-devel
mips64el.patch
(application/octet-stream, 3.8 KB)
--- a/basis-library/mlton/platform.sig
+++ b/basis-library/mlton/platform.sig
@@ -10,7 +10,7 @@
structure Arch:
sig
datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | m68k |
- MIPS | PowerPC | PowerPC64 | S390 | Sparc | X86
+ MIPS | MIPS64 | PowerPC | PowerPC64 | S390 | Sparc | X86
val fromString: string -> t option
val host: t
--- a/basis-library/mlton/platform.sml
+++ b/basis-library/mlton/platform.sml
@@ -25,6 +25,7 @@
(IA64, "IA64"),
(m68k, "m68k"),
(MIPS, "MIPS"),
+ (MIPS64, "MIPS64"),
(PowerPC, "PowerPC"),
(PowerPC64, "PowerPC64"),
(S390, "S390"),
--- a/basis-library/primitive/prim-mlton.sml
+++ b/basis-library/primitive/prim-mlton.sml
@@ -153,6 +153,7 @@
| IA64
| m68k
| MIPS
+ | MIPS64
| PowerPC
| PowerPC64
| S390
@@ -169,6 +170,7 @@
| "ia64" => IA64
| "m68k" => m68k
| "mips" => MIPS
+ | "mips64" => MIPS64
| "powerpc" => PowerPC
| "powerpc64" => PowerPC64
| "s390" => S390
--- a/bin/platform
+++ b/bin/platform
@@ -108,6 +108,9 @@
m68k*)
HOST_ARCH=m68k
;;
+mips64*)
+ HOST_ARCH=mips64
+;;
mips*)
# big-endian and little-endian detect via headers
HOST_ARCH=mips
--- a/lib/stubs/mlton-stubs/mlton.sml
+++ b/lib/stubs/mlton-stubs/mlton.sml
@@ -159,7 +159,7 @@
structure Arch =
struct
datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | m68k |
- MIPS | PowerPC | PowerPC64 | S390 | Sparc | X86
+ MIPS | MIPS64 | PowerPC | PowerPC64 | S390 | Sparc | X86
val all = [(Alpha, "Alpha"),
(AMD64, "AMD64"),
@@ -169,6 +169,7 @@
(IA64, "IA64"),
(m68k, "m68k"),
(MIPS, "MIPS"),
+ (MIPS64, "MIPS64"),
(PowerPC, "PowerPC"),
(PowerPC64, "PowerPC64"),
(S390, "S390"),
--- a/lib/stubs/mlton-stubs/platform.sig
+++ b/lib/stubs/mlton-stubs/platform.sig
@@ -10,7 +10,7 @@
structure Arch:
sig
datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | m68k |
- MIPS | PowerPC | PowerPC64 | S390 | Sparc | X86
+ MIPS | MIPS64 | PowerPC | PowerPC64 | S390 | Sparc | X86
val fromString: string -> t option
val host: t
--- a/mlton/main/main.fun
+++ b/mlton/main/main.fun
@@ -191,6 +191,7 @@
| HPPA => true
| IA64 => true
| MIPS => true
+ | MIPS64 => true
| Sparc => true
| S390 => true
| _ => false
--- a/runtime/cenv.h
+++ b/runtime/cenv.h
@@ -112,6 +112,8 @@
#include "platform/ia64.h"
#elif (defined (__m68k__))
#include "platform/m68k.h"
+#elif (defined (__mips64))
+#include "platform/mips64.h"
#elif (defined (__mips__))
#include "platform/mips.h"
#elif (defined (__powerpc64__))
--- /dev/null
+++ b/runtime/platform/mips64.h
@@ -0,0 +1 @@
+#define MLton_Platform_Arch_host "mips64"
--- a/runtime/platform/linux.c
+++ b/runtime/platform/linux.c
@@ -37,7 +37,7 @@
#else
GC_handleSigProf ((code_pointer) scp->si_regs.pc);
#endif
-#elif (defined (__mips__))
+#elif (defined (__mips64)) || (defined (__mips__))
ucontext_t* ucp = (ucontext_t*)context;
#ifdef __UCLIBC__
GC_handleSigProf ((code_pointer) ucp->uc_mcontext.gpregs[CTX_EPC]);
arm64.patch
(application/octet-stream, 1.4 KB)
--- a/lib/stubs/mlton-stubs/mlton.sml
+++ b/lib/stubs/mlton-stubs/mlton.sml
@@ -158,12 +158,13 @@
structure Arch =
struct
- datatype t = Alpha | AMD64 | ARM | HPPA | IA64 | m68k |
+ datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | m68k |
MIPS | PowerPC | PowerPC64 | S390 | Sparc | X86
val all = [(Alpha, "Alpha"),
(AMD64, "AMD64"),
(ARM, "ARM"),
+ (ARM64, "ARM64"),
(HPPA, "HPPA"),
(IA64, "IA64"),
(m68k, "m68k"),
--- a/lib/stubs/mlton-stubs/platform.sig
+++ b/lib/stubs/mlton-stubs/platform.sig
@@ -9,7 +9,7 @@
sig
structure Arch:
sig
- datatype t = Alpha | AMD64 | ARM | HPPA | IA64 | m68k |
+ datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | m68k |
MIPS | PowerPC | PowerPC64 | S390 | Sparc | X86
val fromString: string -> t option
--- a/mlton/main/main.fun
+++ b/mlton/main/main.fun
@@ -187,6 +187,7 @@
Alpha => true
| AMD64 => true
| ARM => true
+ | ARM64 => true
| HPPA => true
| IA64 => true
| MIPS => true
--- /dev/null
+++ b/runtime/platform/arm64.h
@@ -0,0 +1 @@
+#define MLton_Platform_Arch_host "arm64"
kfreebsd.patch
(application/octet-stream, 346 B)
--- a/runtime/platform/freebsd.h +++ b/runtime/platform/freebsd.h @@ -37,9 +37,4 @@ #define MLton_Platform_OS_host "freebsd" -/* This is probably debian specific, since freebsd worked w/o it before. */ -#if (defined (__FreeBSD_kernel__)) -#define getpgrp() getpgrp(getpid()) -#endif - extern char **environ; /* for Posix_ProcEnv_environ */
ppc64el.patch
(application/octet-stream, 156 B)
--- a/bin/platform
+++ b/bin/platform
@@ -115,7 +115,7 @@
powerpc64)
HOST_ARCH=powerpc64
;;
-ppc64)
+ppc64*)
HOST_ARCH=powerpc64
;;
powerpc)
features-fix.patch
(application/octet-stream, 422 B)
Index: mlton-20130715/runtime/cenv.h =================================================================== --- mlton-20130715.orig/runtime/cenv.h +++ mlton-20130715/runtime/cenv.h @@ -13,6 +13,7 @@ /* GNU C Library Feature Macros */ #define _ISOC99_SOURCE #define _BSD_SOURCE +#define _DEFAULT_SOURCE 1 // #define _XOPEN_SOURCE 600 /* Only enable _POSIX_C_SOURCE on platforms that don't have broken * system headers.
linux-pic.patch
(application/octet-stream, 352 B)
--- a/mlton/main/main.fun
+++ b/mlton/main/main.fun
@@ -886,6 +886,7 @@
(* On ELF systems, we only need PIC for LibArchive/Library *)
| (_, _, Library) => true
| (_, _, LibArchive) => true
+ | (Linux, _, _) => true
| _ => false
val () = Control.positionIndependent := positionIndependent
stack-hardening.patch
(application/octet-stream, 1.8 KB)
Index: mlton-20130715/bin/mlton-script
===================================================================
--- mlton-20130715.orig/bin/mlton-script
+++ mlton-20130715/bin/mlton-script
@@ -113,6 +113,7 @@ doit "$lib" \
-target-cc-opt freebsd '-I/usr/local/include' \
-target-cc-opt netbsd '-I/usr/pkg/include' \
-target-cc-opt openbsd '-I/usr/local/include' \
+ -target-cc-opt linux '-fstack-protector-strong' \
-target-cc-opt aix '-maix64' \
-target-cc-opt ia64 "$ia64hpux -mtune=itanium2" \
-target-cc-opt sparc '-m32 -mcpu=v8 -Wa,-xarch=v8plusa' \
@@ -131,7 +132,7 @@ doit "$lib" \
-target-link-opt freebsd '-L/usr/local/lib/' \
-target-link-opt aix '-maix64' \
-target-link-opt ia64 "$ia64hpux" \
- -target-link-opt linux '-Wl,-znoexecstack' \
+ -target-link-opt linux '-Wl,-znoexecstack,-zrelro' \
-target-link-opt mingw \
'-lws2_32 -lkernel32 -lpsapi -lnetapi32 -lwinmm' \
-target-link-opt mingw '-Wl,--enable-stdcall-fixup' \
Index: mlton-20130715/runtime/Makefile
===================================================================
--- mlton-20130715.orig/runtime/Makefile
+++ mlton-20130715/runtime/Makefile
@@ -85,6 +85,11 @@ OPTXCFLAGS := -Wdisabled-optimization -O
DEBUGXCFLAGS := -DASSERT=1 -Wno-uninitialized -O0 -g
PICXCFLAGS :=
+# Use stack hardening for the C method calls on linux
+ifeq ($(TARGET_OS), linux)
+XCFLAGS += -fstack-protector-strong
+endif
+
# Win32&64 don't use PIC code, all other platforms do
ifeq ($(findstring $(TARGET_OS), mingw cygwin),)
PICXCFLAGS += -fPIC