Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions makes/include-target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ ifneq (,$(filter $(TARGETS_ARM8CORTEXR),$(TARGET_FAMILY)-$(TARGET_SUBFAMILY)))
TARGET_SUFF ?= armv8r
endif

# ARM multilib
TARGETS_ARMMULTILIB := \
arm-multilib

TARGETS += $(TARGETS_ARMMULTILIB)
ifneq (,$(filter $(TARGETS_ARMMULTILIB),$(TARGET_FAMILY)-$(TARGET_SUBFAMILY)))
TARGET_SUFF ?= arm-multilib
endif

# IA32
TARGETS_IA32 := ia32-generic

Expand Down
43 changes: 43 additions & 0 deletions target/arm-multilib.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# Makefile for Phoenix-RTOS 3
#
# ARM Multilib options
#
# Copyright 2025 Phoenix Systems
#

CROSS ?= arm-phoenix-

CC := $(CROSS)gcc
CXX := $(CROSS)g++

# common CFLAGS
OLVL ?= -O2
CFLAGS += -fomit-frame-pointer -mno-unaligned-access

LDFLAGS := -Wl,-z,max-page-size=0x10

# CFLAGS are passed via the last part of TARGET
MULTI_FLAGS := $(subst $(TARGET_FAMILY)-$(TARGET_SUBFAMILY)-,,$(TARGET))

CFLAGS += $(subst @, -, $(MULTI_FLAGS))

CXXFLAGS := $(CFLAGS)

AR := $(CROSS)ar
ARFLAGS := -r

LD := $(CROSS)gcc
LDFLAGS_PREFIX := -Wl,

OBJCOPY := $(CROSS)objcopy
OBJDUMP := $(CROSS)objdump

STRIP := $(CROSS)strip

# Choose if target has MMU based on fPIC flag from multilib.
ifeq ($(subst fPIC,,$(CFLAGS)), $(CFLAGS))
HAVE_MMU := y
else
HAVE_MMU := n
endif
82 changes: 82 additions & 0 deletions toolchain/binutils-2.43-05-arm-phoenix-emul-fdpic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
diff --git a/bfd/config.bfd b/bfd/config.bfd
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -410,7 +410,7 @@ case "${targ}" in
;;
arm-*-phoenix*)
targ_defvec=arm_elf32_le_vec
- targ_selvecs=arm_elf32_be_vec
+ targ_selvecs="arm_elf32_be_vec arm_elf32_fdpic_le_vec arm_elf32_fdpic_be_vec"
;;
armeb-*-elf | arm*b-*-freebsd* | arm*b-*-linux-* | armeb-*-eabi*)
targ_defvec=arm_elf32_be_vec
diff --git a/ld/Makefile.am b/ld/Makefile.am
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -174,6 +174,7 @@ ALL_EMULATION_SOURCES = \
earmelf_nacl.c \
earmelf_nbsd.c \
earmelf_phoenix.c \
+ earmelf_phoenix_fdpiceabi.c \
earmelf_vxworks.c \
earmelfb.c \
earmelfb_fbsd.c \
diff --git a/ld/Makefile.in b/ld/Makefile.in
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -685,6 +685,7 @@ ALL_EMULATION_SOURCES = \
earmelf_nacl.c \
earmelf_nbsd.c \
earmelf_phoenix.c \
+ earmelf_phoenix_fdpiceabi.c \
earmelf_vxworks.c \
earmelfb.c \
earmelfb_fbsd.c \
@@ -1311,6 +1312,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_nacl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_nbsd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_phoenix.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_phoenix_fdpiceabi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_vxworks.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_fbsd.Po@am__quote@
diff --git a/ld/configure.tgt b/ld/configure.tgt
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -200,7 +200,7 @@ arm-*-nto*) targ_emul=armnto
;;
arm-*-phoenix*)
targ_emul=armelf_phoenix
- targ_extra_emuls="armelf"
+ targ_extra_emuls="armelf armelf_phoenix_fdpiceabi"
targ_extra_libpath=$targ_extra_emuls
;;
armeb-*-elf | armeb-*-eabi*)
diff --git a/ld/emulparams/armelf_phoenix_fdpiceabi.sh b/ld/emulparams/armelf_phoenix_fdpiceabi.sh
--- /dev/null
+++ b/ld/emulparams/armelf_phoenix_fdpiceabi.sh
@@ -0,0 +1,12 @@
+source_sh ${srcdir}/emulparams/armelf_phoenix.sh
+
+OUTPUT_FORMAT="elf32-littlearm-fdpic"
+BIG_OUTPUT_FORMAT="elf32-bigarm-fdpic"
+LITTLE_OUTPUT_FORMAT="elf32-littlearm-fdpic"
+
+OTHER_READONLY_SECTIONS="${OTHER_READONLY_SECTIONS}
+ .rofixup : {
+ ${RELOCATING+__ROFIXUP_LIST__ = .;}
+ *(.rofixup)
+ ${RELOCATING+__ROFIXUP_END__ = .;}
+}"
diff --git a/ld/po/BLD-POTFILES.in b/ld/po/BLD-POTFILES.in
--- a/ld/po/BLD-POTFILES.in
+++ b/ld/po/BLD-POTFILES.in
@@ -36,6 +36,7 @@ earmelf_linux_fdpiceabi.c
earmelf_nacl.c
earmelf_nbsd.c
earmelf_phoenix.c
+earmelf_phoenix_fdpiceabi.c
earmelf_vxworks.c
earmelfb.c
earmelfb_fbsd.c

24 changes: 14 additions & 10 deletions toolchain/build-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ if command -v "${TARGET}-gcc" > /dev/null; then
exit 1
fi

# old legacy versions of the compiler:
#BINUTILS=binutils-2.28
#GCC=gcc-7.1.0

BINUTILS=binutils-2.43
GCC=gcc-9.5.0
GCC=gcc-14.2.0

TOOLCHAIN_PREFIX="${BUILD_ROOT}/${TARGET}"
SYSROOT="${TOOLCHAIN_PREFIX}/${TARGET}"
Expand Down Expand Up @@ -140,6 +136,7 @@ build_gcc_stage1() {
# --enable-initfini-array -> force init/fini array support instead of .init .fini sections
# --disable-decimal-float -> not relevant for other than i386 and PowerPC
# --disable-libquadmath -> not using fortran and quad floats
# --disable-tm-clone-registry -> no support for Transactional Memory
# --enable-threads=posix -> enable POSIX threads


Expand All @@ -154,7 +151,8 @@ build_gcc_stage1() {
--disable-decimal-float \
--disable-libquadmath \
--disable-libssp --disable-nls \
--enable-threads=posix
--enable-threads=posix \
--disable-tm-clone-registry

make all-gcc

Expand All @@ -175,12 +173,20 @@ build_libc() {
mkdir -p "${SYSROOT}/usr/include"
ln -snf usr/include "${SYSROOT}/include"

if [ "$TARGET" = "arm-phoenix" ]; then
for multilib_target in $("$TARGET-gcc" -print-multi-lib); do
multilib_flags=${multilib_target/*;/}
phx_targets="$phx_targets arm-multilib-$multilib_flags"
done
fi
# Overwrite multilibs with Phoenix targets when available.
phx_targets="$phx_targets $PHOENIX_TARGETS"

# NOCHECKENV: don't check if build env is sane - we're building only necessary components by hand
for phx_target in $PHOENIX_TARGETS; do
for phx_target in $phx_targets; do
log "[$phx_target] installing kernel headers"
make -C "$SCRIPT_DIR/../../phoenix-rtos-kernel" NOCHECKENV=1 TARGET="$phx_target" install-headers

# FIXME: libphoenix should be installed for all supported multilib target variants
log "[$phx_target] installing libphoenix"
make -C "$SCRIPT_DIR/../../libphoenix" NOCHECKENV=1 TARGET="$phx_target" clean install
done
Expand Down Expand Up @@ -227,7 +233,6 @@ build_libstdcpp() {
# LIBSTDC++ compilation options
# --host -> target is a host for libstdc++
# --with-gxx-include-dir -> configure as a subdir of sysroot for c++ includes to work with external (out-of-toolchain) sysroot
# --with-libphoenix -> use libphoenix as standard C library
# --enable-tls -> enable Thread Local Storage
# --disable-nls -> all compiler messages will be in english
# --disable-shared -> disable building shared libraries [default=yes]
Expand All @@ -239,7 +244,6 @@ build_libstdcpp() {
--host="${TARGET}" \
--prefix="${SYSROOT}" \
--with-gxx-include-dir="${SYSROOT}/include/c++" \
--with-libphoenix \
--enable-tls \
--disable-nls \
--disable-shared \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
--- gcc-9.3.0-orig/gcc/config.gcc 2020-03-12 12:07:21.000000000 +0100
+++ gcc-9.3.0/gcc/config.gcc 2020-03-18 19:25:57.937836171 +0100
@@ -1205,7 +1205,9 @@
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 95c91ee02be..7ad62278cfa 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1465,7 +1465,9 @@ arm*-*-phoenix*)
tm_file="elfos.h arm/unknown-elf.h arm/elf.h arm/bpabi.h"
tm_file="${tm_file} newlib-stdint.h phoenix.h"
tm_file="${tm_file} arm/aout.h arm/arm.h"
Expand All @@ -11,3 +13,4 @@
target_cpu_cname="arm7tdmi"
;;
arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems* | arm*-*-fuchsia*)

40 changes: 40 additions & 0 deletions toolchain/gcc-14.2.0-02-i386-pc-phoenix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh
--- a/fixincludes/mkfixinc.sh
+++ b/fixincludes/mkfixinc.sh
@@ -11,6 +11,7 @@ target=fixinc.sh

# Check for special fix rules for particular targets
case $machine in
+ *-phoenix* | \
i?86-*-cygwin* | \
i?86-*-mingw32* | \
x86_64-*-mingw32* | \
diff --git a/gcc/config.gcc b/gcc/config.gcc
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1934,6 +1934,9 @@ i[34567]86-*-elfiamcu)
i[34567]86-*-elf*)
tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h"
;;
+i[34567]86-*-phoenix*)
+ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h phoenix.h"
+ ;;
x86_64-*-elf*)
tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
;;
diff --git a/libgcc/config.host b/libgcc/config.host
index e75a7af647f..9ec10581966 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -818,6 +818,10 @@ i[34567]86-pc-msdosdjgpp*)
;;
i[34567]86-*-lynxos*)
;;
+i[34567]86-*-phoenix*)
+ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
i[34567]86-*-nto-qnx*)
tmake_file="$tmake_file i386/t-nto t-libgcc-pic"
extra_parts=crtbegin.o

22 changes: 22 additions & 0 deletions toolchain/gcc-14.2.0-03-riscv64-phoenix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/gcc/config.gcc b/gcc/config.gcc
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2509,13 +2509,16 @@ riscv*-*-linux*)
gcc_cv_initfini_array=yes
with_tls=${with_tls:-trad}
;;
-riscv*-*-elf* | riscv*-*-rtems*)
+riscv*-*-elf* | riscv*-*-rtems* | riscv*-*-phoenix*)
tm_file="elfos.h newlib-stdint.h ${tm_file} riscv/elf.h"
case ${target} in
*-*-rtems*)
tm_file="${tm_file} riscv/rtems.h rtems.h"
tmake_file="${tmake_file} riscv/t-rtems"
;;
+ *-*-phoenix*)
+ tm_file="${tm_file} phoenix.h"
+ ;;
*)
if test "x${with_multilib_generator}" = xdefault; then
case "x${enable_multilib}" in

Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
diff -Naur gcc-9.3.0-orig/libgcc/config/arm/t-phoenix gcc-9.3.0/libgcc/config/arm/t-phoenix
--- gcc-9.3.0-orig/libgcc/config/arm/t-phoenix 1970-01-01 01:00:00.000000000 +0100
+++ gcc-9.3.0/libgcc/config/arm/t-phoenix 2021-08-23 13:40:28.290478307 +0200
diff --git a/libgcc/config.host b/libgcc/config.host
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -556,6 +556,7 @@ arm*-*-uclinux*) # ARM ucLinux
arm*-*-phoenix*)
tmake_file="t-hardfp t-softfp arm/t-arm arm/t-elf arm/t-softfp arm/t-phoenix"
tmake_file="${tmake_file} arm/t-bpabi"
+ tmake_file="${tmake_file} t-crtstuff-pic t-libgcc-pic"
tm_file="$tm_file arm/bpabi-lib.h"
extra_parts="crtbegin.o crtend.o crti.o crtn.o"
unwind_header=config/arm/unwind-arm.h
diff --git a/libgcc/config/arm/t-phoenix b/libgcc/config/arm/t-phoenix
new file mode 100644
--- /dev/null
+++ b/libgcc/config/arm/t-phoenix
@@ -0,0 +1,13 @@
+# PhoenixRTOS uses relocatable ELFs on NOMMU platforms
+# if this is ARM Cortex-M/R subvariant -> build libgcc/crtstuff with PIC
Expand All @@ -15,14 +27,4 @@ diff -Naur gcc-9.3.0-orig/libgcc/config/arm/t-phoenix gcc-9.3.0/libgcc/config/ar
+ CRTSTUFF_T_CFLAGS = $(PICFLAG) -mno-pic-data-is-text-relative
+ INTERNAL_CFLAGS += $(PICFLAG) -mno-pic-data-is-text-relative
+endif
diff -Naur gcc-9.3.0-orig/libgcc/config.host gcc-9.3.0/libgcc/config.host
--- gcc-9.3.0-orig/libgcc/config.host 2020-03-12 12:07:23.000000000 +0100
+++ gcc-9.3.0/libgcc/config.host 2021-07-23 10:19:14.900201201 +0200
@@ -454,6 +454,7 @@
arm*-*-phoenix*)
tmake_file="t-hardfp t-softfp arm/t-arm arm/t-elf arm/t-softfp arm/t-phoenix"
tmake_file="${tmake_file} arm/t-bpabi"
+ tmake_file="${tmake_file} t-crtstuff-pic t-libgcc-pic"
tm_file="$tm_file arm/bpabi-lib.h"
extra_parts="crtbegin.o crtend.o crti.o crtn.o"
unwind_header=config/arm/unwind-arm.h

Loading
Loading