diff --git a/GNUmakefile b/GNUmakefile index 7845cfc..3f80746 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,8 +4,8 @@ AS= $(CONFIG_TARGET_CC) # NOTE(dinosaure): we must use [aarch64-none-elf-gcc] to compile assembly code # to be able to include some files and define some macros. LD= $(CONFIG_TARGET_LD) -AR= aarch64-none-elf-ar # TODO -OBJDUMP= aarch64-none-elf-objdump # TODO +AR= aarch64-linux-gnu-ar # TODO +OBJDUMP= aarch64-linux-gnu-objdump # TODO OBJCOPY= $(CONFIG_TARGET_OBJCOPY) export TOPDIR := $(abspath .) @@ -37,7 +37,7 @@ CFLAGS += -std=c11 -ffreestanding -fstack-protector-strong -nostdlib \ LDFLAGS += -nostdlib -static -Wl,--no-warn-rwx-segments \ -Wl,--section-start=.init=0x80000 -Wl,--build-id=none \ - -Wl,--start-group -L . -lgilbraltar -L nolibc -lnolibc -L openlibm -lopenlibm -lgcc -Wl,--end-group + -Wl,--start-group -L lib/$(CONFIG_TARGET_TRIPLE) -lgilbraltar.rpi5 -L nolibc -lnolibc -L openlibm -lopenlibm -lgcc -Wl,--end-group SRCS= kernel.c timer.c led.c interrupt_handler.c exception_handler.c \ mbox.c clock.c crt.c serial.c log.c power.c tag.c coherent_page.c dtb.c \ @@ -50,6 +50,23 @@ ASMS:=$(addprefix kernel/,$(ASMS)) OBJS= $(SRCS:c=o) $(ASMS:S=o) +bin: + @test ! -d $@ + @mkdir -p $@ + +bin/$(CONFIG_TARGET_TRIPLE)-%: toolchain/%.in | bin + @echo "SUBST $@" + @sed -e 's!@@CONFIG_TARGET_ARCH@@!$(CONFIG_TARGET_ARCH)!g' \ + -e 's!@@CONFIG_TARGET_TRIPLE@@!$(CONFIG_TARGET_TRIPLE)!g' \ + -e 's!@@CONFIG_TARGET_CC@@!$(CONFIG_TARGET_CC)!g' \ + -e 's!@@CONFIG_TARGET_CC_CFLAGS@@!$(CONFIG_TARGET_CC_CFLAGS)!g' \ + -e 's!@@CONFIG_TARGET_CC_LDFLAGS@@!$(CONFIG_TARGET_CC_LDFLAGS)!g' \ + -e 's!@@CONFIG_TARGET_LD@@!$(CONFIG_TARGET_LD)!g' \ + -e 's!@@CONFIG_TARGET_LD_LDFLAGS@@!$(CONFIG_TARGET_LD_LDFLAGS)!g' \ + -e 's!@@CONFIG_TARGET_OBJCOPY@@!$(CONFIG_TARGET_OBJCOPY)!g' \ + $< >$@ + @chmod +x $@ + %.o: %.S @echo "AS $@" @$(AS) $(AFLAGS) -c -o $@ $< @@ -58,11 +75,18 @@ OBJS= $(SRCS:c=o) $(ASMS:S=o) @echo "CC $@" @$(CC) $(CFLAGS) -c -o $@ $< -kernel/libgilbraltar.a: $(OBJS) +lib/$(CONFIG_TARGET_TRIPLE): + @test ! -d $@ + @mkdir -p $@ + +lib/$(CONFIG_TARGET_TRIPLE)/libgilbraltar.rpi5.a: $(OBJS) | lib/$(CONFIG_TARGET_TRIPLE) @echo "AR $@" @rm -f $@ @$(AR) cr $@ $^ +lib/$(CONFIG_TARGET_TRIPLE)/libgilbraltar.stub.a: | lib/$(CONFIG_TARGET_TRIPLE) + @$(AR) cr $@ + .PHONY: phony-openlibm phony-openlibm: include/$(CONFIG_TARGET_TRIPLE) @$(MAKE) -C openlibm \ @@ -79,11 +103,12 @@ ocaml: fi ocaml/Makefile.config: | ocaml - PATH="$$PWD/$(TOOLDIR_FOR_BUILD):$$PATH" ; + PATH="$$PWD/bin/:$$PATH" ; \ cd ocaml && \ ./configure \ - --target="$(MAKECONF_TARGET_ARCH)-gilbraltar-ocaml" \ - --prefix="$(MAKECONF_SYSROOT)" \ + --host="$(CONFIG_HOST_ARCH)-unknown-none" \ + --target="$(CONFIG_TARGET_TRIPLE)" \ + --prefix="$(CONFIG_SYSROOT)" \ --disable-shared \ --disable-systhreads \ --disable-unix-lib \ @@ -91,7 +116,7 @@ ocaml/Makefile.config: | ocaml --disable-debug-runtime \ --disable-ocamltest \ --disable-ocamldoc \ - --disable-zstd \ + --without-zstd \ $(MAKECONF_OCAML_CONFIGURE_OPTIONS) OCAML_IS_BUILT := _build/ocaml_is_built @@ -111,13 +136,15 @@ phony-nolibc: include/$(CONFIG_TARGET_TRIPLE) nolibc/libnolibc.a: phony-nolibc .PHONY: all -all: kernel/libgilbraltar.a +all: kernel/libgilbraltar.rpi5.a .PHONY: clean clean: $(RM) -f kernel/*.o kernel/*.a *.elf *.bin *.img *.map - $(RM) -rf include/$(CONFIG_TARGET_TRIPLE) + $(RM) -rf include/$(CONFIG_TARGET_TRIPLE)/ $(RM) -rf _build + $(RM) -rf bin/ + $(RM) -rf lib/$(CONFIG_TARGET_TRIPLE)/ if [ -d ocaml ] ; then $(MAKE) -C ocaml clean ; fi $(RM) -f test/*.o $(MAKE) -C openlibm clean @@ -132,7 +159,7 @@ test/%.o: test/%.c @echo "CC $@" @$(CC) $(CFLAGS) -c -o $@ $< -kernel_2712.img: kernel/libgilbraltar.a nolibc/libnolibc.a openlibm/libopenlibm.a test/test.o +kernel_2712.img: lib/$(CONFIG_TARGET_TRIPLE)/libgilbraltar.rpi5.a nolibc/libnolibc.a openlibm/libopenlibm.a test/test.o @echo "LD ${@:img=elf}" - @$(LD) test/test.o -o ${@:img=elf} $(LDFLAGS) -Wl,-Map ${@:img=map} -Wl,-T gilbraltar.ld + @$(LD) test/test.o -o ${@:img=elf} $(LDFLAGS) -Wl,-Map ${@:img=map} -Wl,-T gilbraltar.rpi5.ld @$(OBJCOPY) ${@:img=elf} -O binary $@ diff --git a/configure.sh b/configure.sh index 0f6a0eb..2a9423f 100755 --- a/configure.sh +++ b/configure.sh @@ -18,9 +18,9 @@ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -TARGET_CC="${TARGET_CC:-aarch64-none-elf-gcc}" -TARGET_LD="${TARGET_LD:-aarch64-none-elf-gcc}" -TARGET_OBJCOPY="${TARGET_OBJCOPY:-aarch64-none-elf-objcopy}" +TARGET_CC="${TARGET_CC:-aarch64-linux-gnu-gcc}" +TARGET_LD="${TARGET_LD:-aarch64-linux-gnu-gcc}" +TARGET_OBJCOPY="${TARGET_OBJCOPY:-aarch64-linux-gnu-objcopy}" prog_NAME="$(basename $0)" @@ -424,7 +424,7 @@ fi echo "${prog_NAME}: Using ${TARGET_LD} for target linker" echo "${prog_NAME}: Using ${TARGET_OBJCOPY} for target objcopy" -TARGET_TRIPLE="${TARGET_ARCH}-gilbraltar-none-static" +TARGET_TRIPLE="${TARGET_ARCH}-gilbraltar-none" echo "${prog_NAME}: Target toolchain triple is ${TARGET_TRIPLE}" # diff --git a/gilbraltar.ld b/gilbraltar.rpi5.ld similarity index 100% rename from gilbraltar.ld rename to gilbraltar.rpi5.ld diff --git a/gilbraltar.stub.ld b/gilbraltar.stub.ld new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/gilbraltar.stub.ld @@ -0,0 +1 @@ + diff --git a/libgilbraltar.a b/libgilbraltar.a deleted file mode 100644 index 2ef3e95..0000000 Binary files a/libgilbraltar.a and /dev/null differ diff --git a/patches/5.2.1/0001-Fix-two-small-issues-with-preprocessor-directives-13.patch b/patches/5.2.1/0001-Fix-two-small-issues-with-preprocessor-directives-13.patch new file mode 100644 index 0000000..6895757 --- /dev/null +++ b/patches/5.2.1/0001-Fix-two-small-issues-with-preprocessor-directives-13.patch @@ -0,0 +1,49 @@ +From 189d0adbdcbc480fe3c9c79abf4b3f1df584e0c1 Mon Sep 17 00:00:00 2001 +From: shym +Date: Thu, 4 Jul 2024 18:01:17 +0200 +Subject: [PATCH 01/14] Fix two small issues with preprocessor directives + (#13281) + +* Add missing `defined` in preprocessor test + +When `HAS_CLOCK_GETTIME_NSEC_NP` is not defined, +`#elif HAS_CLOCK_GETTIME_NSEC_NP` triggers a warning + +* Include `caml/config.h` before `HAS_GETTIMEOFDAY` is tested + +Also remove a duplicate `errno.h` +--- + runtime/unix.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/runtime/unix.c b/runtime/unix.c +index b5fd4de17b..c0677e09ac 100644 +--- a/runtime/unix.c ++++ b/runtime/unix.c +@@ -27,13 +27,12 @@ + #include + #include + #include ++#include "caml/config.h" + #ifdef HAS_GETTIMEOFDAY + #include + #endif + #include + #include +-#include +-#include "caml/config.h" + #if defined(SUPPORT_DYNAMIC_LINKING) && !defined(BUILDING_LIBCAMLRUNS) + #define WITH_DYNAMIC_LINKING + #ifdef __CYGWIN__ +@@ -47,7 +46,7 @@ + #endif + #ifdef HAS_POSIX_MONOTONIC_CLOCK + #include +-#elif HAS_CLOCK_GETTIME_NSEC_NP ++#elif defined(HAS_CLOCK_GETTIME_NSEC_NP) + #include + #endif + #ifdef HAS_DIRENT +-- +2.45.2 + diff --git a/patches/5.2.1/0002-Detect-and-use-CC-.-_FOR_BUILD-to-build-sak.patch b/patches/5.2.1/0002-Detect-and-use-CC-.-_FOR_BUILD-to-build-sak.patch new file mode 100644 index 0000000..91ede64 --- /dev/null +++ b/patches/5.2.1/0002-Detect-and-use-CC-.-_FOR_BUILD-to-build-sak.patch @@ -0,0 +1,311 @@ +From acd2f9c4ae0ee5dd550796b547e781794eb9b58c Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Wed, 21 Feb 2024 18:47:12 +0100 +Subject: [PATCH 02/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 647326 -> 682393 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 ++# ++# 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 49d5bff6495b2f38d91d97ec777a4212e3c23677..9f16ca87352a88b5e995631c15fd8914f6b2ebfc 100755 +GIT binary patch +delta 6754 +zcmds5eN0r@70*4x8{mn2L`L~qc=H?>6lV~20WBRBXVBG91-ET%WBL}xfn~)RWQLV3 +zK{Ph8G;Lv*T~2gUm$peawcBQClTMp#7frfd~-*CgKtYi-PWh1EjxEfo4>TJ!N+?W +z8xy+B9SWzkbMyB4-CyKYqJDS1OwiektY*LDk4RoG(`6)%4(vEKu!GPa=x?EaQgmPk +zCq?@O`mwwor=!&CUFGDJ0n>(*L8ULokf4OZqV;M_3A)QXS|_Y>;&smIz@rCKDhu}p +zA_0G-J=i8ho(TwEArcC8_@8NR4+^cJE&+dkm=p|WZnXCQcfOYH_Kv-xu%V>7wvXp| +ze^)3Rmi(dpo$Vb|w4@Asf+3!#uqlKjuOoGK1zOvCJbZhr5DA1Mf-5M94pkOUw-XdT +zM=?>R_^Euu9F5N<@_~-T=~8n?dvjPc30Xjf%Ip#`R0Vl0`hg0LM1yh48mNi|D5mT& +z3NAmLVLHC~WDMJsh&p=bXY13E4L3g**el`eq@~y@8*s0HbCZ_r +zR8OtY9i$7WB-Hjjn(%T8y!i21B52L#+u%d#9QnLPpEyTO@%l;Q_umC?8f!TC!Utf> +zWqUj#V_DI;H_4Ytj%mC%W+X^1kkMLQzDG76|8w+ih1!h%DR!vJEz`x}l@{>w4Bb3V +za#*^5oP_Z7QA>Wc&eY%&Yh{lSR4=H>6?&NMH~6q=ng}?3kxZFkz|0#Yh3%wB-ssD*=nipMRUe0kFG9Cw1hao4yR_!c2`GQcu=@lR>02cTt?kscg#)x@ +zU{(Q{=X~*nNn&Hc{Lv&4b(>s{mnX?Sjo$h$`7z7-pl$M}eL5DMPaef5m#3FT6!YjXS+>N5zVze)Ev!8CrD0uj%x_WG#nV6j;C!8ib?i(unx_xlH^~OgT=(51ubXiUofuV%kt{}1NX +z6lFtIeqK#M%(f~DB_%Yd?G-w^@J2Zq!0&B<^l0%1q~C)7oPZkq$M2HT@Z4`xQ}OQw +zbY#2$-Xf|kzdS~q_`^cDyHdY|p63JM*t@=!)dzo41O;xLvF!OiIoFWGYe~&2XjEm& +zE^xL8yxIC3nk)GOosqEM!n&%Id>pi=EV0cu+=gck5fOU@7${To10`Ja`=vHHO_LK; +z(^4MM)h1%|U*Y7)AZN`mO~RRV)@+=ygLSFCoJSOKw3OIJZgAD;{u)<1vOPH$Px+Fw +z@VE%&Su7_N&Zpwsb*^6F#HW9gY}Xt@XeHF>cn%N!t8_jJ>m2Z6x^Y{0<|AtkcJ8xs +zcIw4 +z_y$Y&mB2<5U5Ha9@R$b7of3FbYkHhexJ2JRKRkBZhoesLvGbcMVVlOkrW8DJ6m9s1 +z3$nD4@07v@cG9P=I7aW6!fRPZg#8s2IN^r3GtJ$YwV$xi53Gg)CWJO5I1N5QiwG1c +zIJO#G+HNkdh9P!0`^$`wP}%^=wX!%Qt~K*OGPDMcvGN#5B-cWaoOUe;Ns${~)3*Ay +z8z!{o%jHn2THKrE_pbJP<#Dw$*BaFxU29aE(uMfR+PEd;R>akQx?&!+sU>9Kx0?u$ +zmnxup0RWCyE(E}bl?wv!mB-@%eD-)8fD2D(0Bly%Q0iCw>(;CFA)!xpF9}Hv>k5tL +zP*@emWqTEDeB=r=o7KBxti#X(O)Pr4hZ>Ahamn{M)LM*5lKj5mk!{JHIFbSB__vvq +z>geu|$+WdtU05wL(dR~f=#)1wmSU>cvB3hG$Hl=ka79Ngu#MQ+xw5wmhUDpL=|LHb +zewqZkEx9aTtTds@^{2o(^}<9?q`)1E)~0J5)!t9cN{9N?xCG2BfFku?9ZZL6wNNOj +z+t&+=D(!KowcF@;I#hy|kVoe-VOW#>i}!BsA$VmO=hNJ#a(!ii*36A*j^L^nOS(pS +z#>QA6$y~emm{}-w19A-89*ndKc(N$Ty@Xi+<(l78rlY|Zt(oOgIrgpCbd76yPu7q0nJy5)&Kwi + +delta 62 +zcmbPvS##b&^$i_<&20YdZ2pWu%ml>DK+Lk8&7U=4`}CCy*!ib_XJZp-XX|GJVs;?r +L*v{6^Ir$a +Date: Thu, 22 Feb 2024 13:37:28 +0100 +Subject: [PATCH 03/14] Use `target` instead of `host` to detect the C + toolchain + +When building a cross-compiler, the runtime will run on the target, not +the host so: +- set `cross_compiling` by comparing `build` to `target` (rather than to + `host`), as this variable will be used later +- use `target` to set up the tool prefix, +- as the libtool configuration will configure a `build` to `host` + toolchain, temporarily assign `host*` values to `target*` values +--- + configure | Bin 682393 -> 682949 bytes + configure.ac | 18 ++++++++++++++++++ + 2 files changed, 18 insertions(+) + +diff --git a/configure b/configure +index 9f16ca87352a88b5e995631c15fd8914f6b2ebfc..f81f4ca213b710395b61b64d1380318d4d80867d 100755 +GIT binary patch +delta 1998 +zcmZ`(drVbz9N+yt?u9D~^12Qaj&QXR!UV#QN5pXGe6e(h`QUQ6_W&nu=Unc&0<{Wr +zD<>GO8vK+s2i9!ONBq(FHF{hNafq|VoH5JU!?YZcjAl&@>UX)nUodan?QEa>`F_s# +z{XIu7rw)#$?*GVC)z(thsCd1qOOc#j-7p+Z{W*{7R<&A5)?AY8bog}L?eKV&8nsz! +zl)b84?N$uQP&KC_`RWv@L<%UJb+W2Ss$or$_8E$caZ;_KDPGyfRI;~L@kvgd1!<~N +zG^u)@>UPb9kerEusLU3Ks(7txjpS1dpVXXepHY#uX0tt(X$v*os<;hBvde};(>>O= +zdymC~8kGz+TUI=jXQ4e9(jmK5*+{q6sB}-8>Ch7ioYsxGab`&J;7ijZcm~ph0aI~I +z5R;zYOxrmuo&>9j|1VP}X|$OmN!hr`N;5`Hp1Ap?(RA&&X)65x1(f-^xhyQ0)1w(= +zxdl8gomu7I0!t;ZJwKOzJrW(hzrdtQTD3?x@xW)&S1G|1oF}<2d&V +z0MXK5amo3CP0_59hg(n2Y;C8)fgU;wM8tvmlQcC0q52Vq>Rs&=oWH^-Tei +z`Kx(_XiAjJlFp9jyr&%H3jX8{)RMsY^aj)_T=pC2JFx&qUPN8uP;w5SB5^=Xub~m4 +z+4KhLS|s8Yp(#LbcB9|LJ!^jSSl{QUUPNX8RSQ>tdmiL-^Wu2knhm89Y%(qoTQV@9d>Y>^JvXM;@S`#FF%xv6}}Qi^R#~c?*uD +zJ1qDuQ4?c-;Zewy#rQ5y3tm<(;iJEM4=x*@sTt_(vb-*3Sw#J&~(LDy}@uZwgq +zmfARQznZR9_EoeIZ=!5!znGe4&ZHKV1x};-!_~d#i~n4@+jl$nbAEl! +z`JVF~ycmiPhdMsdUfdzOcWRvl`E@a~sXAur^)DGsQM1Wt4bGW_g2rMa*xFLRab2v% +z4C+mF(TzrtZWxwYK7Udx$q?Tswdvw&C6w7xo@n?(OBeV4qXlH-TW$Lchgw={pY8z3 +zM_N9^_k$hxW)@pmM$)|1Y*!jd$$GZb@9>kmx3UNBLz}7iY7Z+#o3zm0VVi9iG5#*A +z6uEI`h=%vrEa{E2t4OgdMFL2AtCxN3aYp^}5X&LMPd{SkIN5z8*#btAw~y^|k<^o9 +zfF3(}aFJp6Ma-+wv*gezc2Al!Z@1V!XQyP~UzV?l +z!W!Lsq!!#N2Rd8{i_x`uhTO9NW+}T91#rMa>X(;7HkBhRsj#~Y +zQsiJMjHtQ}Jp+L$3}2{%7*Jk$u^M`(@Zt^7H3giz1y(q~`4V4+r~}NC6FXr46fi7c +zkxztwb@{}lYDkyc_rgI{N#TBoXHX>r +ziHP^IxiXZG3FRX%6yWI;758v4M#$W?1n+1RLs(><6$O{kC$9Blnrth<{uyNRSUDD| +z3fn8NeI`YaJ`>y2?CoyG@6;VNwqZg|rhgkQQBxgx1HV?<@Y|S}_P?o$d$1)ysrve{ +zi&6X0ck$(Ip +zu1*Wu8&SO_YCRZ@lZ#@Vc&Achtpe)Lez!{FqCDmY6Nw>3mT0 +zQM8z8Y*?3T#)7(7*~w>$M;f_LxH9?Y#Ohoo|5*_@mc`wZS8zU?o9U!p9_A0LZEw%z +z5p^x{r}^CDCH0>re4Hl3CnrjIK2v0hp5UugdGRNCvD%d@PxA_LS-6}ZR>~VI_-)li +zOA1JQjvtuZk`oc$rxsOqmh+Xf$?@_le2C`FFORhIoM|f8_?x^nPZhpZ1FzgRz{}A7 +u&lW!p@=K}(wVRsnJ~JiB)J%E(6z`yWe|`NKZk-hCq*})%*Pn5(>G=<2b2Q8V + +diff --git a/configure.ac b/configure.ac +index 2e3a11f60c..0862b381ff 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -288,6 +288,14 @@ AC_CANONICAL_BUILD + AC_CANONICAL_HOST + AC_CANONICAL_TARGET + ++# Override cross_compiling and ac_tool_prefix variables since the C toolchain is ++# used to generate target code when building a cross compiler ++AS_IF([test x"$build" = x"$target"], ++ [cross_compiling=no], ++ [cross_compiling=yes]) ++AS_IF([test -n "$target_alias"], ++ [ac_tool_prefix=$target_alias-]) ++ + # Ensure that AC_CONFIG_LINKS will either create symlinks which are compatible + # with native Windows (i.e. NTFS symlinks, not WSL or Cygwin-emulated ones) or + # use its fallback mechanisms. Native Windows versions of ocamlc/ocamlopt cannot +@@ -594,12 +602,22 @@ AC_CHECK_TOOLS([LD],[ld link]) + # Also, it has been observed that, on some platforms (e.g. msvc) LT_INIT + # alters the CFLAGS variable, so we save its value before calling the macro + # and restore it after the call ++pushdef([host], target)dnl ++pushdef([host_alias], target_alias)dnl ++pushdef([host_cpu], target_cpu)dnl ++pushdef([host_vendor], target_vendor)dnl ++pushdef([host_os], target_os)dnl + old_host_os=$host_os + AS_IF([test x"$host_os" = "xwindows"],[host_os=mingw]) + saved_CFLAGS="$CFLAGS" + LT_INIT + CFLAGS="$saved_CFLAGS" + host_os=$old_host_os ++popdef([host_os])dnl ++popdef([host_vendor])dnl ++popdef([host_cpu])dnl ++popdef([host_alias])dnl ++popdef([host])dnl + + AS_CASE([$host], + [sparc-sun-solaris*], +-- +2.45.2 + diff --git a/patches/5.2.1/0004-Use-target-instead-of-host-when-relevant-in-configur.patch b/patches/5.2.1/0004-Use-target-instead-of-host-when-relevant-in-configur.patch new file mode 100644 index 0000000..4ab437d --- /dev/null +++ b/patches/5.2.1/0004-Use-target-instead-of-host-when-relevant-in-configur.patch @@ -0,0 +1,83 @@ +From 7acd97746d8c41a191d5de96b03c915a52bdc142 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Wed, 21 Feb 2024 19:05:44 +0100 +Subject: [PATCH 04/14] Use `target` instead of `host` when relevant in + configuration + +--- + configure | Bin 682949 -> 682314 bytes + configure.ac | 10 +++++----- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/configure b/configure +index f81f4ca213b710395b61b64d1380318d4d80867d..b393e6e2871a942e0171f1a52b70f75ef74f780a 100755 +GIT binary patch +delta 382 +zcmX?lUGvl>&4w+Esyn8O?`5>&ElDg&Pc4a0%*jkF)}0=(m(dngX#2w*j4@28V$(0M +zFi)HQa5v-Y=?MmGT+?stVdP~=$?_$tCeVF19K@F4I5U +zVH4S|wwG}+i@bsYNDL;+rJ#_SQ=AHlQVFkN& +zd+d3(9Zb`AtYPEdu5^hlt_dpK9K!A)Jbhvrvm8H)pK?;B8!l!t#SnCS!Z>65{|xr~ +zjHsTQ{82+<`h?qz72E5w*?AbJD}82^n9fto&NY2~4m&5t;^V@#oqI3i7MAJ%DwqU?d|Z?iY!xc3 +z6-qKv^SBg%VETPAHnr*ftC>otpS{Z3$pg{^)82mXAR`bn0WmWWvj8#c_In4}?0BaC +zv|{Jou6>Se9n1^xsX_NBR0pbmyQbR|u*QYK + +diff --git a/configure.ac b/configure.ac +index 0862b381ff..26de5bed24 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -597,7 +597,7 @@ AS_IF([test x"$enable_ocamldoc" = "xno"], + # Initialization of libtool + # Allow the MSVC linker to be found even if ld isn't installed. + # User-specified LD still takes precedence. +-AC_CHECK_TOOLS([LD],[ld link]) ++AC_CHECK_TARGET_TOOLS([LD],[ld link]) + # libtool expects host_os=mingw for native Windows + # Also, it has been observed that, on some platforms (e.g. msvc) LT_INIT + # alters the CFLAGS variable, so we save its value before calling the macro +@@ -1027,7 +1027,7 @@ AS_CASE([$flexdll_source_dir,$supports_shared_libraries,$flexlink,$host], + + mkexe_cmd_exp="$CC" + +-AS_CASE([$ocaml_cc_vendor,$host], ++AS_CASE([$ocaml_cc_vendor,$target], + [*,x86_64-*-darwin*], + [oc_ldflags='-Wl,-no_compact_unwind'; + AC_DEFINE([HAS_ARCH_CODE32], [1])], +@@ -1045,7 +1045,7 @@ AS_CASE([$ocaml_cc_vendor,$host], + ) + ostype="Cygwin"], + [*,*-*-mingw32*], +- [AS_CASE([$host], ++ [AS_CASE([$target], + [i686-*-*], [oc_dll_ldflags="-static-libgcc"]) + ostype="Win32" + toolchain="mingw" +@@ -1342,7 +1342,7 @@ system=unknown + # preserving $arch = 'none' <=> $system = 'unknown' + has_native_backend=no + native_ldflags="" +-AS_CASE([$host], ++AS_CASE([$target], + [[i[3456]86-*-linux*]], + [arch=i386; system=linux], + [[i[3456]86-*-freebsd*]], +@@ -1479,7 +1479,7 @@ AS_IF([$natdynlink], + + AC_DEFINE_UNQUOTED([OCAML_OS_TYPE], ["$ostype"]) + +-AC_CHECK_TOOL([DIRECT_LD],[ld]) ++AC_CHECK_TARGET_TOOL([DIRECT_LD],[ld]) + AS_IF([test -z "$PARTIALLD"], + [AS_CASE(["$host,$ocaml_cc_vendor"], + [x86_64-*-darwin*,gcc-*], [PACKLD_FLAGS=' -arch x86_64'], +-- +2.45.2 + diff --git a/patches/5.2.1/0005-Use-the-strip-command-detected-by-libtool.patch b/patches/5.2.1/0005-Use-the-strip-command-detected-by-libtool.patch new file mode 100644 index 0000000..a0e2cc9 --- /dev/null +++ b/patches/5.2.1/0005-Use-the-strip-command-detected-by-libtool.patch @@ -0,0 +1,42 @@ +From a67f2491770af3937b9cf5c548855dff678d99b5 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Fri, 5 Jul 2024 12:42:36 +0200 +Subject: [PATCH 05/14] Use the `strip` command detected by libtool + +Instead of using `strip` unconditionally to build `tmpheader.exe`, use +the `strip` command detected by `libtool` during configure so that it is +replaced with `:` when the command is absent and it becomes easy to +override it if need be +--- + Makefile.config.in | 1 + + stdlib/Makefile | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/Makefile.config.in b/Makefile.config.in +index 4243bebad9..b91634efb6 100644 +--- a/Makefile.config.in ++++ b/Makefile.config.in +@@ -185,6 +185,7 @@ OCAMLOPT_CFLAGS=@ocamlc_cflags@ + OCAMLOPT_CPPFLAGS=@ocamlc_cppflags@ + NATIVECCLIBS=@cclibs@ + SYSTHREAD_SUPPORT=@systhread_support@ ++STRIP=@STRIP@ + PACKLD=@PACKLD@$(EMPTY) + CCOMPTYPE=@ccomptype@ + TOOLCHAIN=@toolchain@ +diff --git a/stdlib/Makefile b/stdlib/Makefile +index 50f825a1b3..b6286920f2 100644 +--- a/stdlib/Makefile ++++ b/stdlib/Makefile +@@ -98,7 +98,7 @@ tmpheader.exe: $(HEADERPROGRAM).$(O) + $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^) + # FIXME This is wrong - mingw could invoke strip; MSVC equivalent? + ifneq "$(UNIX_OR_WIN32)" "win32" +- strip $@ ++ $(STRIP) $@ + endif + + stdlib.cma: $(OBJS) +-- +2.45.2 + diff --git a/patches/5.2.1/0006-Strip-tmpheader.exe-also-on-Windows.patch b/patches/5.2.1/0006-Strip-tmpheader.exe-also-on-Windows.patch new file mode 100644 index 0000000..5b6d595 --- /dev/null +++ b/patches/5.2.1/0006-Strip-tmpheader.exe-also-on-Windows.patch @@ -0,0 +1,32 @@ +From aefbbb813cdc27252153d2cf043900681c8689d8 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Fri, 5 Jul 2024 12:58:58 +0200 +Subject: [PATCH 06/14] Strip tmpheader.exe also on Windows + +GNU strip can be called safely on binaries generated by cl as well as by +MinGW GCC (even if it doesn't produce a smaller executable for +cl-generated binaries) so invoke strip also on Windows so that MinGW +binaries are properly stripped +Tested with GNU strip 2.42 +--- + stdlib/Makefile | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/stdlib/Makefile b/stdlib/Makefile +index b6286920f2..a7f2e60a7a 100644 +--- a/stdlib/Makefile ++++ b/stdlib/Makefile +@@ -96,10 +96,7 @@ endif + .INTERMEDIATE: tmpheader.exe + tmpheader.exe: $(HEADERPROGRAM).$(O) + $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^) +-# FIXME This is wrong - mingw could invoke strip; MSVC equivalent? +-ifneq "$(UNIX_OR_WIN32)" "win32" + $(STRIP) $@ +-endif + + stdlib.cma: $(OBJS) + $(V_LINKC)$(CAMLC) -a -o $@ $^ +-- +2.45.2 + diff --git a/patches/5.2.1/0007-Allow-ocaml-as-a-target-OS-to-configure-freestanding.patch b/patches/5.2.1/0007-Allow-ocaml-as-a-target-OS-to-configure-freestanding.patch new file mode 100644 index 0000000..0af801e --- /dev/null +++ b/patches/5.2.1/0007-Allow-ocaml-as-a-target-OS-to-configure-freestanding.patch @@ -0,0 +1,65 @@ +From 627cf134087f67001306b9480a51f6c5ea082758 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 26 Feb 2024 11:51:11 +0100 +Subject: [PATCH 07/14] Allow `ocaml` as a target OS to configure freestanding + cross-compilers + +Allow the use of *-*-ocaml or *-*-*-ocaml target triplets to stand for +freestanding cross-compilers by temporarily rewriting the target OS to +`none` when generating the canonical target + +This allows to use *-*-ocaml and *-*-*-ocaml prefixes for cross-compiler +specific toolchains, so that all the specific tools (for instance +aarch64-solo5-ocaml-gcc, etc.) are automatically discovered +--- + configure | Bin 682314 -> 682823 bytes + configure.ac | 17 +++++++++++++++++ + 2 files changed, 17 insertions(+) + +diff --git a/configure b/configure +index b393e6e2871a942e0171f1a52b70f75ef74f780a..498bc2042686e7fc202a6ecdfaa1ca6d2c780efc 100755 +GIT binary patch +delta 551 +zcmb7Au}T9$5G64hyAYqSwV3K0acut*y?#&dEm?A?al#Tc8Uibbka`3PGf +zpCDMKu(PuF8=Rb?7e!E(x6Hg5-n^N|dGPQQ4DU;Kqd^T0mC`*BI>uB9Kno5{LJrPa +z(9s4uhR8b1E@YNKtkbSkWZ=9Hj?%6+Xr$_cp`MYBJG>gWODae>4IMa;o{|61aQCv0LGEUD~e8z +zTTP$8oLnUJu%5@31`e*51@l62Dx261{k<^X;#0yeh(n|C<>7x0jx1mLPY!+`Kb@Rb +sH>dMqd4KjYD&17JzPbN#R&m=Nml$Qn3ZueUWvnr(jP+T2yz%<{2ER13{Qv*} + +delta 60 +zcmX?pP4mg9ZU +F7XS(}7}x*+ + +diff --git a/configure.ac b/configure.ac +index 26de5bed24..6f02258356 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -286,7 +286,24 @@ AC_CONFIG_COMMANDS_PRE(OCAML_QUOTED_STRING_ID) + + AC_CANONICAL_BUILD + AC_CANONICAL_HOST ++# Allow "ocaml" as target OS for freestanding compiler by temporarily rewriting ++# the target OS to "none" to generate the canonical target ++real_target_alias="$target_alias" ++AS_CASE([$target_alias], ++ [*-*-*-ocaml], ++ [ac_save_IFS=$IFS ++ IFS='-' ++ set x $target_alias ++ target_alias="$2-$3-none" ++ IFS=$ac_save_IFS], ++ [*-*-ocaml], ++ [ac_save_IFS=$IFS ++ IFS='-' ++ set x $target_alias ++ target_alias="$2-none" ++ IFS=$ac_save_IFS]) + AC_CANONICAL_TARGET ++target_alias="$real_target_alias" + + # Override cross_compiling and ac_tool_prefix variables since the C toolchain is + # used to generate target code when building a cross compiler +-- +2.45.2 + diff --git a/patches/5.2.1/0008-Define-OS-type-to-None.patch b/patches/5.2.1/0008-Define-OS-type-to-None.patch new file mode 100644 index 0000000..089f689 --- /dev/null +++ b/patches/5.2.1/0008-Define-OS-type-to-None.patch @@ -0,0 +1,38 @@ +From 8056ab2f13faa7a484dc1d985208a6066cebfc89 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 26 Feb 2024 12:06:45 +0100 +Subject: [PATCH 08/14] Define OS type to None + +--- + configure | Bin 682823 -> 682873 bytes + configure.ac | 4 +++- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 498bc2042686e7fc202a6ecdfaa1ca6d2c780efc..0eebc7063ceea9c5c392b02e68dce28144556545 100755 +GIT binary patch +delta 89 +zcmX?pP4nk9&4w1n7N!>F7M2#)Eo{-()pfLVwRH3H^HOWHz|7Q~G))C7E(IXSFD|Jp +lNVQe+1IkWsRN)k!zQC8At3CHR8xXStF~|1Y>zubH0{~+sAF2QV + +delta 44 +ycmex)P4oCQ&4w1n7N!>F7M2#)Eo{-(r@y(&F3>*rIvWtP12M<;xz{=GOa=hQ!xZiS + +diff --git a/configure.ac b/configure.ac +index 6f02258356..5523a1013c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1090,7 +1090,9 @@ AS_CASE([$ocaml_cc_vendor,$target], + [oc_ldflags='-brtl -bexpfull' + AC_DEFINE([HAS_ARCH_CODE32], [1])], + [gcc-*,powerpc-*-linux*], +- [oc_ldflags="-mbss-plt"]) ++ [oc_ldflags="-mbss-plt"], ++ [*,*-*-none|*,*-*-elf], ++ [ostype="None"]) + + ## Program to use to install files + AC_PROG_INSTALL +-- +2.45.2 + diff --git a/patches/5.2.1/0009-Add-freestanding-targets-to-supported-configurations.patch b/patches/5.2.1/0009-Add-freestanding-targets-to-supported-configurations.patch new file mode 100644 index 0000000..8c24fcb --- /dev/null +++ b/patches/5.2.1/0009-Add-freestanding-targets-to-supported-configurations.patch @@ -0,0 +1,40 @@ +From cbcf96dca5420b9a2665b0064c5ba2b37b7ecaa6 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 26 Feb 2024 19:35:26 +0100 +Subject: [PATCH 09/14] Add freestanding targets to supported configurations + +--- + configure | Bin 682873 -> 683028 bytes + configure.ac | 6 +++++- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/configure b/configure +index 0eebc7063ceea9c5c392b02e68dce28144556545..d95fd568597e59d6f9e92aacadc9f50840dcee16 100755 +GIT binary patch +delta 99 +zcmex)O>@c(&4w1n7N!>F7M2#)7Pc+yfyvYRBiK2opN(bbWXa3VOPzi;f!$ad#8R-f +sR#4X9Qcy@tEK1HWGtt%31uNK_$ZiZ)+8&t94#XTl%(*=F7M2#)7Pc+yfyvW13UCOw|4(KIVh$kY-2OkAOOyiuw<;1a + +diff --git a/configure.ac b/configure.ac +index 5523a1013c..3b2de0b053 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1458,7 +1458,11 @@ AS_CASE([$target], + [x86_64-*-cygwin*], + [has_native_backend=yes; arch=amd64; system=cygwin], + [riscv64-*-linux*], +- [has_native_backend=yes; arch=riscv; model=riscv64; system=linux] ++ [has_native_backend=yes; arch=riscv; model=riscv64; system=linux], ++ [x86_64-*-none], ++ [has_native_backend=yes; arch=amd64; system=none], ++ [aarch64-*-none], ++ [has_native_backend=yes; arch=arm64; system=none] + ) + + AS_CASE([$arch], +-- +2.45.2 + diff --git a/patches/5.2.1/0010-Check-that-the-configured-and-the-installed-OCaml-ar.patch b/patches/5.2.1/0010-Check-that-the-configured-and-the-installed-OCaml-ar.patch new file mode 100644 index 0000000..87b0c45 --- /dev/null +++ b/patches/5.2.1/0010-Check-that-the-configured-and-the-installed-OCaml-ar.patch @@ -0,0 +1,46 @@ +From 156caacd6b9b4d3d83adf02ffd0c68f11a0ff5a7 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Tue, 19 Mar 2024 19:14:29 +0100 +Subject: [PATCH 10/14] Check that the configured and the installed OCaml are + compatible + +--- + configure | Bin 683028 -> 683595 bytes + configure.ac | 7 +++++++ + 2 files changed, 7 insertions(+) + +diff --git a/configure b/configure +index d95fd568597e59d6f9e92aacadc9f50840dcee16..58c25a0c685bf6860c63c9c394d191f9281bd1b3 100755 +GIT binary patch +delta 436 +zcmbPoL-X_<&4w1n7N!>F7M2#)Eo{FyO_deGQx%F*3rjPLQWX*v^78X^lZ*0;i*=Lp +za|<$aQi~Mw(-cZFQWc65b5j+{Qj3Z+^Yf-}+{1384HAV4z!YWX6_+ID9)8%)`*8P*$vF7M2#)Eo{Fyr$_j)>$S)8umLeU5OV-A=k|CWt~ZGQuvrin + +diff --git a/configure.ac b/configure.ac +index 3b2de0b053..c5b2a3f217 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -825,6 +825,13 @@ AS_IF( + CPPFLAGS_FOR_BUILD='$(CPPFLAGS)' + LDFLAGS_FOR_BUILD='$(LDFLAGS)'], + [cross_compiler=true ++ # We require a non-cross-compiler of the same version ++ AC_MSG_CHECKING([the version of the installed OCaml compiler]) ++ already_installed_version=`ocamlc -vnum` ++ AS_IF([test x"AC_PACKAGE_VERSION" = x"$already_installed_version"], ++ [AC_MSG_RESULT([compatible (AC_PACKAGE_VERSION)])], ++ [AC_MSG_ERROR(m4_normalize([incompatible (AC_PACKAGE_VERSION vs ++ $already_installed_version)]))]) + AC_MSG_NOTICE([detecting the C toolchain for build]) + AX_PROG_CC_FOR_BUILD]) + +-- +2.45.2 + diff --git a/patches/5.2.1/0011-Use-the-target-pkg-config-to-detect-zstd.patch b/patches/5.2.1/0011-Use-the-target-pkg-config-to-detect-zstd.patch new file mode 100644 index 0000000..f4d0a0e --- /dev/null +++ b/patches/5.2.1/0011-Use-the-target-pkg-config-to-detect-zstd.patch @@ -0,0 +1,44 @@ +From 40f00c44630bae376edf63dc5f76150b3a8065af Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Wed, 20 Mar 2024 17:41:26 +0100 +Subject: [PATCH 11/14] Use the target pkg-config to detect zstd + +Make sure that we don't detect zstd on build when we are building a +cross-compiler, as the native zstd has no reason to be compatible with +the cross toolchain +--- + configure | Bin 683595 -> 683354 bytes + configure.ac | 2 +- + 2 files changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure b/configure +index 58c25a0c685bf6860c63c9c394d191f9281bd1b3..e364c57560a234055311de9b09ff0f399fd0f44a 100755 +GIT binary patch +delta 151 +zcmV;I0BHZq+$q}HDS(6lgaU*Egam{Iga(8MvRQ2tN&UVRC0>bYEd? +zX<>6Mx88CHV+59$0ST8ba0d&QSa%2*m(sogDwlJ22ppG`a0ef^tak{b1DEr^2oaZv +zcnA~)A|NIvAeVu72pb4JB4%N1b7dm8OnV4E0hi=`2q6SzY;$FouzUy_hXsBJw*`I) +FM({SFH0=NY + +delta 171 +zcmcb0OY`&{&4w1n7N!>F7M2#)7Pc1lEgUvQ)4#lA3T7_IPM_Ylo5Ongft!qiVBUq@ +z9J8lOlyUHFk1yuf&OAL}1(W!6t#S^D>6zsm^3z4WFv@OUUe2+YdHSzX4({zst2qo9 +zr~BKp@ktbv#0Pl0$2g?s_5lEp)jm4_ + +diff --git a/configure.ac b/configure.ac +index c5b2a3f217..14d0356368 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2261,7 +2261,7 @@ AC_CHECK_HEADER([spawn.h], + [AC_CHECK_FUNC([posix_spawn], + [AC_CHECK_FUNC([posix_spawnp], [AC_DEFINE([HAS_POSIX_SPAWN])])])]) + +-AC_PATH_TOOL([PKG_CONFIG], [pkg-config], [false]) ++AC_PATH_TARGET_TOOL([PKG_CONFIG], [pkg-config], [false]) + + ## ZSTD compression library + +-- +2.45.2 + diff --git a/patches/5.2.1/0012-WIP-Add-a-Makefile.cross-for-recipes-to-build-a-cros.patch b/patches/5.2.1/0012-WIP-Add-a-Makefile.cross-for-recipes-to-build-a-cros.patch new file mode 100644 index 0000000..44c0458 --- /dev/null +++ b/patches/5.2.1/0012-WIP-Add-a-Makefile.cross-for-recipes-to-build-a-cros.patch @@ -0,0 +1,122 @@ +From 4ab2e100f97da1a4251137dfaf473af705f0274f Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Fri, 23 Feb 2024 16:56:07 +0100 +Subject: [PATCH 12/14] WIP Add a Makefile.cross for recipes to build a + cross-compiler + +Define cross.opt and cross-install targets + +FIXME: Problems of inconsistencies between compilation options (only +about zstd?) between the native toolchain and the cross toolchain may +break the build? +--- + Makefile | 2 ++ + Makefile.cross | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 85 insertions(+) + create mode 100644 Makefile.cross + +diff --git a/Makefile b/Makefile +index df191af79c..cb6b3f4484 100644 +--- a/Makefile ++++ b/Makefile +@@ -2732,6 +2732,8 @@ endif + + include .depend + ++include Makefile.cross ++ + Makefile.config Makefile.build_config: config.status + config.status: + @echo "Please refer to the installation instructions:" +diff --git a/Makefile.cross b/Makefile.cross +new file mode 100644 +index 0000000000..b993783d2f +--- /dev/null ++++ b/Makefile.cross +@@ -0,0 +1,83 @@ ++#************************************************************************** ++#* * ++#* OCaml * ++#* * ++#* Samuel Hym, Tarides * ++#* * ++#* Copyright 2024 Tarides * ++#* * ++#* All rights reserved. This file is distributed under the terms of * ++#* the GNU Lesser General Public License version 2.1, with the * ++#* special exception on linking described in the file LICENSE. * ++#* * ++#************************************************************************** ++ ++# Recipes to build a cross-compiler (_not_ cross-compiling the compiler), aka ++# generating code that will run on `target`, assuming that a non-cross OCaml ++# compiler (so targetting our build machine) of the same version is available in ++# $PATH ++ ++# We assume no zstd for the cross-compiler (ie no requirement on zstd for the ++# target) ++# Still the cross-compiler will run on host, not target. And as a consequence of ++# the rules linking it, the cross-compilers will be linked with the _build_ ++# version of libcomprmarsh, so we still must discover the flags to link with ++# libzstd if it was set up in the non-cross compiler, so we rely on the ++# pkg-config command to get the linking flags for zstd ++PKG_CONFIG := pkg-config ++# This is used only once, so it doesn't have to be much lazier ++NATIVE_ZSTD_LIBS=ZSTD_LIBS="$(shell $(PKG_CONFIG) --libs libzstd)" ++# As the libcomprmarsh built by the C cross compiler will not be linked in, we ++# can build an empty one ++NO_ZSTD=libcomprmarsh_OBJECTS= ++ ++CROSS_OVERRIDES=OCAMLRUN=ocamlrun NEW_OCAMLRUN=ocamlrun \ ++ BOOT_OCAMLLEX=ocamllex OCAMLYACC=ocamlyacc ++CROSS_COMPILER_OVERRIDES=$(CROSS_OVERRIDES) CAMLC=ocamlc CAMLOPT=ocamlopt \ ++ BEST_OCAMLC=ocamlc BEST_OCAMLOPT=ocamlopt BEST_OCAMLLEX=ocamllex ++ ++INSTALL_OVERRIDES=build_ocamldoc=false WITH_DEBUGGER= ++ ++# Freestanding target custom options ++ifeq "$(SYSTEM)" "none" ++RUNTIME_BUILD_OVERRIDES=runtime_PROGRAMS= ++INSTALL_OVERRIDES += runtime_PROGRAMS=`which ocamlrun` \ ++ runtime_BYTECODE_STATIC_LIBRARIES=runtime/ld.conf ++else ++RUNTIME_BUILD_OVERRIDES= ++endif ++ ++cross.opt: ++ $(MAKE) runtime-all $(NO_ZSTD) $(RUNTIME_BUILD_OVERRIDES) ++ $(MAKE) ocamlc ocamlopt $(TOOLS_BYTECODE_TARGETS) expunge \ ++ $(CROSS_COMPILER_OVERRIDES) ++ $(MAKE) library $(CROSS_OVERRIDES) ++ifneq "$(SYSTEM)" "none" ++ $(MAKE) ocamlyacc $(CROSS_OVERRIDES) ++ $(MAKE) ocamllex $(CROSS_COMPILER_OVERRIDES) ++endif ++ $(MAKE) ocaml $(CROSS_COMPILER_OVERRIDES) ++ $(MAKE) -C otherlibs all $(CROSS_OVERRIDES) ++ # Opt ++ $(MAKE) runtimeopt $(NO_ZSTD) ++ $(MAKE) ocamlc.opt ocamlopt.opt $(TOOLS_NATIVE_TARGETS) \ ++ $(NO_ZSTD) $(CROSS_COMPILER_OVERRIDES) $(NATIVE_ZSTD_LIBS) ++ $(MAKE) libraryopt $(NO_ZSTD) $(CROSS_OVERRIDES) ++ $(MAKE) otherlibrariesopt ocamltoolsopt $(NO_ZSTD) $(CROSS_OVERRIDES) ++ $(MAKE) tools-allopt.opt $(NO_ZSTD) $(CROSS_COMPILER_OVERRIDES) ++ ++.PHONY: cross-install ++cross-install: ++ # dummy files ++ touch \ ++ $(addprefix toplevel/, \ ++ $(foreach ext,cmi cmt cmti cmx, native/nat__dummy__.$(ext)) \ ++ all__dummy__.cmx topstart.o native/tophooks.cmi) ++ $(LN) `which ocamlyacc` yacc/ocamlyacc.opt$(EXE) ++ $(LN) `which ocamllex` lex/ocamllex.opt$(EXE) ++ifeq "$(SYSTEM)" "none" ++ $(LN) `which ocamlyacc` yacc/ocamlyacc$(EXE) ++ $(LN) `which ocamllex` lex/ocamllex$(EXE) ++endif ++ # Real installation ++ $(MAKE) install $(INSTALL_OVERRIDES) OCAMLRUN=ocamlrun +-- +2.45.2 + diff --git a/patches/5.2.1/0013-Set-Max_domains-to-1.patch b/patches/5.2.1/0013-Set-Max_domains-to-1.patch new file mode 100644 index 0000000..2eb5515 --- /dev/null +++ b/patches/5.2.1/0013-Set-Max_domains-to-1.patch @@ -0,0 +1,35 @@ +From bde7866513c8deeddd9165d05502162229abd13a Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Fri, 12 Apr 2024 19:21:52 +0200 +Subject: [PATCH 13/14] Set Max_domains to 1 + +Solo5 is single-core with no scheduler, so avoid the useless memory +waste + +Note that since PR#13272 the maximum number of domains can set using a +parameter in OCAMLRUNPARAM so `getenv` might be a better place to set +this limit in the future +--- + runtime/caml/domain.h | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/runtime/caml/domain.h b/runtime/caml/domain.h +index 4b9be80b41..986486478c 100644 +--- a/runtime/caml/domain.h ++++ b/runtime/caml/domain.h +@@ -31,11 +31,7 @@ extern "C" { + + /* The runtime currently has a hard limit on the number of domains. + This hard limit may go away in the future. */ +-#ifdef ARCH_SIXTYFOUR +-#define Max_domains 128 +-#else +-#define Max_domains 16 +-#endif ++#define Max_domains 1 + + /* is the minor heap full or an external interrupt has been triggered */ + Caml_inline int caml_check_gc_interrupt(caml_domain_state * dom_st) +-- +2.45.2 + diff --git a/patches/5.2.1/0014-Set-stack-as-non-executable-on-freestanding-targets.patch b/patches/5.2.1/0014-Set-stack-as-non-executable-on-freestanding-targets.patch new file mode 100644 index 0000000..d0e29b0 --- /dev/null +++ b/patches/5.2.1/0014-Set-stack-as-non-executable-on-freestanding-targets.patch @@ -0,0 +1,53 @@ +From d6d0345ba0d079ffc17c397ae1773e50ecc470b1 Mon Sep 17 00:00:00 2001 +From: Samuel Hym +Date: Mon, 29 Apr 2024 18:21:24 +0200 +Subject: [PATCH 14/14] Set stack as non-executable on freestanding targets + +--- + asmcomp/amd64/emit.mlp | 2 +- + asmcomp/arm64/emit.mlp | 2 +- + runtime/amd64.S | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp +index 619ce9c3c5..19f896c1ac 100644 +--- a/asmcomp/amd64/emit.mlp ++++ b/asmcomp/amd64/emit.mlp +@@ -1079,7 +1079,7 @@ let end_assembly() = + D.size frametable (ConstSub (ConstThis, ConstLabel frametable)) + end; + +- if system = S_linux then ++ if system = S_linux || system = S_unknown then + (* Mark stack as non-executable, PR#4564 *) + D.section [".note.GNU-stack"] (Some "") [ "%progbits" ]; + +diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp +index 1816f8c345..41769e4f93 100644 +--- a/asmcomp/arm64/emit.mlp ++++ b/asmcomp/arm64/emit.mlp +@@ -1217,7 +1217,7 @@ let end_assembly () = + emit_symbol_type emit_symbol lbl "object"; + emit_symbol_size lbl; + begin match Config.system with +- | "linux" -> ++ | "linux" | "none" -> + (* Mark stack as non-executable *) + ` .section .note.GNU-stack,\"\",%progbits\n` + | _ -> () +diff --git a/runtime/amd64.S b/runtime/amd64.S +index 49c712b167..be0856a72b 100644 +--- a/runtime/amd64.S ++++ b/runtime/amd64.S +@@ -1386,7 +1386,7 @@ G(caml_negf_mask): + G(caml_absf_mask): + .quad 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF + +-#if defined(SYS_linux) ++#if defined(SYS_linux) || defined(SYS_none) + /* Mark stack as non-executable, PR#4564 */ + .section .note.GNU-stack,"",%progbits + #endif +-- +2.45.2 + diff --git a/test/test.c b/test/test.c index 7717a15..8ab1365 100644 --- a/test/test.c +++ b/test/test.c @@ -1,6 +1,6 @@ #include int main(int ac, const char *av[]) { - gilbraltar_log(INFO, "Hello World!\r\n"); + gilbraltar_log(INFO, "Hello Tazi!\r\n"); return (0); } diff --git a/toolchain/ar.in b/toolchain/ar.in new file mode 100644 index 0000000..1795c99 --- /dev/null +++ b/toolchain/ar.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec @@CONFIG_TARGET_AR@@ "$@" diff --git a/toolchain/as.in b/toolchain/as.in new file mode 100644 index 0000000..3e4eb88 --- /dev/null +++ b/toolchain/as.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec @@CONFIG_TARGET_CC@@ -c "$@" diff --git a/toolchain/cc.in b/toolchain/cc.in new file mode 100644 index 0000000..8f502a8 --- /dev/null +++ b/toolchain/cc.in @@ -0,0 +1,130 @@ +#!/bin/sh +# Copyright (c) 2015-2021 Solo5 Contributors +# Copyright (c) 2024 Romain Calascibetta +# +# This file is part of Gilbraltar, a bare-metal OS for RaspBerry Pi 5. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +# @@CONFIG_TARGET_TRIPLE@@-cc: Gilbraltar wrapper for 'cc'. +# Generated by configure.sh at build time. +# +# Passes through to @@CONFIG_TARGET_CC@ for actual work. Defines all flags +# required for correct operation when building C code intended for inclusion in +# a Gilbraltar operating system. +# +# Provides a '-z gilbraltar-abi=ABI' option to select the Gilbraltar bindings to +# use if linking. ABI defaults to 'stub' to accomodate non-Gilbraltar-aware +# build systems, such as GNU autoconf, which use 'cc'-as-linker to test for the +# presence of symbols. + +prog="$(basename $0)" +I="$(dirname $0)/../include" +[ ! -d "${I}" ] && echo "$prog: Could not determine include path" 1>&2 && exit 1 +L="$(dirname $0)/../lib/@@CONFIG_TARGET_TRIPLE@@" +[ ! -d "${L}" ] && echo "$prog: Could not determine library path" 1>&2 && exit 1 +# we can't really tell if 'cc' is called with no input, but work around the +# most obvious cases and stop them from "succeeding" and producing an "a.out" +[ "$#" -lt 1 ] && \ + echo "$prog: No input files. Compilation terminated." 1>&1 && exit 1 +[ "$#" -eq 1 -a "$1" = "-v" ] && exec @@CONFIG_TARGET_CC@@ "$@" +# default to cc as linker, unless we see args to the contrary +M=link +# cc as linker with no -z gilbraltar-abi= defaults to stub +B=stub +Z= +for arg do + shift + if [ -n "${Z}" ]; then + # handle -z linker-arg + Z= + case "$arg" in + gilbraltar-abi=*) + B="${arg##*=}" + continue + ;; + *) + set -- "$@" "-z" "$arg" + continue + ;; + esac + fi + + case "$arg" in + -c|-S|-E) + M=compile + ;; + -z) + if [ -z "${Z}" ]; then + Z=1 + continue + fi + ;; + esac + set -- "$@" "$arg" +done +case ${M} in + compile) + [ -n "${__V}" ] && set -x + echo exec @@CONFIG_TARGET_CC@@ \ + @@CONFIG_TARGET_CC_CFLAGS@@ \ + -isystem ${I}/@@CONFIG_TARGET_TRIPLE@@ \ + -I ${I} \ + -D__BSD_VISIBLE=0 \ + -D__XSI_VISIBLE=0 \ + -std=c11 \ + -ffreestanding \ + -fstack-protector-strong \ + -nostdlib \ + -nostartfiles \ + -mstrict-align \ + -Wall \ + -DAARCH=64 \ + -mcpu=cortex-a76 \ + "$@" ; + exec @@CONFIG_TARGET_CC@@ \ + @@CONFIG_TARGET_CC_CFLAGS@@ \ + -isystem ${I}/@@CONFIG_TARGET_TRIPLE@@ \ + -I ${I} \ + -D__BSD_VISIBLE=0 \ + -D__XSI_VISIBLE=0 \ + -std=c11 \ + -ffreestanding \ + -fstack-protector-strong \ + -nostdlib \ + -nostartfiles \ + -mstrict-align \ + -Wall \ + -DAARCH=64 \ + -mcpu=cortex-a76 \ + "$@" + ;; + link) + [ -n "${B}" ] && B="-Wl,-T,gilbraltar.${B}.ld -lgilbraltar.${B}" + [ -n "${__V}" ] && set -x + exec @@CONFIG_TARGET_CC@@ \ + @@CONFIG_TARGET_CC_CFLAGS@@ \ + -isystem ${I}/@@CONFIG_TARGET_TRIPLE@@ \ + -I ${I} \ + -ffreestanding \ + -fstack-protector-strong \ + @@CONFIG_TARGET_CC_LDFLAGS@@ \ + -nostdlib \ + -L ${L} \ + ${B} \ + -static \ + "$@" + ;; +esac diff --git a/toolchain/gcc.in b/toolchain/gcc.in new file mode 120000 index 0000000..0895a9f --- /dev/null +++ b/toolchain/gcc.in @@ -0,0 +1 @@ +cc.in \ No newline at end of file diff --git a/toolchain/ld.in b/toolchain/ld.in new file mode 100644 index 0000000..38936de --- /dev/null +++ b/toolchain/ld.in @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright (c) 2015-2021 Solo5 Contributors +# Copyright (c) 2024 Romain Calascibetta +# +# This file is part of Gilbraltar, a bare-metal OS for RaspBerry Pi 5. +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +# @@CONFIG_TARGET_TRIPLE@@-ld: Gilbraltar wrapper for 'ld'. +# Generated by configure.sh at build time. +# +# Passes through to @@CONFIG_TARGET_LD@ for actual work. Defines all flags +# required for correct operation when linking code intended for inclusion in a +# Gilbraltar operating system. +# +# Provides a '-z gilbraltar-abi=ABI' option to select the RPi4 bindings to use +# if linking. No default for ABI is provided, as it is expected that a caller +# directly using 'ld' knows what they are doing. + +L="$(dirname $0)/../lib/@@CONFIG_TARGET_TRIPLE@@" +[ ! -d "${L}" ] && echo "$0: Could not determine library path" 1>&2 && exit 1 +# ld accepts -z gilbraltar-abi=ABI, but does not provide a default ABI +# this is intentional +B= +Z= +for arg do + shift + if [ -n "${Z}" ]; then + # handle -z linker-arg + Z= + case "$arg" in + gilbraltar-abi=*) + B="${arg##*=}" + continue + ;; + *) + set -- "$@" "-z" "$arg" + continue + ;; + esac + fi + + case "$arg" in + -z) + if [ -z "${Z}" ]; then + Z=1 + continue + fi + ;; + esac + set -- "$@" "$arg" +done +[ -n "${B}" ] && B="-T $gilbraltar.{B}.ld -lgilbraltar.${B}" +[ -n "${__V}" ] && set -x +exec @@CONFIG_TARGET_LD@@ \ + @@CONFIG_TARGET_LD_LDFLAGS@@ \ + -nostdlib \ + -L ${L} \ + -static \ + ${B} \ + "$@" diff --git a/toolchain/nm.in b/toolchain/nm.in new file mode 100644 index 0000000..0a0e59f --- /dev/null +++ b/toolchain/nm.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec @@CONFIG_TARGET_NM@@ "$@" diff --git a/toolchain/objcopy.in b/toolchain/objcopy.in new file mode 100644 index 0000000..5b4f3c3 --- /dev/null +++ b/toolchain/objcopy.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec @@CONFIG_TARGET_OBJCOPY@@ "$@" diff --git a/toolchain/objdump.in b/toolchain/objdump.in new file mode 100644 index 0000000..40769e8 --- /dev/null +++ b/toolchain/objdump.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec @@CONFIG_TARGET_OBJDUMP@@ "$@" diff --git a/toolchain/ranlib.in b/toolchain/ranlib.in new file mode 100644 index 0000000..90db357 --- /dev/null +++ b/toolchain/ranlib.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec @@CONFIG_TARGET_RANLIB@@ "$@" diff --git a/toolchain/readelf.in b/toolchain/readelf.in new file mode 100644 index 0000000..b236a16 --- /dev/null +++ b/toolchain/readelf.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec @@CONFIG_TARGET_READELF@@ "$@" diff --git a/toolchain/strip.in b/toolchain/strip.in new file mode 100644 index 0000000..dad08a4 --- /dev/null +++ b/toolchain/strip.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec @@CONFIG_TARGET_STRIP@@ "$@"