Skip to content

Commit

Permalink
TMP Add patches for 5.2.0~beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
shym committed Apr 18, 2024
1 parent ce48b31 commit 8c4b29c
Show file tree
Hide file tree
Showing 13 changed files with 1,023 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 8300488c8891138da0bb490f1e74aaa9acfe11bd Mon Sep 17 00:00:00 2001
From: Samuel Hym <[email protected]>
Date: Tue, 27 Feb 2024 16:14:38 +0100
Subject: [PATCH 01/13] 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 3a811f54eb8b087ccbcebf40898053c37afec2a5 Mon Sep 17 00:00:00 2001
From: Samuel Hym <[email protected]>
Date: Tue, 27 Feb 2024 16:22:58 +0100
Subject: [PATCH 02/13] 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,310 @@
From 7353c75e772ad2beed7d4f9344e7d777d2786556 Mon Sep 17 00:00:00 2001
From: Samuel Hym <[email protected]>
Date: Wed, 21 Feb 2024 18:47:12 +0100
Subject: [PATCH 03/13] 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 647384 -> 682451 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 <[email protected]>
+#
+# 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([CFLAGS_FOR_BUILD])dnl
+AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
+AC_SUBST([LDFLAGS_FOR_BUILD])dnl
+])
diff --git a/configure b/configure
index c307be8f419008a6282200bfe39e231a24da8dbb..81a01f255d8c54961f0ebde2437dc859954c2380 100755
GIT binary patch
delta 6734
zcmds6du)@}71uq+pPdhq)T{F#4dLd)vGX#C17xt^P)O1Mjq+$q#rnVtjuX<RHpC7M
zOVfbbsb!j0SSn7pXe)H9T4=R_rtRa8jWuH0q>Zl45XwecNGiehPo||}?K+KW_j}mB
z*C8V+DSr^j(s$22_dI^*+;i_e`OB#1{P~iTKWH9ms=u#kW8;H?`&u3dY}&S^sa~#Y
zZJk9*CFq=imQ7n5wm&2rgNE%5+JLR*WVHta!C0WKjw6YK=SG@e7-=T#2kd8IzeVau
zv-OlZMA;wD>-V^d>*`88vObYwkUpu?;taE#&{<5X$u!G%jmIQHi3jhOBo|)DlBx<j
zLa|UV)*bGmv0WirM`MvlPjFXzcbIlYdg;!-Zfxs>+~K3&w+-EtwWmX&weISgL0OiA
zy^&}%5R5#vySs-;4=_nR9sY1cmKk#TAfTxV?CuS9cK7?`?oJvDMPt+(rix3SS7c^U
zn0}4HqA%IS1PE(PKCdE&dS)*VwD)wkM^lB&A;Vy1k~+I(86Az5tewfgQrGOn@n~)s
z-h~*pd^o8$$X29;@kTPx_pWV4fYalR&|oCoso~&CpcLv4h5BRjlSo~&0*`yDVRfYe
zc*5e|Kv%er1?lPbXdoJj1;h!zYXD~^Y|b@h`vwznaShy<c`zBJX#3t!M*ycLY(<im
z$^%pvljg6XePO1?7}{8R+?gm_b(HZN=Lj`F+jdy$@$5OW-W-2^j-0T^1CGAaq+to4
zIk@p%$hwE8_!S|w)B~l`LnJqaV<4U@7<!K!t%=KTs`qPI6x_@9SfooVRl;^jio>xh
zQk~3=3$IGKqKSu3Ko7n%Lkd<W^(Zx3@dz6mHKi*01qZNwno!&@MlOmlU~3;pq9TUH
zJ%veAm^X^<j#zXJL~!yvv1cX?@+)1zAhum0-^EMELE=4X`whuTQMB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
z!@h*BK_6`Pin$+LyH4A=>;b1etJ&)<<slW%j+c1394gnV=0s)3syR{l^{NCa!PPM4
zm}L_l`>{3OOqEC0Kz`Ny^22z7vU0@S!oo5rG)4S$4Q#lhIxU+F#KeXQ>$Jol-1BIo
z=uMNQewWcsNs-jqjiYC64O(gT;(szB19PYB)#|VQOD3cuL$}c|V!a!7ZW%qb`14So
z$CH+L-l^jj*h@<JW!g(N9MM)9tpk3}FC%HR+^s%qh4q%D!i-Q0es71hMts%J?eK}k
zj5Sl{RcSgrOqTF#(RajJyO^WkOw^KlWVd8B*G*(VwP0higJ`(wckz8%)OW`IQJbtj
zoe7tS`S4b^Ibhg4r+;q$$72NRoRAlPl|Sx;;`sNsoIvB>uRGz2O}EXn5(_h6HU2gW
zwxRC;$;XOp$c*#VW<#ZE?o-*Y4yRtStj8avfsD&@U<rPj4Q-~=k)2PlcHZ!*seO73
z)oVEr1{1CJJUC6#3@8}iu<vRv{%b$kguC-$MN5Lt)*F3RIw%{B>Ug7vXGx-DsEngz
zwzluUE~goQ*DqSHJeDj=+V#zBEqAcive3m(KKBH&Uu#gtcdYlDsjKkJgf%bSz}jf7
zwc>$k_$p?9V7-^Sb5Pbq7yEbA+n}V7)UFS#Ba3PUX|1f*3;%4;>|xgxo+gAG>6A5R
z+5eS+Gy6%+Von5Vy}fjf&{VIEOj*;c{DJb5tJa-&RDE_DAc<8K5B-r$f-JufmL&GG
Nv7cQHOKDGB{2%PRV<P|n

delta 62
zcmcb7S@Xt0^$oN9nkD?(CHxtIm<foPftY2xgg@)1?bFrGI0dH1u(JubXZ5oIF*^`*
LY|rZF%)A8v$tM;O

diff --git a/configure.ac b/configure.ac
index f6fbf61157..98a8fcefd4 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 8c4b29c

Please sign in to comment.