Skip to content

Commit

Permalink
TMP Add patches for 5.2.0~rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
shym committed May 6, 2024
1 parent 0289971 commit b5c3aa7
Show file tree
Hide file tree
Showing 14 changed files with 1,077 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 00aaca1bda7c1df41a105c05d51c26bf1bc98064 Mon Sep 17 00:00:00 2001
From: Samuel Hym <samuel.hym@rustyne.lautre.net>
Date: Tue, 27 Feb 2024 16:14:38 +0100
Subject: [PATCH 01/14] Add missing `defined` in preprocessor test

When `HAS_CLOCK_GETTIME_NSEC_NP` is not defined,
`#elif HAS_CLOCK_GETTIME_NSEC_NP` triggers a warning
---
runtime/unix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runtime/unix.c b/runtime/unix.c
index b5fd4de17b..b397fd2c9c 100644
--- a/runtime/unix.c
+++ b/runtime/unix.c
@@ -47,7 +47,7 @@
#endif
#ifdef HAS_POSIX_MONOTONIC_CLOCK
#include <time.h>
-#elif HAS_CLOCK_GETTIME_NSEC_NP
+#elif defined(HAS_CLOCK_GETTIME_NSEC_NP)
#include <time.h>
#endif
#ifdef HAS_DIRENT
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From e31eb17d071681d415dde4aab9f8658f171b7958 Mon Sep 17 00:00:00 2001
From: Samuel Hym <samuel.hym@rustyne.lautre.net>
Date: Tue, 27 Feb 2024 16:22:58 +0100
Subject: [PATCH 02/14] Include `config.h` before `HAS_GETTIMEOFDAY` is tested

Also remove a duplicate `errno.h`
---
runtime/unix.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/runtime/unix.c b/runtime/unix.c
index b397fd2c9c..abdc8cd630 100644
--- a/runtime/unix.c
+++ b/runtime/unix.c
@@ -21,6 +21,7 @@
/* Helps finding RTLD_DEFAULT in glibc */
/* also secure_getenv */

+#include "caml/config.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -32,8 +33,6 @@
#endif
#include <sys/stat.h>
#include <fcntl.h>
-#include <errno.h>
-#include "caml/config.h"
#if defined(SUPPORT_DYNAMIC_LINKING) && !defined(BUILDING_LIBCAMLRUNS)
#define WITH_DYNAMIC_LINKING
#ifdef __CYGWIN__
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
From a8ae3a7767e76fabe24836ff7244f7e00f13ba8c Mon Sep 17 00:00:00 2001
From: Samuel Hym <samuel.hym@rustyne.lautre.net>
Date: Wed, 21 Feb 2024 18:47:12 +0100
Subject: [PATCH 03/14] Detect and use {CC,...}_FOR_BUILD to build sak

---
Makefile | 9 +-
Makefile.config.in | 4 +
aclocal.m4 | 1 +
build-aux/ax_prog_cc_for_build.m4 | 155 ++++++++++++++++++++++++++++++
configure | Bin 647402 -> 682469 bytes
configure.ac | 10 +-
6 files changed, 172 insertions(+), 7 deletions(-)
create mode 100644 build-aux/ax_prog_cc_for_build.m4

diff --git a/Makefile b/Makefile
index 71d41cd2d6..df191af79c 100644
--- a/Makefile
+++ b/Makefile
@@ -1284,11 +1284,10 @@ runtime/caml/jumptbl.h : runtime/caml/instruct.h
sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \
-e '/^}/q' > $@

-# These are provided as a temporary shim to allow cross-compilation systems
-# to supply a host C compiler and different flags and a linking macro.
-SAK_CC ?= $(CC)
-SAK_CFLAGS ?= $(OC_CFLAGS) $(CFLAGS) $(OC_CPPFLAGS) $(CPPFLAGS)
-SAK_LINK ?= $(MKEXE_VIA_CC)
+SAK_CC ?= $(CC_FOR_BUILD)
+SAK_CFLAGS ?=\
+ $(OC_CFLAGS) $(CFLAGS_FOR_BUILD) $(OC_CPPFLAGS) $(CPPFLAGS_FOR_BUILD)
+SAK_LINK ?= $(SAK_CC) $(SAK_CFLAGS) $(OC_EXE_LDFLAGS) $(OUTPUTEXE)$(1) $(2)

$(SAK): runtime/sak.$(O)
$(V_MKEXE)$(call SAK_LINK,$@,$^)
diff --git a/Makefile.config.in b/Makefile.config.in
index 559738f6ed..4243bebad9 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -65,11 +65,13 @@ LIBTOOL = $(TOP_BUILDDIR)/libtool
### Which C compiler to use
TOOLPREF=@ac_tool_prefix@
CC=@CC@
+CC_FOR_BUILD=@CC_FOR_BUILD@

CC_HAS_DEBUG_PREFIX_MAP=@cc_has_debug_prefix_map@
AS_HAS_DEBUG_PREFIX_MAP=@as_has_debug_prefix_map@

LDFLAGS?=@LDFLAGS@
+LDFLAGS_FOR_BUILD=@LDFLAGS_FOR_BUILD@

### How to invoke the C preprocessor through the C compiler
CPP=@CPP@
@@ -160,7 +162,9 @@ UNIX_OR_WIN32=@unix_or_win32@
INSTALL_SOURCE_ARTIFACTS=@install_source_artifacts@

CFLAGS=@CFLAGS@
+CFLAGS_FOR_BUILD=@CFLAGS_FOR_BUILD@
CPPFLAGS=@CPPFLAGS@
+CPPFLAGS_FOR_BUILD=@CPPFLAGS_FOR_BUILD@
OCAMLC_CFLAGS=@ocamlc_cflags@

OCAMLC_CPPFLAGS=@ocamlc_cppflags@
diff --git a/aclocal.m4 b/aclocal.m4
index cb73385dda..d2e58a45f6 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -30,6 +30,7 @@ m4_include([build-aux/ax_check_compile_flag.m4])

# Macros from the autoconf macro archive
m4_include([build-aux/ax_func_which_gethostbyname_r.m4])
+m4_include([build-aux/ax_prog_cc_for_build.m4])
m4_include([build-aux/ax_pthread.m4])

# OCaml version
diff --git a/build-aux/ax_prog_cc_for_build.m4 b/build-aux/ax_prog_cc_for_build.m4
new file mode 100644
index 0000000000..1db8d73f96
--- /dev/null
+++ b/build-aux/ax_prog_cc_for_build.m4
@@ -0,0 +1,155 @@
+# ===========================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PROG_CC_FOR_BUILD
+#
+# DESCRIPTION
+#
+# This macro searches for a C compiler that generates native executables,
+# that is a C compiler that surely is not a cross-compiler. This can be
+# useful if you have to generate source code at compile-time like for
+# example GCC does.
+#
+# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
+# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD).
+# The value of these variables can be overridden by the user by specifying
+# a compiler with an environment variable (like you do for standard CC).
+#
+# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object
+# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if
+# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are
+# substituted in the Makefile.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 21
+
+AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
+AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_CPP])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+
+dnl Use the standard macros, but make them use other variable names
+dnl
+pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
+pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl
+pushdef([ac_cv_prog_cc_c99], ac_cv_build_prog_cc_c99)dnl
+pushdef([ac_cv_prog_cc_c11], ac_cv_build_prog_cc_c11)dnl
+pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
+pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
+pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
+pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
+pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl
+pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
+pushdef([ac_cv_objext], ac_cv_build_objext)dnl
+pushdef([ac_exeext], ac_build_exeext)dnl
+pushdef([ac_objext], ac_build_objext)dnl
+pushdef([CC], CC_FOR_BUILD)dnl
+pushdef([CPP], CPP_FOR_BUILD)dnl
+pushdef([GCC], GCC_FOR_BUILD)dnl
+pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
+pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
+pushdef([EXEEXT], BUILD_EXEEXT)dnl
+pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
+pushdef([OBJEXT], BUILD_OBJEXT)dnl
+pushdef([host], build)dnl
+pushdef([host_alias], build_alias)dnl
+pushdef([host_cpu], build_cpu)dnl
+pushdef([host_vendor], build_vendor)dnl
+pushdef([host_os], build_os)dnl
+pushdef([ac_cv_host], ac_cv_build)dnl
+pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
+pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
+pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
+pushdef([ac_cv_host_os], ac_cv_build_os)dnl
+pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl
+pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl
+pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl
+pushdef([cross_compiling], cross_compiling_build)dnl
+
+cross_compiling_build=no
+
+ac_build_tool_prefix=
+AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"],
+ [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"])
+
+AC_LANG_PUSH([C])
+
+dnl The pushdef([ac_cv_c_compiler_gnu], ...) currently does not cover
+dnl the use of this variable in _AC_LANG_COMPILER_GNU called by
+dnl AC_PROG_CC. Unset this cache variable temporarily as a workaround.
+was_set_c_compiler_gnu=${[ac_cv_c_compiler_gnu]+y}
+AS_IF([test ${was_set_c_compiler_gnu}],
+ [saved_c_compiler_gnu=$[ac_cv_c_compiler_gnu]
+ AS_UNSET([[ac_cv_c_compiler_gnu]])])
+
+AC_PROG_CC
+
+dnl Restore ac_cv_c_compiler_gnu
+AS_IF([test ${was_set_c_compiler_gnu}],
+ [[ac_cv_c_compiler_gnu]=$[saved_c_compiler_gnu]])
+
+_AC_COMPILER_EXEEXT
+_AC_COMPILER_OBJEXT
+AC_PROG_CPP
+
+dnl Restore the old definitions
+dnl
+popdef([cross_compiling])dnl
+popdef([am_cv_prog_cc_c_o])dnl
+popdef([am_cv_CC_dependencies_compiler_type])dnl
+popdef([ac_tool_prefix])dnl
+popdef([ac_cv_host_os])dnl
+popdef([ac_cv_host_vendor])dnl
+popdef([ac_cv_host_cpu])dnl
+popdef([ac_cv_host_alias])dnl
+popdef([ac_cv_host])dnl
+popdef([host_os])dnl
+popdef([host_vendor])dnl
+popdef([host_cpu])dnl
+popdef([host_alias])dnl
+popdef([host])dnl
+popdef([OBJEXT])dnl
+popdef([LDFLAGS])dnl
+popdef([EXEEXT])dnl
+popdef([CPPFLAGS])dnl
+popdef([CFLAGS])dnl
+popdef([GCC])dnl
+popdef([CPP])dnl
+popdef([CC])dnl
+popdef([ac_objext])dnl
+popdef([ac_exeext])dnl
+popdef([ac_cv_objext])dnl
+popdef([ac_cv_exeext])dnl
+popdef([ac_cv_c_compiler_gnu])dnl
+popdef([ac_cv_prog_cc_g])dnl
+popdef([ac_cv_prog_cc_cross])dnl
+popdef([ac_cv_prog_cc_works])dnl
+popdef([ac_cv_prog_cc_c89])dnl
+popdef([ac_cv_prog_gcc])dnl
+popdef([ac_cv_prog_CPP])dnl
+
+dnl restore global variables ac_ext, ac_cpp, ac_compile,
+dnl ac_link, ac_compiler_gnu (dependant on the current
+dnl language after popping):
+AC_LANG_POP([C])
+
+dnl Finally, set Makefile variables
+dnl
+AC_SUBST(BUILD_EXEEXT)dnl
+AC_SUBST(BUILD_OBJEXT)dnl
+AC_SUBST([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zM#D%1!+vOkwLIZDqoLG4Dj9BZs*h&*OSOWF;c4O$+G
z`ep};oy|NH3(Y(fbi4vPTi{MxB)tVT*`GgbffcOM)FXCa`6?J^CmAGWS7kzC{oU6^
z;>6t!65XpEBuZKx^RI2aar5`JIyz6ZLdR{@A=qF!2H$9*<std<zJc~iqM1^md95~!
zixaIiX1sTq*;U22^C1r#=d;_4=dY0&vBo;w>Lk&oj#+#Xbt(BqOswN~JxQ|}XFPDg
zt~}T%Kv^EkL6eXSW)&L&0opxxa4TFmpU#HQTaIYVWy6Oa+bJn;)qq^sNtUsD@xBg7
z-rtVrLA6c&N*=V??G;P@RO`?hYhJc7n*hP+&4+i1{kk^pDTJqOU0%L+<q?84#ZZxa
zdUq5<ZSs4d806&lkz%-POR&ELzDabP-A9&}WNc`nTnf!Lac?QC!426<*5U&>AmQt!
zu-n!$x@RBl;~kq6+wiQA)rAF1#RlU-8AKq*f`Jm?D;_8}^a}VsVJ1)MLJ1aC!g^-z
zL>^Q<;OwJ}ojhZ8tCPJRmL!FoB})=HYX?p*2xYfb%-JS6a#6VaNU8!Uj`yp5X6u7(
z<foo>+_YwPOp=jmHB8uDcydNazKze!2;<B}LZ+>AzP%!=-HL0<*!;F|e95?FDyuoS
zZ5yrS>=}|N0<9nH9B<>~#^jCA>h*mxQ_9o4f`%jUei?sO0*$%c0f}xOKV^)~3poN?
mKAu<*_S{x(Q)*%6O0bd{AM;1Hiz5AJ(SNqFUCep*;=cik1bC1D

delta 62
zcmaEQS@YFF^$k<}nuYw^h5Q+Tm<foPftY2xkU#6J?bFMzvkFYNV`md?_vvQ?Vs;?r
L*zVKMIrA0(*pn7|

diff --git a/configure.ac b/configure.ac
index 0c9d63859a..e23db6acd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -784,8 +784,14 @@ dnl nefarious single quotes which may appear in any of the strings.

AS_IF(
[test x"$host" = x"$target"],
- [cross_compiler=false],
- [cross_compiler=true])
+ [cross_compiler=false
+ CC_FOR_BUILD='$(CC)'
+ CFLAGS_FOR_BUILD='$(CFLAGS)'
+ CPPFLAGS_FOR_BUILD='$(CPPFLAGS)'
+ LDFLAGS_FOR_BUILD='$(LDFLAGS)'],
+ [cross_compiler=true
+ AC_MSG_NOTICE([detecting the C toolchain for build])
+ AX_PROG_CC_FOR_BUILD])

# Checks for programs

--
2.43.0

Loading

0 comments on commit b5c3aa7

Please sign in to comment.