Skip to content

Commit

Permalink
m68k-palm-elf-gcc: new port
Browse files Browse the repository at this point in the history
This is a toolchain for building Palm OS apps. It consists of the
Retro68 fork of gcc 9.1.0, with a few patches from dmitrygr.
  • Loading branch information
nkorth authored and herbygillot committed Nov 14, 2023
1 parent e80c1b8 commit b0e005d
Show file tree
Hide file tree
Showing 5 changed files with 2,847 additions and 0 deletions.
12 changes: 12 additions & 0 deletions palm/m68k-palm-elf-binutils/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup crossbinutils 1.0

crossbinutils.setup m68k-palm-elf 2.37
revision 0
categories palm cross

maintainers {@nkorth nkorth.com:nkorth} openmaintainer

configure.args-append --disable-werror
20 changes: 20 additions & 0 deletions palm/m68k-palm-elf-gcc/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup crossgcc 1.0

crossgcc.setup m68k-palm-elf 9.1.0
crossgcc.languages c
revision 0
maintainers {@nkorth nkorth.com:nkorth} openmaintainer
categories palm cross


patch.pre_args -p1
patchfiles retro68.diff \
palm.diff \
aarch64.diff

# palm specific config
configure.args-delete --enable-multilib
configure.args-append --disable-multilib --disable-libssp --with-arch=m68k --with-cpu=m68000
86 changes: 86 additions & 0 deletions palm/m68k-palm-elf-gcc/files/aarch64.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
diff --git a/config.guess b/config.guess
index 8e2a58b86..772577d8d 100755
--- a/config.guess
+++ b/config.guess
@@ -1309,6 +1309,9 @@ EOF
*:Rhapsody:*:*)
echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
exit ;;
+ arm64:Darwin:*:*)
+ echo aarch64-apple-darwin"$UNAME_RELEASE"
+ exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
set_cc_for_build
diff --git a/gcc/config.host b/gcc/config.host
index 816a0f06c..adaa50b73 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -99,7 +99,8 @@ case ${host} in
esac

case ${host} in
- aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia*)
+ aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* |\
+ aarch64*-*-darwin*)
case ${target} in
aarch64*-*-*)
host_extra_gcc_objs="driver-aarch64.o"
@@ -263,6 +264,10 @@ case ${host} in
out_host_hook_obj="${out_host_hook_obj} host-ppc64-darwin.o"
host_xmake_file="${host_xmake_file} rs6000/x-darwin64"
;;
+ aarch64-*-darwin*)
+ out_host_hook_obj="${out_host_hook_obj} host-aarch64-darwin.o"
+ host_xmake_file="${host_xmake_file} aarch64/x-darwin"
+ ;;
rs6000-ibm-aix* | powerpc-ibm-aix*)
host_xmake_file="${host_xmake_file} rs6000/x-aix"
;;
diff --git a/gcc/config/aarch64/host-aarch64-darwin.c b/gcc/config/aarch64/host-aarch64-darwin.c
new file mode 100644
index 000000000..5ed81cf7d
--- /dev/null
+++ b/gcc/config/aarch64/host-aarch64-darwin.c
@@ -0,0 +1,32 @@
+/* i386-darwin host-specific hook definitions.
+ Copyright (C) 2003-2019 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#define IN_TARGET_CODE 1
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"
+#include "config/host-darwin.h"
+
+/* Darwin doesn't do anything special for aarch64 hosts; this file exists just
+ to include config/host-darwin.h. */
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff --git a/gcc/config/aarch64/x-darwin b/gcc/config/aarch64/x-darwin
new file mode 100644
index 000000000..6d788d5e8
--- /dev/null
+++ b/gcc/config/aarch64/x-darwin
@@ -0,0 +1,3 @@
+host-aarch64-darwin.o : $(srcdir)/config/aarch64/host-aarch64-darwin.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
182 changes: 182 additions & 0 deletions palm/m68k-palm-elf-gcc/files/palm.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c
index 03dca31e7..c46a3a151 100644
--- a/gcc/c-family/c-lex.c
+++ b/gcc/c-family/c-lex.c
@@ -1353,10 +1353,15 @@ lex_charconst (const cpp_token *token)
}
/* In C, a character constant has type 'int'.
In C++ 'char', but multi-char charconsts have type 'int'. */
- else if (!c_dialect_cxx () || chars_seen > 1)
- type = integer_type_node;
- else
+ else if (c_dialect_cxx ())
type = char_type_node;
+ else if (chars_seen > 2)
+ type = long_unsigned_type_node;
+ else if (chars_seen > 1)
+ type = unsigned_type_node;
+ else
+ type = integer_type_node;
+

/* Cast to cppchar_signed_t to get correct sign-extension of RESULT
before possibly widening to HOST_WIDE_INT for build_int_cst. */
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index fbc734a04..5f8c75086 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -1557,7 +1557,7 @@ init_pragma (void)
c_register_pragma_with_expansion (0, "message", handle_pragma_message);

#ifdef REGISTER_TARGET_PRAGMAS
- REGISTER_TARGET_PRAGMAS ();
+// REGISTER_TARGET_PRAGMAS ();
#endif

global_sso = default_sso;
diff --git a/gcc/calls.c b/gcc/calls.c
index 3d5af427d..b0ce7d4ac 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -4092,7 +4092,7 @@ expand_call (tree exp, rtx target, int ignore)

if (is_pascal)
{
- auto pascal_return_mode = TYPE_MODE (TREE_TYPE (funtype));
+ machine_mode pascal_return_mode = TYPE_MODE (TREE_TYPE (funtype));
poly_uint16 modesize = GET_MODE_SIZE (pascal_return_mode);
#ifdef PUSH_ROUNDING
modesize = PUSH_ROUNDING (modesize);
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 19fc2b6fc..904f58ee5 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -456,8 +456,6 @@ m32r*-*-*)
m68k-*-*)
extra_headers=math-68881.h
extra_options="${extra_options} m68k/m68k-tables.opt"
- c_target_objs="m68k-mac-pragmas.o"
- cxx_target_objs="m68k-mac-pragmas.o"
;;
microblaze*-*-*)
cpu_type=microblaze
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index d66ea01a9..b10a1ebf2 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -5537,9 +5537,9 @@ m68k_function_value (const_tree valtype, const_tree func_decl_or_type, bool outg
break;
}

-#if 1 /* POINTERS_IN_D0 */
+#if 0 /* POINTERS_IN_D0 */
return gen_rtx_REG (mode, D0_REG);
-#else
+
/* If the function returns a pointer, push that into %a0. */
if (type && POINTER_TYPE_P (TREE_TYPE (type)) && !outgoing)
/* For compatibility with the large body of existing code which
@@ -5558,7 +5558,9 @@ m68k_function_value (const_tree valtype, const_tree func_decl_or_type, bool outg
gen_rtx_EXPR_LIST (VOIDmode,
gen_rtx_REG (mode, D0_REG),
const0_rtx)));
- else if (POINTER_TYPE_P (valtype))
+ else
+#else
+ if (POINTER_TYPE_P (valtype))
return gen_rtx_REG (mode, A0_REG);
else
return gen_rtx_REG (mode, D0_REG);
diff --git a/libcpp/charset.c b/libcpp/charset.c
index 67eddcc7f..452143631 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -1796,7 +1796,7 @@ narrow_str_to_charconst (cpp_reader *pfile, cpp_string str,
unsigned int *pchars_seen, int *unsignedp)
{
size_t width = CPP_OPTION (pfile, char_precision);
- size_t max_chars = CPP_OPTION (pfile, int_precision) / width;
+ size_t max_chars = 4;
size_t mask = width_to_mask (width);
size_t i;
cppchar_t result, c;
@@ -1831,9 +1831,9 @@ narrow_str_to_charconst (cpp_reader *pfile, cpp_string str,
else if (i > 1 && i != 4 && CPP_OPTION (pfile, warn_multichar))
cpp_warning (pfile, CPP_W_MULTICHAR, "multi-character character constant");

- /* Multichar constants are of type int and therefore signed. */
+ /* Multichar constants are of type UNSIGNED LONG for PALMOS. */
if (i > 1)
- unsigned_p = 0;
+ unsigned_p = 1;
else
unsigned_p = CPP_OPTION (pfile, unsigned_char);

@@ -1841,8 +1841,10 @@ narrow_str_to_charconst (cpp_reader *pfile, cpp_string str,
sign- or zero-extend to the full width of cppchar_t.
For single-character constants, the value is WIDTH bits wide.
For multi-character constants, the value is INT_PRECISION bits wide. */
- if (i > 1)
- width = CPP_OPTION (pfile, int_precision);
+ if (i > 2) //3-4 char sequences are long, 2-char seq is short
+ width = 32;
+ else if (i > 1)
+ width = 16;
if (width < BITS_PER_CPPCHAR_T)
{
mask = ((cppchar_t) 1 << width) - 1;
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index ea390a5bb..2b4eb8601 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -246,7 +246,8 @@ LIBGCC2_DEBUG_CFLAGS = -g
LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
$(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \
-fbuilding-libgcc -fno-stack-protector \
- $(INHIBIT_LIBC_CFLAGS)
+ -ffunction-sections \
+ $(INHIBIT_LIBC_CFLAGS) -mpcrel -fpic

# Additional options to use when compiling libgcc2.a.
# Some targets override this to -isystem include
@@ -441,10 +442,13 @@ lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \
_negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 \
_ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2 \
_paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2 \
- _mulhc3 _mulsc3 _muldc3 _mulxc3 _multc3 _divhc3 _divsc3 \
- _divdc3 _divxc3 _divtc3 _bswapsi2 _bswapdi2 _clrsbsi2 \
+ _bswapsi2 _bswapdi2 _clrsbsi2 \
_clrsbdi2

+# complex shit we do not support (gcc bugs cause compile failure)
+#lib2funcs += _mulhc3 _mulsc3 _muldc3 _mulxc3 _multc3 _divhc3 _divsc3 \
+# _divdc3 _divxc3 _divtc3
+
# The floating-point conversion routines that involve a single-word integer.
# XX stands for the integer mode.
swfloatfuncs = $(patsubst %,_fixuns%XX,sf df xf)
diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S
index c38721122..2bd998c2e 100644
--- a/libgcc/config/m68k/lb1sf68.S
+++ b/libgcc/config/m68k/lb1sf68.S
@@ -97,16 +97,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
* a little on this and in the PIC case, we use short offset branches and
* hope that the final object code is within range (which it should be).
*/
+
+
#ifndef __PIC__

/* Non PIC (absolute/relocatable) versions */

.macro PICCALL addr
- jbsr \addr
+ bsr \addr
.endm

.macro PICJUMP addr
- jmp \addr
+ bra \addr
.endm

.macro PICLEA sym, reg
Loading

0 comments on commit b0e005d

Please sign in to comment.