tool_chain: cleanup

Fixes #1517
This commit is contained in:
Christian Prochaska 2015-05-11 17:55:26 +02:00 committed by Christian Helmuth
parent ebcfc28a5b
commit 2706e4cd75
29 changed files with 455 additions and 1102 deletions

View File

@ -1,28 +0,0 @@
#
# Support for using standard C++ headers for Genode programs
#
#
# Add the location of the compiler's C++ headers to search path
#
# We add all header locations that have "c++" or "include-fixed" to the search
# path. The 'c++' subdirectory contains the actual standard C++ headers.
# However, for using them together with Boost, we need to access 'limits.h' as
# provided within the 'include-fixed' location.
#
INC_DIR += $(shell echo "int main() {return 0;}" |\
LANG=C $(CXX) -x c++ -v -E - 2>&1 |\
sed '/^\#include <\.\.\.> search starts here:/,/^End of search list/!d' |\
grep "c++")
# avoid multiple definition of type _mbstate_t
CC_CXX_OPT += -D_GLIBCXX_HAVE_MBSTATE_T
#
# Link libstdc++ that comes with the tool chain
#
ifneq ($(filter hardening_tool_chain, $(SPECS)),)
EXT_OBJECTS += $(shell $(CUSTOM_CXX_LIB) $(CC_MARCH) -print-file-name=libstdc++.so)
else
EXT_OBJECTS += $(shell $(CUSTOM_CXX_LIB) $(CC_MARCH) -print-file-name=libstdc++.a)
endif

View File

@ -1,7 +0,0 @@
#
# This is a pseudo library for letting programs use stdc++ headers by adding
# 'stdcxx' to the 'LIBS' declaration. The actual support for incorporating
# the C++ standard library resides in 'lib/import/import-stdcxx.mk'. This
# file merely exists to resolve the build dependency to the 'stdcxx' library
# description file.
#

View File

@ -69,17 +69,17 @@ NOUX_BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [$(NOUX_PKG)] /"
endif
ifeq ($(findstring arm, $(SPECS)), arm)
NOUX_CONFIGURE_ARGS += --host arm-elf-eabi
NOUX_CONFIGURE_ARGS += --host arm-none-eabi
else
ifeq ($(findstring x86, $(SPECS)), x86)
NOUX_CONFIGURE_ARGS += --host x86_64-elf
NOUX_CONFIGURE_ARGS += --host x86_64-pc-elf
endif
endif
NOUX_CONFIGURE_ARGS += --srcdir=$(NOUX_PKG_DIR)
NOUX_CONFIGURE_ARGS += --prefix /
CONFIG_GUESS_SCRIPT = $(NOUX_PKG_DIR)/config.guess)
CONFIG_GUESS_SCRIPT = $(NOUX_PKG_DIR)/config.guess
ifneq ($(wildcard $(CONFIG_GUESS_SCRIPT)),)
NOUX_CONFIGURE_ARGS += --build $(shell $(CONFIG_GUESS_SCRIPT))
else
@ -97,9 +97,13 @@ LIBGCC = $(shell $(CC) $(CC_MARCH) -print-libgcc-file-name)
NOUX_CPPFLAGS += -nostdinc $(INCLUDES)
NOUX_CPPFLAGS += -D_GNU_SOURCE=1
NOUX_CPPFLAGS += $(CC_MARCH)
NOUX_CFLAGS += -ffunction-sections $(CC_OLEVEL) -nostdlib $(NOUX_CPPFLAGS)
NOUX_CFLAGS += -g
# flags to be used in both CFLAGS and CXXFLAGS
NOUX_COMMON_CFLAGS_CXXFLAGS += -ffunction-sections $(CC_OLEVEL) $(CC_MARCH)
NOUX_COMMON_CFLAGS_CXXFLAGS += -g
NOUX_CFLAGS += $(NOUX_COMMON_CFLAGS_CXXFLAGS)
NOUX_CXXFLAGS += $(NOUX_COMMON_CFLAGS_CXXFLAGS)
#
# We have to specify 'LINK_ITEMS' twice to resolve inter-library dependencies.
@ -111,14 +115,6 @@ NOUX_LIBS_A = $(filter %.a, $(sort $(LINK_ITEMS)) $(EXT_OBJECTS) $(LIBGCC))
NOUX_LIBS_SO = $(filter %.so,$(sort $(LINK_ITEMS)) $(EXT_OBJECTS) $(LIBGCC))
NOUX_LIBS += $(NOUX_LIBS_A) $(NOUX_LIBS_SO) $(NOUX_LIBS_A)
NOUX_ENV += CC='$(CC)' CXX='$(CXX)' LD='$(LD)' AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' STRIP='$(STRIP)' LIBS='$(NOUX_LIBS)' \
LDFLAGS='$(NOUX_LDFLAGS)' CFLAGS='$(NOUX_CFLAGS)' \
CPPFLAGS='$(NOUX_CPPFLAGS)' CXXFLAGS='$(NOUX_CXXFLAGS)'
NOUX_ENV += CC_FOR_BUILD=gcc LD_FOR_BUILD=ld \
CFLAGS_FOR_BUILD='$(NOUX_CFLAGS_FOR_BUILD)' \
CPPFLAGS_FOR_BUILD='' LDFLAGS_FOR_BUILD=''
#
# Re-configure the Makefile if the Genode build environment changes
#
@ -145,18 +141,6 @@ noux_env.sh:
$(VERBOSE)echo "export CXXFLAGS='$(NOUX_CXXFLAGS)'" >> $@
$(VERBOSE)echo "export LDFLAGS='$(NOUX_LDFLAGS)'" >> $@
$(VERBOSE)echo "export LIBS='$(NOUX_LIBS)'" >> $@
$(VERBOSE)echo "export CC_FOR_TARGET='$(CC)'" >> $@
$(VERBOSE)echo "export CXX_FOR_TARGET='$(CXX)'" >> $@
$(VERBOSE)echo "export GCC_FOR_TARGET='$(CC)'" >> $@
$(VERBOSE)echo "export LD_FOR_TARGET='$(LD)'" >> $@
$(VERBOSE)echo "export AS_FOR_TARGET='$(AS)'" >> $@
$(VERBOSE)echo "export AR_FOR_TARGET='$(AR)'" >> $@
$(VERBOSE)echo "export LDFLAGS_FOR_TARGET='$(NOUX_LDFLAGS)'" >> $@
$(VERBOSE)echo "export LIBS_FOR_TARGET='$(NOUX_LIBS)'" >> $@
$(VERBOSE)echo "export CFLAGS_FOR_BUILD='$(NOUX_CFLAGS_FOR_BUILD)'" >> $@
$(VERBOSE)echo "export CPPFLAGS_FOR_BUILD=''" >> $@
$(VERBOSE)echo "export LDFLAGS_FOR_BUILD=''" >> $@
$(VERBOSE)echo "export LIBS_FOR_BUILD=''" >> $@
$(VERBOSE)echo "export LIBTOOLFLAGS='$(NOUX_LIBTOOLFLAGS)'" >> $@
$(VERBOSE)echo "export PS1='<noux>'" >> $@

View File

@ -1 +1 @@
920639d7e58d1b0a2a04f727f77b9a6f48806bfc
d396d536dec018b4199b12437f1e9d563b4330d0

View File

@ -1 +1 @@
7ec276c84890127c9d72a17fd6bbd7df372131c7
3952072999371f80ec126fcf842ab167c19cad66

View File

@ -1,4 +1,4 @@
PROGRAM_PREFIX = genode-arm-
BINUTILS_TARGET = arm-elf-eabi
BINUTILS_TARGET = arm-none-eabi
include $(PRG_DIR)/../binutils/target.inc

View File

@ -1,4 +1,4 @@
PROGRAM_PREFIX = genode-x86-
BINUTILS_TARGET = x86_64-elf
BINUTILS_TARGET = x86_64-pc-elf
include $(PRG_DIR)/../binutils/target.inc

View File

@ -9,8 +9,9 @@ From: Christian Prochaska <christian.prochaska@genode-labs.com>
fixincludes/Makefile.in | 4 ++--
gcc/Makefile.in | 6 +++---
gcc/configure.ac | 1 +
gcc/gengtype-lex.c | 1 -
libgcc/Makefile.in | 2 +-
6 files changed, 14 insertions(+), 6 deletions(-)
7 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/Makefile.def b/Makefile.def
index ae2689d..2569010 100644
@ -81,10 +82,10 @@ index b9857b9..0229f70 100644
$(AF): $(FIXOBJ) $(LIBIBERTY)
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 5c3514d..9345bc3 100644
index f3cc49f..6baecb8 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -745,7 +745,7 @@ BUILD_LINKERFLAGS = $(BUILD_CFLAGS)
@@ -760,7 +760,7 @@ BUILD_LINKERFLAGS = $(BUILD_CFLAGS)
# Native linker and preprocessor flags. For x-fragment overrides.
BUILD_LDFLAGS=@BUILD_LDFLAGS@
@ -93,7 +94,7 @@ index 5c3514d..9345bc3 100644
# Actual name to use when installing a native compiler.
GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
@@ -1015,8 +1015,8 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
@@ -1030,8 +1030,8 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
# How to link with both our special library facilities
# and the system's installed libraries.
@ -105,10 +106,10 @@ index 5c3514d..9345bc3 100644
$(ZLIB)
# Any system libraries needed just for GNAT.
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 75bb2b5..1cb2b05 100644
index a78a1d7..5baf340 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1514,6 +1514,7 @@ else
@@ -1540,6 +1540,7 @@ else
saved_CFLAGS="${CFLAGS}"
CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
LDFLAGS="${LDFLAGS_FOR_BUILD}" \
@ -116,11 +117,20 @@ index 75bb2b5..1cb2b05 100644
${realsrcdir}/configure \
--enable-languages=${enable_languages-all} \
--target=$target_alias --host=$build_alias --build=$build_alias
diff --git a/gcc/gengtype-lex.c b/gcc/gengtype-lex.c
index 39d6357..731de55 100644
--- a/gcc/gengtype-lex.c
+++ b/gcc/gengtype-lex.c
@@ -1,4 +1,3 @@
-#include "bconfig.h"
#line 2 "gengtype-lex.c"
#line 4 "gengtype-lex.c"
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index d64c9e0..adae105 100644
index a2cb98f..84b34c7 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -224,7 +224,7 @@ endif
@@ -225,7 +225,7 @@ endif
LIBGCC2_DEBUG_CFLAGS = -g
LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
$(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \

View File

@ -4,31 +4,20 @@ NOUX_PKG_DIR = $(call select_from_ports,gcc)/src/noux-pkg/gcc
NOUX_CONFIGURE_ARGS = --program-prefix=$(PROGRAM_PREFIX) \
--target=$(GCC_TARGET) \
--with-gnu-as --with-gnu-ld --disable-tls --disable-threads --disable-lto \
--disable-multilib --disable-sjlj-exceptions --enable-languages=c,c++
#
# Configure options passed to gcc
#
# The 't-linux' tmake file is needed to let the tool chain use 'unwind-dw2-fde-glibc',
# needed for the exception handling on Genode in the presence of shared libraries.
#
HOST_CONFIG_ARGS = host_xm_include_list=$(LINK_SPEC_H_$(PLATFORM)) \
tmake_file='t-slibgcc'
#
# Passed to target components such as libgcc, libstdc++
#
# The 't-slibgcc' tmake file is needed to have libgcc_eh.a built.
# The 't-eh-dw2-dip' tmake file is needed to let the tool chain use 'unwind-dw2-fde-dip.c',
# needed for the exception handling on Genode in the presence of shared libraries.
#
TARGET_CONFIG_ARGS = tmake_file='t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver' \
extra_parts='crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o'
# compile libsupc++ as position-independent code
TARGET_CONFIG_ARGS += PIC_CXXFLAGS='-prefer-pic'
--enable-languages=c,c++ \
--disable-libgo \
--disable-libssp \
--disable-libquadmath \
--disable-libffi \
--enable-targets=all \
--with-gnu-as \
--with-gnu-ld \
--disable-tls \
--disable-threads \
--disable-hosted-libstdcxx \
--enable-shared \
--enable-multiarch \
--disable-sjlj-exceptions
NOUX_ENV += host_configargs="$(HOST_CONFIG_ARGS)" \
target_configargs="$(TARGET_CONFIG_ARGS)"
@ -36,14 +25,13 @@ NOUX_ENV += host_configargs="$(HOST_CONFIG_ARGS)" \
NOUX_ENV += CC_FOR_TARGET=$(CC) CXX_FOR_TARGET=$(CXX) GCC_FOR_TARGET=$(CC) CPP_FOR_TARGET="$(CC) -E" \
LD_FOR_TARGET=$(LD) AS_FOR_TARGET=$(AS) AR_FOR_TARGET=$(AR)
#
# Need to specify LDFLAGS_FOR_TARGET as configure argument, not just as
# environment variable. Otherwise, the generated Makefile will set 'LDFLAGS_FOR_TARGET'
# to empty, target libraries will fail to build.
#
NOUX_ENV += LDFLAGS_FOR_TARGET='$(NOUX_LDFLAGS)'
NOUX_ENV += CPPFLAGS_FOR_TARGET='$(NOUX_CPPFLAGS)'
NOUX_ENV += CXXFLAGS_FOR_TARGET='$(NOUX_CXXFLAGS)'
# libgcc does not evaluate CPPFLAGS_FOR_TARGET, so everything is put into CFLAGS_FOR_TARGET here
NOUX_ENV += CFLAGS_FOR_TARGET='-I$(BASE_DIR)/../../tool -DUSE_PT_GNU_EH_FRAME -Dinhibit_libc -fPIC'
# libsupc++
NOUX_ENV += CXXFLAGS_FOR_TARGET='-fPIC'
NOUX_MAKE_ENV += MULTILIB_OPTIONS="m64/m32" MULTILIB_DIRNAMES="64 32"
#
# We link libraries to the final binaries using the 'LIBS' variable. But
@ -67,8 +55,6 @@ LIBS += libc libm libc_noux
include $(REP_DIR)/mk/noux.mk
NOUX_CXXFLAGS += -ffunction-sections $(CC_OLEVEL) -nostdlib $(NOUX_CPPFLAGS)
#
# We have to specify 'LINK_ITEMS' twice to resolve inter-library dependencies.
# Unfortunately, the use of '--start-group' and '--end-group' does not suffice

View File

@ -1,5 +1,5 @@
PROGRAM_PREFIX = genode-arm-
GCC_TARGET = arm-elf-eabi
GCC_TARGET = arm-none-eabi
# cross-compiling does not work yet
REQUIRES = arm

View File

@ -1,5 +1,5 @@
PROGRAM_PREFIX = genode-x86-
GCC_TARGET = x86_64-elf
GCC_TARGET = x86_64-pc-elf
# cross-compiling does not work yet
REQUIRES = x86

View File

@ -1,7 +1,8 @@
diff --git a/gdb/configure b/gdb/configure
index 30e5e45..9c5ed7f 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -7917,11 +7917,11 @@
@@ -7917,11 +7917,11 @@ fi
# configuration.
gdb_host_obs=posix-hdep.o
@ -17,7 +18,7 @@ diff --git a/gdb/configure b/gdb/configure
. $srcdir/configure.host
@@ -12919,7 +12919,7 @@
@@ -12919,7 +12919,7 @@ sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);
return 0;
}
_ACEOF
@ -27,9 +28,10 @@ diff --git a/gdb/configure b/gdb/configure
else
gdb_cv_func_sigsetjmp=no
diff --git a/missing b/missing
index 28055d2..031956f 100755
--- a/missing
+++ b/missing
@@ -314,7 +314,7 @@
@@ -314,7 +314,7 @@ WARNING: \`$1' is $msg. You should only need it if
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
@ -38,3 +40,16 @@ diff --git a/missing b/missing
touch $file
;;
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 351f4a0..9b68c87 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -237,7 +237,7 @@ CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \
-I../../bfd -I$(srcroot)/bfd \
-I../../opcodes -I$(srcroot)/opcodes \
@INCINTL@
-ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
+ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CPPFLAGS) $(CFLAGS)
BUILD_CFLAGS = -g -O $(CSEARCH)
COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH)

View File

@ -5,7 +5,7 @@ NOUX_CONFIGURE_ARGS += --program-prefix=$(PROGRAM_PREFIX) \
# the configure script calls the linker with "-lexpat", which fails
NOUX_CONFIGURE_ARGS += --without-expat
NOUX_CFLAGS += -DHAVE_LIBEXPAT=1
NOUX_CPPFLAGS += -DHAVE_LIBEXPAT=1
LIBS += ncurses expat

View File

@ -1,4 +1,4 @@
PROGRAM_PREFIX = genode-arm-
GDB_TARGET = arm-elf-eabi
GDB_TARGET = arm-none-eabi
include $(PRG_DIR)/../gdb/target.inc

View File

@ -1,4 +1,4 @@
PROGRAM_PREFIX = genode-x86-
GDB_TARGET = x86_64-elf
GDB_TARGET = x86_64-pc-elf
include $(PRG_DIR)/../gdb/target.inc

View File

@ -1,641 +0,0 @@
/*
* \brief Stub for compiling GCC support libraries without libc
* \author Norman Feske
* \date 2011-08-31
*
* The target components of GCC tool chains (i.e. libsupc++, libgcc_eh, and
* libstdc++) depend on the presence of libc includes. For this reason, a C
* library for the target platform is normally regarded as a prerequisite for
* building a complete tool chain. However, for low-level operating-system
* code, this prerequisite is not satisfied.
*
* There are two traditional solutions to this problem. The first is to leave
* out those target components from the tool chain and live without full C++
* support (using '-fno-rtti' and '-fno-exceptions'). Because Genode relies on
* such C++ features however, this is no option. The other traditional solution
* is to use a tool chain compiled for a different target platform such as
* Linux. However, this approach calls for subtle problems because the target
* components are compiled against glibc and make certain presumptions about
* the underlying OS environment. E.g., the 'libstdc++' library of a Linux tool
* chain contains references to glibc's 'stderr' symbol, which does not exist
* on Genode's libc derived from FreeBSD. More critical assumptions are related
* to the mechanism used for thread-local storage.
*
* This header file overcomes these problems by providing all function
* prototypes and type declarations that are mandatory for compiling GCC's
* target components. Using this libc stub, all GCC target components can be
* built without the need for additional libc support. Of course, for actually
* using these target components, the target OS has to provide the
* implementation of a small subset of functions declared herein. On Genode,
* this subset is provided by the 'cxx' library.
*
* The code of the target components expects usual C header file names such as
* 'stdio.h'. It does not include 'libgcc_libc_stub.h'. By creating symlinks
* for all those file names pointing to this file, we ensure that this file is
* always included on the first occurrence of the inclusion of any libc header
* file. The set of symlinks pointing to this libc stub are created
* automatically by the 'tool_chain' script.
*/
/*
* Copyright (C) 2011-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _LIBC_STUB_H_
#define _LIBC_STUB_H_
/* used for vararg, comes with GCC */
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
/*****************
** sys/types.h **
*****************/
typedef __SIZE_TYPE__ size_t;
#ifndef ssize_t
#define ssize_t long /* xxx 64bit */
#endif
typedef unsigned long off_t; /* XXX 64bit */
#define pid_t int
typedef unsigned short mode_t; /* XXX 64bit */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif /* __cplusplus */
#endif /* defined NULL */
typedef long clock_t; /* XXX not on 64bit */
#ifdef _LP64
typedef signed char __int8_t;
typedef signed short __int16_t;
typedef signed int __int32_t;
typedef signed long __int64_t;
typedef unsigned char __uint8_t;
typedef unsigned short __uint16_t;
typedef unsigned int __uint32_t;
typedef unsigned long __uint64_t;
#else /* _LP64 */
typedef signed char __int8_t;
typedef signed short __int16_t;
typedef signed long __int32_t;
typedef unsigned char __uint8_t;
typedef unsigned short __uint16_t;
typedef unsigned long __uint32_t;
#ifndef __STRICT_ANSI__
typedef signed long long __int64_t;
typedef unsigned long long __uint64_t;
#endif /* __STRICT_ANSI__ */
#endif /* _LP64 */
typedef __int64_t intmax_t;
typedef __int32_t int_fast8_t;
typedef __int32_t int_fast16_t;
typedef __int32_t int_fast32_t;
typedef __int64_t int_fast64_t;
typedef __int8_t int_least8_t;
typedef __int16_t int_least16_t;
typedef __int32_t int_least32_t;
typedef __int64_t int_least64_t;
typedef __uint64_t uintmax_t;
#ifdef _LP64
typedef __int64_t time_t;
typedef __int64_t intptr_t;
typedef __uint64_t uintptr_t;
#else
typedef __int32_t time_t;
typedef __int32_t intptr_t;
typedef __uint32_t uintptr_t;
#endif
typedef __uint32_t uint_fast8_t;
typedef __uint32_t uint_fast16_t;
typedef __uint32_t uint_fast32_t;
typedef __uint64_t uint_fast64_t;
typedef __uint8_t uint_least8_t;
typedef __uint16_t uint_least16_t;
typedef __uint32_t uint_least32_t;
typedef __uint64_t uint_least64_t;
struct timeval {
time_t tv_sec;
long tv_usec; /* XXX 64bit */
};
/****************
** sys/stat.h **
****************/
struct stat
{
unsigned long st_dev;
unsigned long st_ino;
unsigned short st_mode;
};
#define S_ISREG(m) (((m) & 0170000) == 0100000)
/************
** time.h **
************/
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
long tm_gmtoff;
char *tm_zone;
};
clock_t clock(void);
double difftime(time_t time1, time_t time0);
struct tm *localtime(const time_t *timep);
char *asctime(const struct tm *tm);
time_t mktime(struct tm *tm);
char *ctime(const time_t *timep);
struct tm *gmtime(const time_t *timep);
time_t time(time_t *t);
size_t strftime(char *s, size_t max, const char *format,
const struct tm *tm);
/**************
** string.h **
**************/
int memcmp(const void *s1, const void *s2, size_t n);
size_t strlen(const char *s);
void *memcpy(void *dest, const void *src, size_t n);
char *strchr(const char *s, int c);
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t n);
void *memchr(const void *s, int c, size_t n);
int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);
void *memset(void *s, int c, size_t n);
size_t strcspn(const char *s, const char *reject);
char *strstr(const char *haystack, const char *needle);
size_t strspn(const char *s, const char *accept);
char *strpbrk(const char *s, const char *accept);
char *strcat(char *dest, const char *src);
char *strncat(char *dest, const char *src, size_t n);
/* for compiling 'libsupc++/del_opvnt.cc' */
void *memmove(void *dest, const void *src, size_t n);
int strcoll(const char *s1, const char *s2);
char *strerror(int errnum);
char *strtok(char *str, const char *delim);
size_t strxfrm(char *dest, const char *src, size_t n);
char *strrchr(const char *s, int c);
/***************
** strings.h **
***************/
void bcopy(const void *src, void *dest, size_t n);
void bzero(void *s, size_t n);
/**************
** stdlib.h **
**************/
void free(void *ptr);
void *realloc(void *ptr, size_t size);
void *malloc(size_t size);
void *calloc(size_t nmemb, size_t size);
void abort(void);
void exit(int);
int atoi(const char *nptr);
void *alloca(size_t size);
/* for compiling 'libsupc++/del_op.cc' */
typedef struct { int quot; int rem; } div_t;
typedef struct { long quot; long rem; } ldiv_t;
int abs(int j);
long int labs(long int j);
double atof(const char *nptr);
long atol(const char *nptr);
div_t div(int numerator, int denominator);
ldiv_t ldiv(long numerator, long denominator);
void qsort(void *base, size_t nmemb, size_t size,
int(*compar)(const void *, const void *));
int rand(void);
void srand(unsigned int seed);
int system(const char *command);
#ifdef _ANSIDECL_H
/* special case provided specifically for compiling libiberty's 'strtod.c' */
double strtod(char *nptr, char **endptr);
#else
double strtod(const char *nptr, char **endptr);
#endif
long int strtol(const char *nptr, char **endptr, int base);
unsigned long int strtoul(const char *nptr, char **endptr, int base);
char *getenv(const char *name);
int atexit(void (*function)(void));
void *bsearch(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
/*************
** stdio.h **
*************/
typedef struct __sFILE { int dummy; } FILE;
extern FILE *__stderrp;
extern FILE *__stdinp;
extern FILE *__stdoutp;
#define stderr __stderrp
#define stdin __stdinp
#define stdout __stdoutp
/* must not be enum values */
#define EOF (-1)
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
enum { _IONBF = 2 };
enum { BUFSIZ = 1024 };
FILE *fopen(const char *path, const char *mode);
int fclose(FILE *fp);
int fprintf(FILE *stream, const char *format, ...);
int fputs(const char *s, FILE *stream);
int sscanf(const char *str, const char *format, ...);
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
int ferror(FILE *stream);
int sprintf(char *str, const char *format, ...);
FILE *fdopen(int fd, const char *mode);
int fileno(FILE *);
/* for compiling 'libsupc++/vterminate.cc' */
typedef off_t fpos_t;
void clearerr(FILE *stream);
int feof(FILE *stream);
int ferror(FILE *stream);
int fflush(FILE *stream);
char *fgets(char *s, int size, FILE *stream);
int fgetc(FILE *stream);
int fgetpos(FILE *stream, fpos_t *pos);
int fsetpos(FILE *stream, fpos_t *pos);
long ftell(FILE *stream);
int fseek(FILE *stream, long offset, int whence);
void rewind(FILE *stream);
int fputc(int c, FILE *stream);
int putchar(int c);
int puts(const char *s);
int putc(int c, FILE *stream);
int rename(const char *oldpath, const char *newpath);
int remove(const char *pathname);
int vprintf(const char *format, va_list ap);
int vfprintf(FILE *stream, const char *format, va_list ap);
int vsprintf(char *str, const char *format, va_list ap);
FILE *freopen(const char *path, const char *mode, FILE *stream);
int fscanf(FILE *stream, const char *format, ...);
int scanf(const char *format, ...);
int getc(FILE *stream);
int getchar(void);
char *gets(char *s);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
void perror(const char *s);
int printf(const char *format, ...);
void setbuf(FILE *stream, char *buf);
int setvbuf(FILE *stream, char *buf, int mode, size_t size);
FILE *tmpfile(void);
char *tmpnam(char *s);
int ungetc(int c, FILE *stream);
/**************
** unistd.h **
**************/
int close(int fd);
ssize_t read(int fd, void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count);
int execv(const char *path, char *const argv[]);
int execvp(const char *file, char *const argv[]);
pid_t fork(void);
int unlink(const char *pathname);
void _exit(int status);
int link(const char *oldpath, const char *newpath);
pid_t getpid(void);
int pipe(int pipefd[2]);
int dup2(int oldfd, int newfd);
pid_t wait(int *status);
unsigned int sleep(unsigned int seconds);
off_t lseek(int fd, off_t offset, int whence);
/*************
** errno.h **
*************/
#define errno (* __error())
int *__error(void);
/**
* Error codes corresponding to those of FreeBSD
*/
enum {
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EXDEV = 18,
EDEADLK = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
EBUSY = 16,
EEXIST = 17,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EPIPE = 32,
EDOM = 33,
ERANGE = 34,
EAGAIN = 35,
EWOULDBLOCK = EAGAIN,
EINPROGRESS = 36,
EALREADY = 37,
ENOTSOCK = 38,
EDESTADDRREQ = 39,
EMLINK = 31,
EMSGSIZE = 40,
EPROTOTYPE = 41,
ENOPROTOOPT = 42,
EPROTONOSUPPORT = 43,
EOPNOTSUPP = 45,
EAFNOSUPPORT = 47,
EADDRINUSE = 48,
EADDRNOTAVAIL = 49,
ENETDOWN = 50,
ENETUNREACH = 51,
ENETRESET = 52,
ECONNABORTED = 53,
ECONNRESET = 54,
ENOBUFS = 55,
EISCONN = 56,
ENOTCONN = 57,
ETIMEDOUT = 60,
ECONNREFUSED = 61,
ELOOP = 62,
ENAMETOOLONG = 63,
EHOSTUNREACH = 65,
ENOTEMPTY = 66,
ENOLCK = 77,
ENOSYS = 78,
ENOMSG = 83,
EILSEQ = 86
};
/*************
** fcntl.h **
*************/
enum {
O_RDONLY = 0x0000,
O_WRONLY = 0x0001,
O_RDWR = 0x0002,
O_CREAT = 0x0200,
O_TRUNC = 0x0400,
O_EXCL = 0x0800
};
enum { F_SETFD = 2 };
enum { FD_CLOEXEC = 1 };
int open(const char *pathname, int flags, ...);
int fcntl(int fd, int cmd, ... /* arg */ );
/**************
** signal.h **
**************/
enum { SIGTERM = 15 };
int kill(pid_t pid, int sig);
/*************
** ctype.h **
*************/
int isalnum(int c);
int isalpha(int c);
int isascii(int c);
int isblank(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int toupper(int c);
int tolower(int c);
/**************
** locale.h **
**************/
struct lconv;
char *setlocale(int category, const char *locale);
struct lconv *localeconv(void);
enum {
LC_ALL = 0,
LC_COLLATE = 1,
LC_CTYPE = 2,
LC_MONETARY = 3,
LC_NUMERIC = 4,
LC_TIME = 5
};
/************
** math.h **
************/
double acos(double x);
double asin(double x);
double atan(double x);
double atan2(double y, double x);
double ceil(double x);
double cos(double x);
double cosh(double x);
double exp(double x);
double fabs(double x);
double floor(double x);
double fmod(double x, double y);
double frexp(double x, int *exp);
double ldexp(double x, int exp);
double log(double x);
double log10(double x);
double modf(double x, double *iptr);
double pow(double x, double y);
double sin(double x);
double sinh(double x);
double sqrt(double x);
double tan(double x);
double tanh(double x);
/**************
** assert.h **
**************/
#define assert(e) ((void)0)
/***********
** elf.h **
***********/
/*
* The following defines and types are solely needed to compile libgcc's
* 'unwind-dw2-fde-glibc.c' in libc mode. This is needed because Genode's
* dynamic linker relies on the the "new" exception mechanism, which is not
* compiled-in when compiling libgcc with the 'inhibit_libc' flag.
*
* The following types are loosely based on glibc's 'link.h' and 'elf.h'.
*/
typedef __uint32_t Elf64_Word;
typedef __uint64_t Elf64_Addr;
typedef __uint64_t Elf64_Xword;
typedef __uint64_t Elf64_Off;
typedef __uint16_t Elf64_Half;
typedef struct
{
Elf64_Word p_type;
Elf64_Word p_flags;
Elf64_Off p_offset;
Elf64_Addr p_vaddr;
Elf64_Addr p_paddr;
Elf64_Xword p_filesz;
Elf64_Xword p_memsz;
Elf64_Xword p_align;
} Elf64_Phdr;
typedef __uint32_t Elf32_Word;
typedef __uint32_t Elf32_Addr;
typedef __uint64_t Elf32_Xword;
typedef __uint32_t Elf32_Off;
typedef __uint16_t Elf32_Half;
typedef struct
{
Elf32_Word p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
Elf32_Addr p_paddr;
Elf32_Word p_filesz;
Elf32_Word p_memsz;
Elf32_Word p_flags;
Elf32_Word p_align;
} Elf32_Phdr;
#define PT_LOAD 1
#define PT_DYNAMIC 2
#define PT_LOOS 0x60000000
/************
** link.h **
************/
/* definitions according to glibc */
#ifdef _LP64
#define ElfW(type) Elf64_##type
#else
#define ElfW(type) Elf32_##type
#endif /* _LP64 */
struct dl_phdr_info
{
ElfW(Addr) dlpi_addr;
const char *dlpi_name;
const ElfW(Phdr) *dlpi_phdr;
ElfW(Half) dlpi_phnum;
unsigned long long int dlpi_adds;
unsigned long long int dlpi_subs;
size_t dlpi_tls_modid;
void *dlpi_tls_data;
};
extern int dl_iterate_phdr(int (*__callback) (struct dl_phdr_info *,
size_t, void *), void *__data);
/****************
** features.h **
****************/
/* let check at the beginning of 'gcc/unwind-dw2-fde-glibc.c' pass */
#define __GLIBC__ 99
#ifdef __cplusplus
}
#endif
#endif /* _LIBC_STUB_H_ */

158
tool/link.h Normal file
View File

@ -0,0 +1,158 @@
/*
* \brief Stub for compiling GCC support libraries without libc
* \author Norman Feske
* \date 2011-08-31
*
* The target components of GCC tool chains (i.e. libsupc++, libgcc_eh, and
* libstdc++) depend on the presence of libc includes. For this reason, a C
* library for the target platform is normally regarded as a prerequisite for
* building a complete tool chain. However, for low-level operating-system
* code, this prerequisite is not satisfied.
*
* There are two traditional solutions to this problem. The first is to leave
* out those target components from the tool chain and live without full C++
* support (using '-fno-rtti' and '-fno-exceptions'). Because Genode relies on
* such C++ features however, this is no option. The other traditional solution
* is to use a tool chain compiled for a different target platform such as
* Linux. However, this approach calls for subtle problems because the target
* components are compiled against glibc and make certain presumptions about
* the underlying OS environment. E.g., the 'libstdc++' library of a Linux tool
* chain contains references to glibc's 'stderr' symbol, which does not exist
* on Genode's libc derived from FreeBSD. More critical assumptions are related
* to the mechanism used for thread-local storage.
*
* This header file overcomes these problems by providing all function
* prototypes and type declarations that are mandatory for compiling GCC's
* target components. Using this libc stub, all GCC target components can be
* built without the need for additional libc support. Of course, for actually
* using these target components, the target OS has to provide the
* implementation of a small subset of functions declared herein. On Genode,
* this subset is provided by the 'cxx' library.
*
* The code of the target components expects usual C header file names such as
* 'stdio.h'. It does not include 'libgcc_libc_stub.h'. By creating symlinks
* for all those file names pointing to this file, we ensure that this file is
* always included on the first occurrence of the inclusion of any libc header
* file. The set of symlinks pointing to this libc stub are created
* automatically by the 'tool_chain' script.
*/
/*
* Copyright (C) 2011-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _LINK_H_
#define _LINK_H_
#include <stddef.h>
/*****************
** sys/types.h **
*****************/
#ifdef _LP64
typedef signed char __int8_t;
typedef signed short __int16_t;
typedef signed int __int32_t;
typedef signed long __int64_t;
typedef unsigned char __uint8_t;
typedef unsigned short __uint16_t;
typedef unsigned int __uint32_t;
typedef unsigned long __uint64_t;
#else /* _LP64 */
typedef signed char __int8_t;
typedef signed short __int16_t;
typedef signed long __int32_t;
typedef unsigned char __uint8_t;
typedef unsigned short __uint16_t;
typedef unsigned long __uint32_t;
#ifndef __STRICT_ANSI__
typedef signed long long __int64_t;
typedef unsigned long long __uint64_t;
#endif /* __STRICT_ANSI__ */
#endif /* _LP64 */
/***********
** elf.h **
***********/
/*
* The following defines and types are solely needed to compile libgcc's
* 'unwind-dw2-fde-glibc.c' in libc mode. This is needed because Genode's
* dynamic linker relies on the the "new" exception mechanism, which is not
* compiled-in when compiling libgcc with the 'inhibit_libc' flag.
*
* The following types are loosely based on glibc's 'link.h' and 'elf.h'.
*/
typedef __uint32_t Elf64_Word;
typedef __uint64_t Elf64_Addr;
typedef __uint64_t Elf64_Xword;
typedef __uint64_t Elf64_Off;
typedef __uint16_t Elf64_Half;
typedef struct
{
Elf64_Word p_type;
Elf64_Word p_flags;
Elf64_Off p_offset;
Elf64_Addr p_vaddr;
Elf64_Addr p_paddr;
Elf64_Xword p_filesz;
Elf64_Xword p_memsz;
Elf64_Xword p_align;
} Elf64_Phdr;
typedef __uint32_t Elf32_Word;
typedef __uint32_t Elf32_Addr;
typedef __uint64_t Elf32_Xword;
typedef __uint32_t Elf32_Off;
typedef __uint16_t Elf32_Half;
typedef struct
{
Elf32_Word p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
Elf32_Addr p_paddr;
Elf32_Word p_filesz;
Elf32_Word p_memsz;
Elf32_Word p_flags;
Elf32_Word p_align;
} Elf32_Phdr;
#define PT_LOAD 1
#define PT_DYNAMIC 2
#define PT_LOOS 0x60000000
/************
** link.h **
************/
/* definitions according to glibc */
#ifdef _LP64
#define ElfW(type) Elf64_##type
#else
#define ElfW(type) Elf32_##type
#endif /* _LP64 */
struct dl_phdr_info
{
ElfW(Addr) dlpi_addr;
const char *dlpi_name;
const ElfW(Phdr) *dlpi_phdr;
ElfW(Half) dlpi_phnum;
unsigned long long int dlpi_adds;
unsigned long long int dlpi_subs;
size_t dlpi_tls_modid;
void *dlpi_tls_data;
};
extern int dl_iterate_phdr(int (*__callback) (struct dl_phdr_info *,
size_t, void *), void *__data);
#endif /* _LINK_H_ */

View File

@ -0,0 +1,123 @@
config.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
---
gcc/config.gcc | 4 ++--
gcc/config/arm/unknown-elf.h | 16 ++++++++++++++++
gcc/config/i386/x86-64.h | 19 +++++++++++++++++++
libgcc/config.host | 12 ++++++++++--
4 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 9503b96..b8d6ce1 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -914,7 +914,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
case ${target} in
arm*-*-eabi*)
tm_file="$tm_file newlib-stdint.h"
- tmake_file="${tmake_file} arm/t-bpabi"
+ tmake_file="${tmake_file} arm/t-bpabi t-slibgcc"
use_gcc_stdint=wrap
;;
arm*-*-rtems*)
@@ -2641,7 +2641,7 @@ i[34567]86-*-linux* | x86_64-*-linux*)
tmake_file="${tmake_file} i386/t-pmm_malloc i386/t-i386"
;;
i[34567]86-*-* | x86_64-*-*)
- tmake_file="${tmake_file} i386/t-gmm_malloc i386/t-i386"
+ tmake_file="${tmake_file} i386/t-gmm_malloc i386/t-i386 t-slibgcc"
;;
powerpc*-*-* | rs6000-*-*)
tm_file="${tm_file} rs6000/option-defaults.h"
diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h
index d5df624..6766c5f 100644
--- a/gcc/config/arm/unknown-elf.h
+++ b/gcc/config/arm/unknown-elf.h
@@ -95,3 +95,19 @@
which will depend on abort, which is defined in libc. */
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %L --end-group"
+
+/* genode.h */
+
+/*
+ * The 'LINK_SPEC' define comprises the rules of how the GCC frontend invokes
+ * the linker.
+ */
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "%(shared:-shared) \
+ %{!static:--eh-frame-hdr}"
+
+/* Don't assume anything about the header files. */
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57699 */
+#define NO_IMPLICIT_EXTERN_C
diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h
index d20f326..0cc4dd0 100644
--- a/gcc/config/i386/x86-64.h
+++ b/gcc/config/i386/x86-64.h
@@ -104,3 +104,22 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#undef TARGET_ASM_UNIQUE_SECTION
#define TARGET_ASM_UNIQUE_SECTION x86_64_elf_unique_section
+
+/* genode64.h */
+
+/*
+ * The 'LINK_SPEC' macro expresses the policy of how the GCC
+ * frontend invokes 'ld' on multiarch platforms. I.e., on x86, we need to pass
+ * '-melf_i386' to 'ld' when building in '-m32' mode.
+ */
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "%{!m32:-m elf_x86_64} \
+ %{m32:-m elf_i386} \
+ %{shared:-shared} \
+ %{!static:--eh-frame-hdr}"
+
+/* Don't assume anything about the header files. */
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57699 */
+#define NO_IMPLICIT_EXTERN_C
diff --git a/libgcc/config.host b/libgcc/config.host
index b64da4a..096d5b6 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -261,7 +261,7 @@ case ${host} in
tmake_file=t-vxworks
;;
*-*-elf)
- extra_parts="crtbegin.o crtend.o"
+ extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
;;
esac
@@ -363,8 +363,12 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
tm_file="$tm_file arm/bpabi-lib.h"
case ${host} in
arm*-*-eabi* | arm*-*-rtems*)
+ # The 't-slibgcc' tmake file is needed to have libgcc_eh.a built.
+ # The 't-eh-dw2-dip' tmake file is needed to let the tool chain use 'unwind-dw2-fde-dip.c',
+ # needed for the exception handling on Genode in the presence of shared libraries.
+ tmake_file="${tmake_file} t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver"
tmake_file="${tmake_file} arm/t-bpabi"
- extra_parts="crtbegin.o crtend.o crti.o crtn.o"
+ extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
;;
arm*-*-symbianelf*)
tmake_file="${tmake_file} arm/t-symbian t-slibgcc-nolc-override"
@@ -524,6 +528,10 @@ i[34567]86-*-elf*)
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
;;
x86_64-*-elf*)
+ # The 't-slibgcc' tmake file is needed to have libgcc_eh.a built.
+ # The 't-eh-dw2-dip' tmake file is needed to let the tool chain use 'unwind-dw2-fde-dip.c',
+ # needed for the exception handling on Genode in the presence of shared libraries.
+ tmake_file="$tmake_file t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver"
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
;;
i[34567]86-*-freebsd*)

View File

@ -1,65 +0,0 @@
cpp_for_target.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
Fix the handling of CPP_FOR_TARGET. Without the fix, the configure script
of libgcc tries to use the normal 'cpp' for executing preprocessor tests,
which produces bogus results.
---
Makefile.def | 1 +
Makefile.tpl | 3 +++
configure.ac | 1 +
3 files changed, 5 insertions(+)
diff --git a/Makefile.def b/Makefile.def
index 1838a21..ae2689d 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -242,6 +242,7 @@ flags_to_pass = { flag= GNATMAKE ; };
// Target tools
flags_to_pass = { flag= AR_FOR_TARGET ; };
flags_to_pass = { flag= AS_FOR_TARGET ; };
+flags_to_pass = { flag= CPP_FOR_TARGET ; };
flags_to_pass = { flag= CC_FOR_TARGET ; };
flags_to_pass = { flag= CFLAGS_FOR_TARGET ; };
flags_to_pass = { flag= CPPFLAGS_FOR_TARGET ; };
diff --git a/Makefile.tpl b/Makefile.tpl
index 5cbd6e6..685756c 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -275,6 +275,7 @@ BASE_TARGET_EXPORTS = \
$(BASE_EXPORTS) \
AR="$(AR_FOR_TARGET)"; export AR; \
AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
+ CPP="$(CPP_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CPP; \
CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
@@ -478,6 +479,7 @@ do-compare3 = $(do-compare)
AR_FOR_TARGET=@AR_FOR_TARGET@
AS_FOR_TARGET=@AS_FOR_TARGET@
+CPP_FOR_TARGET=$(STAGE_CC_WRAPPER) @CPP_FOR_TARGET@
CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@
# If GCC_FOR_TARGET is not overriden on the command line, then this
@@ -643,6 +645,7 @@ POSTSTAGE1_FLAGS_TO_PASS = \
EXTRA_TARGET_FLAGS = \
'AR=$$(AR_FOR_TARGET)' \
'AS=$(COMPILER_AS_FOR_TARGET)' \
+ 'CPP=$$(CPP_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
'CC=$$(CC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
'CFLAGS=$$(CFLAGS_FOR_TARGET)' \
'CXX=$$(CXX_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \
diff --git a/configure.ac b/configure.ac
index a44a000..b763e18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3114,6 +3114,7 @@ RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET"
GCC_TARGET_TOOL(ar, AR_FOR_TARGET, AR, [binutils/ar])
GCC_TARGET_TOOL(as, AS_FOR_TARGET, AS, [gas/as-new])
+GCC_TARGET_TOOL(cpp, CPP_FOR_TARGET, CPP, [gcc/cpp -B$$r/$(HOST_SUBDIR)/gcc/])
GCC_TARGET_TOOL(cc, CC_FOR_TARGET, CC, [gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/])
dnl see comments for CXX_FOR_TARGET_FLAG_TO_PASS
GCC_TARGET_TOOL(c++, CXX_FOR_TARGET, CXX,

View File

@ -1,35 +0,0 @@
cppflags_for_target.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
Allow customization of CPPFLAGS_FOR_TARGET, not supported by the original
GCC config and build system.
---
Makefile.tpl | 1 +
configure.ac | 1 +
2 files changed, 2 insertions(+)
diff --git a/Makefile.tpl b/Makefile.tpl
index 371c3b6..5cbd6e6 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -507,6 +507,7 @@ COMPILER_LD_FOR_TARGET=@COMPILER_LD_FOR_TARGET@
COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_TARGET@
CFLAGS_FOR_TARGET = @CFLAGS_FOR_TARGET@
+CPPFLAGS_FOR_TARGET = @CPPFLAGS_FOR_TARGET@
CXXFLAGS_FOR_TARGET = @CXXFLAGS_FOR_TARGET@
LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
diff --git a/configure.ac b/configure.ac
index 40aeeee..a44a000 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2142,6 +2142,7 @@ if test "x$CFLAGS_FOR_TARGET" = x; then
*) CFLAGS_FOR_TARGET="-g $CFLAGS" ;;
esac
fi
+AC_SUBST(CPPFLAGS_FOR_TARGET)
AC_SUBST(CFLAGS_FOR_TARGET)
if test "x$CXXFLAGS_FOR_TARGET" = x; then

View File

@ -1,25 +0,0 @@
inhibit_libc.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
Make sure to disable the 'inhibit_libc' flag, which is evaluated when
compiling libgcc. When libc is inhibited, the 'unwind-dw2-fde-glibc.c'
is not using the "new" glibc exception handling mechanism. However,
Genode's dynamic linker relies on this mechanism.
---
gcc/configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 29ac2f3..67db551 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1888,7 +1888,7 @@ fi
if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
test x$with_newlib = xyes ; } &&
{ test "x$with_headers" = x || test "x$with_headers" = xno ; } ; then
- inhibit_libc=true
+ inhibit_libc=false # was true
fi
AC_SUBST(inhibit_libc)

View File

@ -0,0 +1,33 @@
libgcc_s.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
---
libgcc/Makefile.in | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index 9f45475..a2cb98f 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -893,7 +893,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT)
endif
ifeq ($(enable_shared),yes)
-all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
+all: libgcc_eh.a
ifneq ($(LIBUNWIND),)
all: libunwind$(SHLIB_EXT)
endif
@@ -1060,10 +1060,6 @@ install-shared:
chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
- $(subst @multilib_dir@,$(MULTIDIR),$(subst \
- @shlib_base_name@,libgcc_s,$(subst \
- @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
-
install-leaf: $(install-shared) $(install-libunwind)
$(mkinstalldirs) $(DESTDIR)$(inst_libdir)

View File

@ -0,0 +1,44 @@
stdcxx_without_libc.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
---
libstdc++-v3/configure.ac | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 59024f2..5245cdd 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -89,9 +89,9 @@ CXXFLAGS="$save_CXXFLAGS"
GLIBCXX_CONFIGURE
# Libtool setup.
-if test "x${with_newlib}" != "xyes"; then
- AC_LIBTOOL_DLOPEN
-fi
+#if test "x${with_newlib}" != "xyes"; then
+# AC_LIBTOOL_DLOPEN
+#fi
AM_PROG_LIBTOOL
ACX_LT_HOST_FLAGS
AC_SUBST(enable_shared)
@@ -191,7 +191,7 @@ GLIBCXX_CHECK_WRITEV
GLIBCXX_CHECK_C99_TR1
# For the EOF, SEEK_CUR, and SEEK_END integer constants.
-GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS
+#GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS
# For gettimeofday support.
GLIBCXX_CHECK_GETTIMEOFDAY
@@ -339,7 +339,7 @@ GCC_CHECK_UNWIND_GETIPINFO
GCC_LINUX_FUTEX([AC_DEFINE(HAVE_LINUX_FUTEX, 1, [Define if futex syscall is available.])])
-GCC_HEADER_STDINT(include/gstdint.h)
+#GCC_HEADER_STDINT(include/gstdint.h)
GLIBCXX_ENABLE_SYMVERS([yes])
AC_SUBST(libtool_VERSION)

View File

@ -1,29 +0,0 @@
link_spec.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
Enable LINK_SPEC customization via configure arguments
We add a hook for sneaking our custom LINK_SPEC definition into the GCC
configure process by uncommentig the 'host_xm_include_list'. This enables us
to supply a custom header file to be included into 'gcc/config.h' defining
the 'LINK_SPEC' macro. This macro expresses the policy of how the GCC
frontend invokes 'ld' on multiarch platforms. I.e., on x86, we need to pass
'-melf_i386' to 'ld' when building in '-m32' mode.
---
gcc/configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/configure.ac b/gcc/configure.ac
index a78a1d7..29ac2f3 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1785,7 +1785,7 @@ for f in $xm_file; do
done
host_xm_file_list=
-host_xm_include_list=
+#host_xm_include_list=
for f in $host_xm_file; do
case $f in
ansidecl.h )

View File

@ -1,10 +1,7 @@
tmake_file_extra_parts.patch
config.patch
misc.patch
tmake_file_arm.patch
link_spec.patch
inhibit_libc.patch
cppflags_for_target.patch
cpp_for_target.patch
no_short_enums.patch
host_target_combination.patch
prefer_pic.patch
libstdcxx_without_libc.patch
libgcc_s.patch

View File

@ -1,25 +0,0 @@
tmake_file_arm.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
Let 'config.gcc' expand our already populated 'tmake_file' variable rather
than making a hard assignment. This is needed for the ARM platform because
the target 'arm-elf-eabi' actually matches the pattern 'arm-*-*-eabi' in
the 'config.gcc' file.
---
gcc/config.gcc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 732b829..8876218 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -910,7 +910,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
need_64bit_hwint=yes
default_use_cxa_atexit=yes
tm_file="dbxelf.h elfos.h arm/unknown-elf.h arm/elf.h arm/bpabi.h"
- tmake_file="arm/t-arm arm/t-arm-elf"
+ tmake_file="${tmake_file} arm/t-arm arm/t-arm-elf"
case ${target} in
arm*-*-eabi*)
tm_file="$tm_file newlib-stdint.h"

View File

@ -1,59 +0,0 @@
tmake_file_extra_parts.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
Enable support for passing custom 'tmake_file' and 'extra_parts' to the
GCC configure process uncommenting the default initialization of the
respective variables. The 'extra_parts' variable is used to carry the
information about which crtN files are to be created.
---
gcc/config.gcc | 2 +-
libgcc/config.host | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 9503b96..732b829 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -204,7 +204,7 @@
out_file=
common_out_file=
-tmake_file=
+#tmake_file=
extra_headers=
user_headers_inc_next_pre=
user_headers_inc_next_post=
diff --git a/libgcc/config.host b/libgcc/config.host
index b64da4a..c34e7b3 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -69,8 +69,8 @@
asm_hidden_op=.hidden
enable_execute_stack=
-extra_parts=
-tmake_file=
+#extra_parts=
+#tmake_file=
tm_file=
tm_define=
md_unwind_header=no-unwind.h
@@ -261,7 +261,7 @@ case ${host} in
tmake_file=t-vxworks
;;
*-*-elf)
- extra_parts="crtbegin.o crtend.o"
+# extra_parts="crtbegin.o crtend.o"
;;
esac
@@ -364,7 +364,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
case ${host} in
arm*-*-eabi* | arm*-*-rtems*)
tmake_file="${tmake_file} arm/t-bpabi"
- extra_parts="crtbegin.o crtend.o crti.o crtn.o"
+# extra_parts="crtbegin.o crtend.o crti.o crtn.o"
;;
arm*-*-symbianelf*)
tmake_file="${tmake_file} arm/t-symbian t-slibgcc-nolc-override"

View File

@ -17,14 +17,13 @@ help:
$(ECHO) "arm - create tool chain for arm"
$(ECHO) "clean - clean everything except downloaded archives"
$(ECHO) "cleanall - clean everything including downloaded archives"
$(ECHO) "install - copy tool chain to '$(INSTALL_LOCATION)'"
$(ECHO)
#
# User interface
#
SUPPORTED_PLATFORMS := x86 microblaze arm
SUPPORTED_PLATFORMS := x86 arm
PLATFORM := $(firstword $(filter $(SUPPORTED_PLATFORMS),$(MAKECMDGOALS)))
@ -102,8 +101,6 @@ VERBOSE = @
#
# Check if 'autoconf' is installed
#
AUTOCONF_VERSION_gcc_4.4.5 = 2.59
AUTOCONF_VERSION_gcc_4.6.1 = 2.64
AUTOCONF_VERSION_gcc_4.7.4 = 2.64
AUTOCONF_VERSION = $(AUTOCONF_VERSION_gcc_$(GCC_VERSION))
@ -166,33 +163,6 @@ ifneq ($(strip $(TOOLS_OK)),)
$(error Please install missing tools.)
endif
#
# Libc stub
#
LIBC_GEN_SYMLINKS = \
stdint.h memory.h string.h stdlib.h unistd.h errno.h wchar.h \
ctype.h strings.h wctype.h math.h stdio.h dlfcn.h inttypes.h \
malloc.h signal.h fcntl.h assert.h locale.h setjmp.h time.h \
link.h gnu-versions.h elf.h
LIBC_GEN_SYS_SYMLINKS = types.h stat.h sem.h
LIBC_DIR = $(shell pwd)/build/libc/include
LIBC_STUB_H = $(GENODE_DIR)/tool/libgcc_libc_stub.h
LIBC = $(addprefix $(LIBC_DIR)/,$(LIBC_GEN_SYMLINKS)) \
$(addprefix $(LIBC_DIR)/sys/,$(LIBC_GEN_SYS_SYMLINKS))
$(LIBC_DIR) $(LIBC_DIR)/sys:
$(VERBOSE)mkdir -p $@
$(addprefix $(LIBC_DIR)/,$(LIBC_GEN_SYMLINKS)): $(LIBC_DIR)
$(VERBOSE)ln -sf $(LIBC_STUB_H) $@
$(addprefix $(LIBC_DIR)/sys/,$(LIBC_GEN_SYS_SYMLINKS)): $(LIBC_DIR)/sys
$(VERBOSE)ln -sf $(LIBC_STUB_H) $@
#
# 'configure' parameters for binutils, gcc and gdb
#
@ -208,9 +178,8 @@ LOCAL_INSTALL_LOCATION = $(shell pwd)/build/install
#
LOCAL_LIB_INSTALL_LOCATION = $(shell pwd)/build/lib-install
TARGET_NAME_x86 = x86_64-elf
TARGET_NAME_microblaze = microblaze-elf
TARGET_NAME_arm = arm-elf-eabi
TARGET_NAME_x86 = x86_64-pc-elf
TARGET_NAME_arm = arm-none-eabi
ifneq ($(VERBOSE),)
CONFIG_QUIET = --quiet
@ -245,82 +214,40 @@ BINUTILS_CONFIG += $(BINUTILS_CONFIG_$(PLATFORM))
#
GDB_CONFIG += $(COMMON_CONFIG) --disable-werror
#
# Dummy libc symbols to resolve unresolved references when linking
# 'libgcc_s.so'. Even though, this library is not used on Genode, we want the
# link command to succeed to complete the build process.
#
DUMMY_LIBC_SYMS = strlen free memcpy malloc memset abort dl_iterate_phdr
LD_PREFIX = -Wl,
LD_DEFSYM_DUMMY_LIBC = $(addprefix $(LD_PREFIX)--defsym=,$(addsuffix =0,$(DUMMY_LIBC_SYMS)))
GCC_CONFIG += $(COMMON_CONFIG) \
--enable-languages=c,c++,go --disable-libgo \
--enable-languages=c,c++,go \
--disable-libgo \
--disable-libssp \
--disable-libquadmath \
--disable-libffi \
--enable-targets=all \
--with-gnu-as --with-gnu-ld --disable-tls --disable-threads \
--disable-libstdcxx-pch \
--with-gnu-as \
--with-gnu-ld \
--disable-tls \
--disable-threads \
--disable-hosted-libstdcxx \
--enable-shared \
--enable-multiarch \
--disable-sjlj-exceptions \
--with-gmp=$(LOCAL_LIB_INSTALL_LOCATION) \
--with-mpfr=$(LOCAL_LIB_INSTALL_LOCATION) \
--with-mpc=$(LOCAL_LIB_INSTALL_LOCATION) \
CPPFLAGS_FOR_TARGET=-I$(LIBC_DIR) \
CFLAGS_FOR_TARGET="-I$(LIBC_DIR) -nostdlib $(LD_DEFSYM_DUMMY_LIBC) -fPIC"
CFLAGS_FOR_TARGET="-I$(GENODE_DIR)/tool -DUSE_PT_GNU_EH_FRAME -Dinhibit_libc -fPIC" \
CXXFLAGS_FOR_TARGET="-fPIC"
GCC_CONFIG += $(GCC_CONFIG_$(PLATFORM))
#
# Configure options passed to gcc
#
HOST_CONFIG_ARGS = $(CONFIG_QUIET) \
host_xm_include_list=$(LINK_SPEC_H_$(PLATFORM)) \
tmake_file='t-slibgcc'
HOST_CONFIG_ARGS = $(CONFIG_QUIET)
#
# Passed to target components such as libgcc, libstdc++
#
# The 't-slibgcc' tmake file is needed to have libgcc_eh.a built.
# The 't-eh-dw2-dip' tmake file is needed to let the tool chain use 'unwind-dw2-fde-dip.c',
# needed for the exception handling on Genode in the presence of shared libraries.
#
TARGET_CONFIG_ARGS = $(CONFIG_QUIET) \
tmake_file='t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver' \
extra_parts='crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o'
# compile libsupc++ as position-independent code
TARGET_CONFIG_ARGS += PIC_CXXFLAGS='-prefer-pic'
TARGET_CONFIG_ARGS = $(CONFIG_QUIET)
GCC_INSTALL_RULE = install-strip
ifeq ($(GCC_VERSION),4.4.5)
GCC_INSTALL_RULE = install
endif
#
# Default linker script
#
# Needed only to make target-configure happy.
#
LD_SCRIPT_microblaze = $(LOCAL_INSTALL_LOCATION)/$(TARGET_NAME_microblaze)/lib/xilinx.ld
$(LD_SCRIPT_$(PLATFORM)):
$(VERBOSE)mkdir -p $(dir $@)
$(VERBOSE)touch $@
#
# Link spec
#
# The 'LINK_SPEC' define comprises the rules of how the GCC frontend invokes
# the linker.
#
LINK_SPEC_H_x86 = $(shell pwd)/build/$(PLATFORM)/link_spec.h
$(LINK_SPEC_H_x86):
$(VERBOSE)echo "#define LINK_SPEC \"%{!m32:-m elf_x86_64} %{m32:-m elf_i386} %{shared:-shared} %{!static:--eh-frame-hdr}\"" > $@
$(LINK_SPEC_H_arm):
$(VERBOSE)echo "#define LINK_SPEC \"%(shared:-shared) %{!static:--eh-frame-hdr}\"" > $@
#
# Platform-specific multilib support
@ -478,8 +405,6 @@ build/$(PLATFORM)/gcc/Makefile:
../../../$(CONTRIB_DIR)/gcc-$(GCC_VERSION)/configure $(GCC_CONFIG)
$(GCC_BINARIES): build/$(PLATFORM)/gcc/Makefile \
$(LINK_SPEC_H_$(PLATFORM)) \
$(LD_SCRIPT_$(PLATFORM)) \
$(LIBC)
$(GCC_BINARIES): build/$(PLATFORM)/gcc/Makefile

View File

@ -14,11 +14,3 @@ $(CONTRIB_DIR)/gcc-$(GCC_VERSION)/configure:: $(CONTRIB_DIR)/gcc-$(GCC_VERSION)
$(VERBOSE)cd $(CONTRIB_DIR)/gcc-$(GCC_VERSION)/gcc; $(AUTOCONF)
$(VERBOSE)cd $(CONTRIB_DIR)/gcc-$(GCC_VERSION); $(AUTOCONF)
$(VERBOSE)touch $@
@#
@# Fix a bug in gcc 4.6.1 that causes compile errors when building Qt4 for ARM
@# More detailed description at and solution from http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02245.html
@#
ifeq ($(GCC_VERSION),4.6.1)
$(ECHO) "$(BRIGHT_COL)patching gcc...$(DEFAULT_COL)"
$(VERBOSE)sed -i "/|| (volatilep && flag_strict_volatile_bitfields > 0/s/)/ \&\& (bitpos % GET_MODE_ALIGNMENT (mode) != 0))/" $(CONTRIB_DIR)/gcc-$(GCC_VERSION)/gcc/expr.c
endif