NIOS2 Tools based on Altera's 4.11 tool set.

Add support for building the NIOS2 tool set. The source
is based on the Altera 4.11 src package. This package has been
split up and placed on the rtems.org server.
This commit is contained in:
Chris Johns 2013-02-12 11:46:29 +11:00
parent 6fad89b9b0
commit 0328944c57
9 changed files with 126486 additions and 5 deletions

View File

@ -0,0 +1,25 @@
#
# Tools Set for RTEMS NIOS 4.11 Stable
#
# The NIOS source is a special version released by Altera.
#
%define rtems_version 4.11
%define release 1
%define _target nios2-rtems%{rtems_version}
package: rtems-%{rtems_version}-%{_target}-%{release}
#
# The RTEMS 4.11 base defines.
#
%include rtems-4.11-base.bset
#
# Tools configuration.
#
rtems-nios2-binutils-2.20-1
rtems-nios2-gcc-4.1-newlib-1.19.0-1
rtems-nios2-gdb-7.0-1

View File

@ -0,0 +1,22 @@
#
# RTEMS NIOS2 Binutils 2.21.
#
%include %{_configdir}/checks.cfg
%include %{_configdir}/base.cfg
%define binutils_version 2.20
%define host_force_32bit
%define with_deterministic_archives
#
# Source
#
Source0: http://www.rtems.org/ftp/people/chrisj/nios/nios2-binutils-2.20.tar.bz2
Patch0: nios2-binutils-2.20-rtems-20110703.diff
#
# The binutils build instructions. We use 2.xx Release 1.
#
%include %{_configdir}/binutils-2-1.cfg

View File

@ -0,0 +1,167 @@
#
# RTEMS NIOS2 GCC 4.1., Newlib 1.19.0
#
%include %{_configdir}/checks.cfg
%include %{_configdir}/base.cfg
%define gcc_version 4.1
%define newlib_version 1.19.0
%define newlib_cfg normalc
%define with_threads 1
%define with_plugin 0
%define enable_cxx 1
#
# The RTEMS 4.11 patches
#
Patch0: nios2-gcc-4.1-rtems-20110818.diff
Patch10: nios2-newlib-1.19.0-rtems-20110720.diff
#
# Project custom message
#
%define gcc_version_message RTEMS %{rtems_version}-%{release},gcc-%{gcc_version}/newlib-%{newlib_version}
Name: %{_target}-gcc-%{gcc_version}-newlib-%{newlib_version}-%{release}
Summary: GCC v%{gcc_version} and Newlib v%{newlib_version} for target %{_target} on host %{_host}
Version: %{gcc_version}
Release: %{release}
URL: http://gcc.gnu.org/
BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
#
# Source
#
#
# GCC core and G++
#
Source0: http://www.rtems.org/ftp/people/chrisj/nios/nios2-gcc-4.1.tar.bz2
#
# Newlib
#
Source10: ftp://sourceware.org/pub/newlib/newlib-%{newlib_version}.tar.gz
#
# The GCC library directory
#
%global _gcclibdir %{_prefix}/lib
#
# Prepare the source code.
#
%prep
%setup -q -c -T -n %{name}-%{version}
# gcc
%setup -q -T -D -n %{name}-%{version} -a0
cd gcc-%{gcc_version}
%{?patch0:%patch0 -p1}
cd ..
# newlib
%setup -q -T -D -n %{name}-%{version} -a10
cd newlib-%{newlib_version}
%{?patch10:%patch10 -p1}
cd ..
# Link newlib into the gcc source tree
ln -s ../newlib-%{newlib_version}/newlib gcc-%{gcc_version}
echo "%{gcc_version_message}" > gcc-%{gcc_version}/gcc/DEV-PHASE
# Fix timestamps
cd gcc-%{gcc_version}
contrib/gcc_update --touch
cd ..
%build
export PATH="%{_bindir}:${PATH}"
mkdir -p build
cd build
languages="c"
%if %{enable_cxx}
languages="$languages,c++"
%endif
%if "%{_build}" != "%{_host}"
CFLAGS_FOR_BUILD="-g -O2 -Wall" \
CC="%{_host}-gcc ${SB_OPT_FLAGS}" \
%else
# gcc is not ready to be compiled with -std=gnu99
CC=$(echo "%{__cc} ${SB_OPT_FLAGS}" | sed -e 's,-std=gnu99 ,,') \
%endif
../gcc-%{gcc_version}/configure \
--prefix=%{_prefix} \
--bindir=%{_bindir} \
--exec_prefix=%{_exec_prefix} \
--includedir=%{_includedir} \
--libdir=%{_gcclibdir} \
--libexecdir=%{_libexecdir} \
--mandir=%{_mandir} \
--infodir=%{_infodir} \
--datadir=%{_datadir} \
--build=%_build --host=%_host \
--target=%{_target} \
--disable-libstdcxx-pch \
--with-gnu-as --with-gnu-ld --verbose \
--with-newlib \
--with-system-zlib \
--disable-nls --without-included-gettext \
--disable-win32-registry \
--enable-version-specific-runtime-libs \
%{?with_lto:--enable-lto}%{!?with_lto:--disable-lto} \
%{?with_threads:--enable-threads}%{!?with_threads:--disable-threads} \
%{?with_plugin:--enable-plugin}%{!?with_plugin:--disable-plugin} \
%{?enable_obsolete:--enable-obsolete} \
--enable-languages="$languages"
%if "%_host" != "%_build"
# Bug in gcc-3.2.1:
# Somehow, gcc doesn't get syslimits.h right for Cdn-Xs
mkdir -p gcc/include
cp ../gcc-%{gcc_version}/gcc/gsyslimits.h gcc/include/syslimits.h
%endif
%{__make} -w %{?_smp_mflags} N2GNU_BUILD_NEWLIB="%{newlib_cfg}" all
cd ..
%install
export PATH="%{_bindir}:${PATH}"
rm -rf $SB_BUILD_ROOT
cd build
#
# Filter the doc stuff we do not want so it builds without error on
# hosts that do not have tex to pdf converters installed.
#
for m in $(find . -name Makefile)
do
mv $m $m.orig
echo "Doc filteirng $m.orig -> $m"
cat $m.orig | sed -e 's/ pdf / /g' \
-e 's/ pdf$/ /g' \
-e 's/ install-pdf / /g' \
-e 's/ install-pdf$/ /g' \
-e 's/ install-html / /g' \
-e 's/ install-html$/ /g' \
-e 's/ html / /g' \
-e 's/ html$/ /g' > $m
done
%{__make} -w DESTDIR=$SB_BUILD_ROOT N2GNU_BUILD_NEWLIB="%{newlib_cfg}" install
cd ..
# libiberty doesn't honor --libdir, but always installs to a
# magically guessed _libdir
rm -f ${SB_BUILD_ROOT}%{_libdir}/libiberty.a
# We use the version from binutils
rm -f $SB_BUILD_ROOT%{_bindir}/%{_target}-c++filt%{_exeext}
# We don't ship info/dir
rm -f $SB_BUILD_ROOT%{_infodir}/dir
# Don't want libffi's man-pages
rm -f $SB_BUILD_ROOT%{_mandir}/man3/*ffi*

View File

@ -0,0 +1,15 @@
#
# GDB 7.0.
#
%include %{_configdir}/checks.cfg
%include %{_configdir}/base.cfg
%define gdb_version 7.0
Source0: http://www.rtems.org/ftp/people/chrisj/nios/nios2-gdb-7.0.tar.bz2
#
# The gdb build instructions. We use 7.xx Release 1.
#
%include %{_configdir}/gdb-7-1.cfg

View File

@ -0,0 +1,21 @@
--- binutils-2.20.orig/gas/configure.tgt 2011-07-03 18:19:58.000000000 +1000
+++ binutils-2.20/gas/configure.tgt 2011-07-03 18:14:15.000000000 +1000
@@ -315,6 +315,7 @@
nios2*-linux*) fmt=elf em=linux ;;
nios2*-*-*) fmt=elf ;;
+ nios2*-rtems*) fmt=elf ;;
ns32k-pc532-mach*) fmt=aout em=pc532mach ;;
ns32k-pc532-ux*) fmt=aout em=pc532mach ;;
--- binutils-2.20.orig/gas/config/tc-nios2.c 2011-07-03 18:20:09.000000000 +1000
+++ binutils-2.20/gas/config/tc-nios2.c 2011-07-03 18:08:42.000000000 +1000
@@ -1340,7 +1340,7 @@
void
md_number_to_chars (char *buf, valueT val, int n)
{
- assert (n == 1 || n == 2 || n == 4);
+ assert (n == 1 || n == 2 || n == 4 || n == 8);
if (target_big_endian)
{
number_to_chars_bigendian (buf, val, n);

View File

@ -0,0 +1,213 @@
diff -ruN gcc-4.1.orig/config-ml.in gcc-4.1/config-ml.in
--- gcc-4.1.orig/config-ml.in 2011-04-26 11:29:52.000000000 +1000
+++ gcc-4.1/config-ml.in 2011-08-06 10:24:23.000000000 +1000
@@ -892,13 +892,48 @@
fi
fi
- if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
- --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
- ${ac_configure_args} ${ml_srcdiroption} ; then
- true
- else
- exit 1
- fi
+ case $(uname) in
+ MINGW32*)
+ #
+ # Work around bugs in MSYS sed or bash. The CC in
+ # ${ac_configure_args} overrides the CC built above
+ # I do not know if the CC should have been stripped
+ # before this script. It seems sed in MSYS does not
+ # handle:
+ # $ echo "'XX=hello' 'YY=world' 'CC=gcc -O3'" | sed -e "s/\'CC=.*\'//g"
+ #
+ tmp_IFS=$IFS
+ IFS="'"
+ tmp__ac_configure_args=
+ for o in ${ac_configure_args}
+ do
+ o=$(echo $o | sed -e 's/ *$//g')
+ case $o in
+ CC=*) ;;
+ '') ;;
+ *) tmp__ac_configure_args="${tmp__ac_configure_args} "\'$o\' ;;
+ esac
+ done
+ IFS=$tmp_IFS
+
+ if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
+ --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
+ ${tmp__ac_configure_args} ${ml_srcdiroption} ; then
+ true
+ else
+ exit 1
+ fi
+ ;;
+ *)
+ if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
+ --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
+ ${ac_configure_args} ${ml_srcdiroption} ; then
+ true
+ else
+ exit 1
+ fi
+ ;;
+ esac
cd ${ML_POPDIR}
diff -ruN gcc-4.1.orig/gcc/DEV-PHASE gcc-4.1/gcc/DEV-PHASE
--- gcc-4.1.orig/gcc/DEV-PHASE 2011-04-26 11:29:52.000000000 +1000
+++ gcc-4.1/gcc/DEV-PHASE 2011-08-06 10:24:25.000000000 +1000
@@ -0,0 +1 @@
+RTEMS (chrisj@rtems.org) NIOS2 gcc-4.1-11.0/newlib-1.19.0
diff -ruN gcc-4.1.orig/gcc/config/nios2/crti.asm gcc-4.1/gcc/config/nios2/crti.asm
--- gcc-4.1.orig/gcc/config/nios2/crti.asm 2011-04-26 11:29:54.000000000 +1000
+++ gcc-4.1/gcc/config/nios2/crti.asm 2011-08-18 11:14:30.000000000 +1000
@@ -67,6 +67,11 @@
stw r16, 12(sp)
stw fp, 8(sp)
addi fp, sp, 8
+
+#if !defined(__rtems__)
+/* FIXME: Disabled for now.
+ * Causes undefined refs to _GLOBAL_OFFSET_TABLE_
+ */
nextpc r22
#ifdef __nios2_6b__
1: movhi20 r2, %hi20adj(_GLOBAL_OFFSET_TABLE_ - 1b)
@@ -76,7 +81,7 @@
addi r2, r2, %lo(_GLOBAL_OFFSET_TABLE_ - 1b)
#endif
add r22, r22, r2
-
+#endif
.section ".fini"
.align 2
@@ -94,6 +99,11 @@
stw r16, 12(sp)
stw fp, 8(sp)
addi fp, sp, 8
+
+#if !defined(__rtems__)
+/* FIXME: Disabled for now.
+ * Causes undefined refs to _GLOBAL_OFFSET_TABLE_
+ */
nextpc r22
#ifdef __nios2_6b__
1: movhi20 r2, %hi20adj(_GLOBAL_OFFSET_TABLE_ - 1b)
@@ -102,7 +112,5 @@
1: movhi r2, %hiadj(_GLOBAL_OFFSET_TABLE_ - 1b)
addi r2, r2, %lo(_GLOBAL_OFFSET_TABLE_ - 1b)
#endif
-
add r22, r22, r2
-
-
+#endif
diff -ruN gcc-4.1.orig/gcc/config/nios2/nios2-protos.h gcc-4.1/gcc/config/nios2/nios2-protos.h
--- gcc-4.1.orig/gcc/config/nios2/nios2-protos.h 2011-04-26 11:29:54.000000000 +1000
+++ gcc-4.1/gcc/config/nios2/nios2-protos.h 2011-08-06 10:24:23.000000000 +1000
@@ -88,3 +88,5 @@
extern int nios2_return_in_memory (tree);
#endif /* TREE_CODE */
+
+rtx nios2_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode);
diff -ruN gcc-4.1.orig/gcc/config/nios2/rtems.h gcc-4.1/gcc/config/nios2/rtems.h
--- gcc-4.1.orig/gcc/config/nios2/rtems.h 1970-01-01 10:00:00.000000000 +1000
+++ gcc-4.1/gcc/config/nios2/rtems.h 2011-08-17 17:06:39.000000000 +1000
@@ -0,0 +1,29 @@
+/* Definitions for rtems targeting a NIOS2 using ELF.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ Contributed by Chris Johns (chrisj@rtems.org).
+
+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 2, 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 COPYING. If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+/* Specify predefined symbols in preprocessor. */
+
+#define TARGET_OS_CPP_BUILTINS() \
+do { \
+ builtin_define ("__rtems__"); \
+ builtin_define ("__USE_INIT_FINI__"); \
+ builtin_assert ("system=rtems"); \
+} while (0)
diff -ruN gcc-4.1.orig/gcc/config/nios2/t-rtems gcc-4.1/gcc/config/nios2/t-rtems
--- gcc-4.1.orig/gcc/config/nios2/t-rtems 1970-01-01 10:00:00.000000000 +1000
+++ gcc-4.1/gcc/config/nios2/t-rtems 2011-08-18 06:03:59.000000000 +1000
@@ -0,0 +1,4 @@
+# Multilibs for NIOS2 RTEMS targets.
+
+# Use all.
+
diff -ruN gcc-4.1.orig/gcc/config.gcc gcc-4.1/gcc/config.gcc
--- gcc-4.1.orig/gcc/config.gcc 2011-04-26 11:29:54.000000000 +1000
+++ gcc-4.1/gcc/config.gcc 2011-08-06 10:24:23.000000000 +1000
@@ -1447,6 +1447,10 @@
thread_file='posix'
fi
;;
+nios2-*-rtems*)
+ tm_file=" elfos.h ${tm_file} dbxelf.h nios2/rtems.h rtems.h"
+ tmake_file="${tmake_file} nios2/t-nios2 t-rtems nios2/t-rtems"
+ ;;
nios2*-*-*)
tm_file="elfos.h ${tm_file}"
tmake_file="${tmake_file} nios2/t-nios2"
diff -ruN gcc-4.1.orig/libiberty/strsignal.c gcc-4.1/libiberty/strsignal.c
--- gcc-4.1.orig/libiberty/strsignal.c 2011-04-26 11:30:12.000000000 +1000
+++ gcc-4.1/libiberty/strsignal.c 2011-08-06 10:24:23.000000000 +1000
@@ -404,10 +404,10 @@
#ifndef HAVE_STRSIGNAL
-const char *
+char *
strsignal (int signo)
{
- const char *msg;
+ char *msg;
static char buf[32];
#ifndef HAVE_SYS_SIGLIST
@@ -428,12 +428,12 @@
{
/* In range, but no sys_siglist or no entry at this index. */
sprintf (buf, "Signal %d", signo);
- msg = (const char *) buf;
+ msg = buf;
}
else
{
/* In range, and a valid message. Just return the message. */
- msg = (const char *) sys_siglist[signo];
+ msg = (char *) sys_siglist[signo];
}
return (msg);
@@ -549,7 +549,7 @@
#ifndef HAVE_PSIGNAL
void
-psignal (unsigned signo, char *message)
+psignal (int signo, const char *message)
{
if (signal_names == NULL)
{

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,10 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
#
# Source
#
Source0: ftp://ftp.gnu.org/gnu/binutils/binutils-%{binutils_version}.tar.bz2
VersionControl0: cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils
%ifn %{defined Source0}
Source0: ftp://ftp.gnu.org/gnu/binutils/binutils-%{binutils_version}.tar.bz2
VersionControl0: cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils
%endif
#
# Prepare the source code.
@ -33,8 +35,11 @@ cd ..
export PATH="%{_bindir}:${PATH}"
mkdir -p build
cd build
%if %{host_force_32bit} == %{nil}
HOST_FORCE_32BIT="-m32"
%endif
%if "%{_build}" != "%{_host}"
CFLAGS_FOR_BUILD="-g -O2 -Wall" \
CFLAGS_FOR_BUILD="-g -O2 -Wall ${HOST_FORCE_32BIT}" \
%endif
CFLAGS="$SB_OPT_FLAGS" \
../binutils-%{binutils_version}/configure \

View File

@ -16,8 +16,10 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
#
# Source
#
Source0: http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.bz2
VersionControl0 git clone git://sourceware.org/git/gdb.git
%ifn %{defined Source0}
Source0: http://ftp.gnu.org/gnu/gdb/gdb-%{gdb_version}.tar.bz2
VersionControl0 git clone git://sourceware.org/git/gdb.git
%endif
#
# Prepare the source code.