summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2022-06-02 19:17:43 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2022-11-02 18:46:05 +0000
commit7478ef25dfcfcb94ce4739624d6eec9751cc2507 (patch)
treeca231e48b6d4f299b1893ec69f770412f34cd80d
parent1fa07c6d22505158ecd341ab57b892284f0f2549 (diff)
downloadtoolchains-7478ef25dfcfcb94ce4739624d6eec9751cc2507.tar.gz
toolchains-7478ef25dfcfcb94ce4739624d6eec9751cc2507.tar.bz2
Teach OSLib about EABI
This introduces a new asmtype to defmod which invokes the correct GCC for the task. It may be necessary to perform further surgery to defmod's assembler generation to address places where the EABI calling conventions don't match APCS-32 (note that there is no floating point involved here, so that's one headache avoided). Update the OSLib build system to allow building for an EABI target.
-rw-r--r--arm-riscos-gnueabihf/Makefile2
-rw-r--r--arm-riscos-gnueabihf/recipes/patches/oslib/buildsystem-elfeabi.p144
-rw-r--r--arm-riscos-gnueabihf/recipes/patches/oslib/defmod-elfeabi.p84
3 files changed, 229 insertions, 1 deletions
diff --git a/arm-riscos-gnueabihf/Makefile b/arm-riscos-gnueabihf/Makefile
index 1a9b4a2..6c53c9b 100644
--- a/arm-riscos-gnueabihf/Makefile
+++ b/arm-riscos-gnueabihf/Makefile
@@ -115,7 +115,7 @@ $(BUILDSTEPS)/ccres.d: $(BUILDSTEPS)/oslib.d $(SOURCESDIR)/$(UPSTREAM_CCRES_TARB
$(BUILDSTEPS)/oslib.d: $(BUILDSTEPS)/gcc.d $(SOURCESDIR)/$(UPSTREAM_OSLIB_TARBALL)
tar -C $(BUILDDIR) -xaf $(SOURCESDIR)/$(UPSTREAM_OSLIB_TARBALL)
for p in `ls $(RECIPES)/patches/oslib/*.p` ; do patch -d $(BUILDDIR)/oslib -p0 <$$p ; done
- cd $(BUILDDIR)/oslib && GCCSDK_INSTALL_ENV=$(PREFIX)/env GCCSDK_INSTALL_CROSSBIN=$(PREFIX)/cross/bin make install
+ cd $(BUILDDIR)/oslib && GCCSDK_INSTALL_ENV=$(PREFIX)/env GCCSDK_INSTALL_CROSSBIN=$(PREFIX)/cross/bin make install-elfeabi
touch $@
###
diff --git a/arm-riscos-gnueabihf/recipes/patches/oslib/buildsystem-elfeabi.p b/arm-riscos-gnueabihf/recipes/patches/oslib/buildsystem-elfeabi.p
new file mode 100644
index 0000000..a729f9e
--- /dev/null
+++ b/arm-riscos-gnueabihf/recipes/patches/oslib/buildsystem-elfeabi.p
@@ -0,0 +1,144 @@
+Index: Source/Makefile
+===================================================================
+--- Source/Makefile (revision 477)
++++ Source/Makefile (working copy)
+@@ -3,8 +3,8 @@
+ # already be built upfront.
+ # Written by OSLib Development Team.
+
+-# Build type: CROSSGCC_AOF, CROSSGCC_ELF (default), [NORCROFT_AOF: not
+-# supported yet]
++# Build type: CROSSGCC_AOF, CROSSGCC_ELF (default), CROSSGCC_ELFEABI,
++# [NORCROFT_AOF: not supported yet]
+ export BUILDTYPE ?= CROSSGCC_ELF
+ # Possible values: "SOFTFPU" (e.g. for UnixLib usage), "HARDFPU" (e.g. for
+ # SharedCLibrary usage) and "MODULE" (latter also meaning HARDFPU but the
+@@ -12,9 +12,10 @@
+ export ELFOBJECTTYPE ?= SOFTFPU
+
+ ifeq ($(BUILDTYPE),CROSSGCC_ELF)
++else ifeq ($(BUILDTYPE),CROSSGCC_ELFEABI)
+ else ifeq ($(BUILDTYPE),CROSSGCC_AOF)
+ else
+-$(error Unknown BUILDTYPE value, possible values are CROSSGCC_AOF and CROSSGCC_ELF)
++$(error Unknown BUILDTYPE value, possible values are CROSSGCC_AOF, CROSSGCC_ELF, and CROSSGCC_ELFEABI)
+ endif
+ include Makefile.setup.$(BUILDTYPE)
+
+Index: Source/Makefile.inc
+===================================================================
+--- Source/Makefile.inc (revision 477)
++++ Source/Makefile.inc (working copy)
+@@ -65,6 +65,9 @@
+ ifeq ($(BUILDTYPE),CROSSGCC_ELF)
+ .ELFHdr.Hdr:
+ if [ -s "$<" ]; then $(CP) $< $@; fi
++else ifeq ($(BUILDTYPE),CROSSGCC_ELFEABI)
++.ELFHdr.Hdr:
++ if [ -s "$<" ]; then $(CP) $< $@; fi
+ else
+ .AOFHdr.Hdr:
+ if [ -s "$<" ]; then $(CP) $< $@; fi
+@@ -98,6 +101,9 @@
+ ifeq ($(BUILDTYPE),CROSSGCC_ELF)
+ .gas.o:
+ $(AS) -o $@ $<
++else ifeq ($(BUILDTYPE),CROSSGCC_ELFEABI)
++.gas.o:
++ $(AS) -o $@ $<
+ else
+ .asm.o:
+ $(AS) -o $@ $<
+Index: Source/Makefile.setup.CROSSGCC_ELFEABI
+===================================================================
+--- Source/Makefile.setup.CROSSGCC_ELFEABI (nonexistent)
++++ Source/Makefile.setup.CROSSGCC_ELFEABI (working copy)
+@@ -0,0 +1,62 @@
++# Settings for ELF building
++
++ifndef GCCSDK_INSTALL_CROSSBIN
++$(error Environment variable GCCSDK_INSTALL_CROSSBIN is not defined)
++endif
++ifndef GCCSDK_INSTALL_ENV
++$(error Environment variable GCCSDK_INSTALL_ENV is not defined)
++endif
++
++ifeq ($(ELFOBJECTTYPE),SOFTFPU)
++CCFLAGS = -mfloat-abi=soft
++DEFMODFLAGS = -float-abi soft
++else ifeq ($(ELFOBJECTTYPE),HARDFPU)
++CCFLAGS = -mlibscl
++DEFMODFLAGS = -float-abi hard
++else ifeq ($(ELFOBJECTTYPE),MODULE)
++CCFLAGS = -mmodule
++DEFMODFLAGS = -float-abi hard
++else
++$(error Unknown ELFOBJECTTYPE value, possible values are SOFTFPU, HARDFPU and MODULE)
++endif
++
++export SOURCEDIR := $(abspath .)
++export BINDIR := $(SOURCEDIR)/../Bin
++export BUILDDIR := $(SOURCEDIR)/../Build
++export RELEASEDIR := $(SOURCEDIR)/../Release
++export RELEASEBINDIR := $(SOURCEDIR)/../Release/$(BUILDTYPE)/$(ELFOBJECTTYPE)
++export EXAMPLESDIR := $(SOURCEDIR)/../examples
++export DOCSDIR := $(SOURCEDIR)/../docs
++
++export TOPHEADERDIR := $(BUILDDIR)/Header
++export HEADERDIR := $(TOPHEADERDIR)/oslib
++export CSTRONGDIR := $(BUILDDIR)/CStrong
++export VAPIDIR := $(BUILDDIR)/\!Vala/vapi
++export VAPIHDIR := $(BUILDDIR)/vapih
++export OBJDIR := $(BUILDDIR)/Objs
++export OBJEXCEPTDIR := $(BUILDDIR)/Objs/Exceptions
++export OSLIBSUPPORTDIR := $(BUILDDIR)/OSLibSupport
++
++export BYTEWIDE := $(SOURCEDIR)/ByteWide
++export DEFMOD := $(BINDIR)/defmod -asmtype gccelfeabi $(DEFMODFLAGS)
++export REDUCEAOF := @echo Not needed for ELF build: reduceaof
++export BINDHELP := $(BINDIR)/bindhelp
++
++export PATH := $(GCCSDK_INSTALL_CROSSBIN):$(PATH)
++
++export CC := arm-riscos-gnueabihf-gcc $(CCFLAGS)
++export CXX := arm-riscos-gnueabihf-g++ $(CCFLAGS)
++export AS := arm-riscos-gnueabihf-gcc -c -xassembler-with-cpp $(CCFLAGS) -I.. -I$(SOURCEDIR)/Types
++export LIBFILE := arm-riscos-gnueabihf-ar rs
++export MKDIR := mkdir -p
++export RM := rm -rf
++export CP := cp -r
++export INSTALL := $(GCCSDK_INSTALL_ENV)/ro-install
++
++export ASMEXT := .gas
++export EXEEXT := ,e1f
++export LIBSUFFIX := a
++
++export OSLIBLIB := $(BUILDDIR)/libOSLib32.$(LIBSUFFIX)
++export OSLIBSUPPORTLIB := $(OSLIBSUPPORTDIR)/libOSLibSupport32.$(LIBSUFFIX)
++export OSLIBCSTRONG := $(BUILDDIR)/OSLib,3d6
+Index: Makefile
+===================================================================
+--- Makefile (revision 477)
++++ Makefile (working copy)
+@@ -29,6 +29,10 @@
+ install-elf: oslib-elf
+ $(MAKE) -C Source install BUILDTYPE=CROSSGCC_ELF
+
++# Installs the ELF headers & library in GCCSDK environment.
++install-elfeabi: oslib-elfeabi
++ $(MAKE) -C Source install BUILDTYPE=CROSSGCC_ELFEABI
++
+ # Installs the AOF headers & library in GCCSDK environment.
+ install-aof: oslib-aof
+ $(MAKE) -C Source install BUILDTYPE=CROSSGCC_AOF
+@@ -49,6 +53,10 @@
+ $(MAKE) -C Source oslib BUILDTYPE=CROSSGCC_ELF
+ $(MAKE) -C Source oslibsupport BUILDTYPE=CROSSGCC_ELF
+
++oslib-elfeabi: tools
++ $(MAKE) -C Source oslib BUILDTYPE=CROSSGCC_ELFEABI
++ $(MAKE) -C Source oslibsupport BUILDTYPE=CROSSGCC_ELFEABI
++
+ vapis: tools
+ $(MAKE) -C Source vapis BUILDTYPE=CROSSGCC_ELF
+
diff --git a/arm-riscos-gnueabihf/recipes/patches/oslib/defmod-elfeabi.p b/arm-riscos-gnueabihf/recipes/patches/oslib/defmod-elfeabi.p
new file mode 100644
index 0000000..97e15f8
--- /dev/null
+++ b/arm-riscos-gnueabihf/recipes/patches/oslib/defmod-elfeabi.p
@@ -0,0 +1,84 @@
+Index: Tools/DefMod2/assembler.c
+===================================================================
+--- Tools/DefMod2/assembler.c (revision 477)
++++ Tools/DefMod2/assembler.c (working copy)
+@@ -1242,6 +1242,21 @@
+ goto finish;
+ break;
+ }
++ case AsmType_eGCCELFEABI:
++ {
++ const char *floatABI = (FloatABI == FloatABI_eSoft) ? "soft" : "hard";
++ if (!apcs32)
++ {
++ fprintf(stderr, "EABI does not support APCS-26.");
++ goto finish;
++ }
++ if ((rc = sprintf (cmd,
++ "arm-riscos-gnueabihf-gcc -c -xassembler -mfloat-abi=%s -o %s %s",
++ floatABI,
++ name2, name1)) < 0)
++ goto finish;
++ break;
++ }
+ default:
+ fprintf (stderr, "Unknown assembler type\n");
+ goto finish;
+Index: Tools/DefMod2/assembler.h
+===================================================================
+--- Tools/DefMod2/assembler.h (revision 477)
++++ Tools/DefMod2/assembler.h (working copy)
+@@ -22,8 +22,9 @@
+ AsmType_eGCCAOF, /* Assembler used in GCCSDK 3.4 (AOF) release, called
+ 'as' (predecessor of AsAsm). */
+ AsmType_eARMASM, /* ARM's assembler. */
+- AsmType_eGCCELF /* Assembler used in GCCSDK 4 (ELF) release, called
++ AsmType_eGCCELF, /* Assembler used in GCCSDK 4 (ELF) release, called
+ 'gas' (GNU binutils assembler). */
++ AsmType_eGCCELFEABI /* Assembler used in EABI-capable GCCSDK */
+ } AsmType_e;
+
+ typedef enum
+@@ -37,7 +38,7 @@
+ extern AsmType_e AsmType;
+ extern FloatABI_e FloatABI;
+
+-#define GASSyntax (AsmType == AsmType_eGCCELF)
++#define GASSyntax (AsmType == AsmType_eGCCELF || AsmType == AsmType_eGCCELFEABI)
+
+ /*if |separate|, output is to the directory |output|; otherwise, to the file |file|.*/
+ extern os_error *assembler_output (FILE *file, const char *title, const char *author, lookup_t types, lookup_t swis, osbool separate, osbool apcs32, char *output);
+Index: Tools/DefMod2/defmod.y
+===================================================================
+--- Tools/DefMod2/defmod.y (revision 477)
++++ Tools/DefMod2/defmod.y (working copy)
+@@ -1179,7 +1179,7 @@
+ "[-o <output-dir> | > <output-file>] "
+ "[-byte_wide <byte-wide-file>] "
+ "[-26bit | -32bit] "
+- "[-asmtype [objasm | asasmaof | asasmelf | gccaof | armasm | gccelf]] "
++ "[-asmtype [objasm | asasmaof | asasmelf | gccaof | armasm | gccelf | gccelfeabi]] "
+ "[-float-abi [soft | hard]] "
+ "< <module-interface-file>\r"
+ "Purpose: generate output from a module interface file\r"
+@@ -1203,6 +1203,7 @@
+ "\tgccaof\t\t" "...use GCC AOF toolkit (GCCSDK 3.4 only)\r"
+ "\tarmasm\t\t" "...use ARM ASM\r"
+ "\tgccelf\t\t" "...use GCC ELF toolkit (GCCSDK 4 only)\r"
++ "\tgccelfeabi\t\t" "...use GCC EABI ELF toolkit (GCCSDK 8+ only)\r"
+ "-float-abi\t\t" "marks object files which float-abi is in use\r"
+ "\tsoft\t\t" "...soft-float, no FP instructions used\r"
+ "\thard\t\t" "...hard-float, FP instructions can be used\r"
+@@ -1345,9 +1346,11 @@
+ AsmType = AsmType_eARMASM;
+ else if (strcmp (argv[i], "gccelf") == 0)
+ AsmType = AsmType_eGCCELF;
++ else if (strcmp (argv[i], "gccelfeabi") == 0)
++ AsmType = AsmType_eGCCELFEABI;
+ else
+ {
+- fprintf (stderr, "Unknown option value %s for -asmtype (only \"objasm\", \"asasmaof\", \"asasmelf\", \"armarm\", \"gccaof\" and \"gccelf\" are known)\n", argv[i]);
++ fprintf (stderr, "Unknown option value %s for -asmtype (only \"objasm\", \"asasmaof\", \"asasmelf\", \"armarm\", \"gccaof\", \"gccelf\" and \"gccelfeabi\" are known)\n", argv[i]);
+ Parse_Error = TRUE;
+ goto finish;
+ }