Add stdcxx-4.6.1 to libports, fix #339

This patch adds libstdc++ to libports. With the previous version of the
stdcxx library, the build system used the C++ standard library that
comes with the compiler. This mechanism was prone to inconsistencies of
types defined in the header files used at compile time of the tool chain
and the types provided by our libc. By building the C++ standard library
as part of the Genode build process, such inconsistencies cannot happen
anymore.

Note that the patch changes the meaning of the 'stdcxx' library for
users that happened to rely on 'stdcxx' for hybrid Linux/Genode
applications. For such uses, the original mechanism is still available,
in the renamed form of 'toolchain_stdcxx'.
This commit is contained in:
Norman Feske 2012-08-31 17:13:06 +02:00
parent f7dd8aa688
commit 9651974448
17 changed files with 2078 additions and 0 deletions

17
.gitignore vendored
View File

@ -69,6 +69,7 @@
/libports/include/readline/rlstdc.h
/libports/include/readline/rltypedefs.h
/libports/include/readline/tilde.h
/libports/include/stdcxx
/libports/include/zlib
/libports/include/gmp/gmp-impl.h
/libports/include/gmp/arm/gmp-mparam.h
@ -76,6 +77,22 @@
/libports/include/gmp/x86_64/gmp-mparam.h
/libports/include/mpc/
/libports/include/mpfr/
/libports/include/stdcxx-genode/bits/atomic_word.h
/libports/include/stdcxx-genode/bits/basic_file.h
/libports/include/stdcxx-genode/bits/c++io.h
/libports/include/stdcxx-genode/bits/ctype_base.h
/libports/include/stdcxx-genode/bits/ctype_inline.h
/libports/include/stdcxx-genode/bits/ctype_noninline.h
/libports/include/stdcxx-genode/bits/cxxabi_forced.h
/libports/include/stdcxx-genode/bits/error_constants.h
/libports/include/stdcxx-genode/bits/hash_bytes.h
/libports/include/stdcxx-genode/bits/messages_members.h
/libports/include/stdcxx-genode/bits/time_members.h
/libports/include/stdcxx-genode/bits/exception_ptr.h
/libports/include/stdcxx-genode/bits/nested_exception.h
/libports/include/stdcxx-genode/initializer_list
/libports/include/stdcxx-genode/exception
/libports/include/stdcxx-genode/new
/libports/src/lib/gmp/mpn/asm-defs.m4
/libports/src/lib/gmp/mpn/arm/hamdist.c
/libports/src/lib/gmp/mpn/arm/popcount.c

View File

@ -0,0 +1,7 @@
#ifndef _INCLUDE__STDCXX_GENODE__BITS__CXXALLOCATOR_H_
#define _INCLUDE__STDCXX_GENODE__BITS__CXXALLOCATOR_H_
#include <ext/new_allocator.h>
#define __glibcxx_base_allocator __gnu_cxx::new_allocator
#endif /* _INCLUDE__STDCXX_GENODE__BITS__CXXALLOCATOR_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
../../../contrib/stdcxx-4.6.1/config/locale/generic/c_locale.h

View File

@ -0,0 +1,47 @@
// -fno-exceptions Support -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2006, 2007, 2008, 2009,
// 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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.
// This library 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.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/exception_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{exception}
*/
#ifndef _EXCEPTION_DEFINES_H
#define _EXCEPTION_DEFINES_H 1
#ifndef __EXCEPTIONS
// Iff -fno-exceptions, transform error handling code to work without it.
# define __try if (true)
# define __catch(X) if (false)
# define __throw_exception_again
#else
// Else proceed normally.
# define __try try
# define __catch(X) catch(X)
# define __throw_exception_again throw
#endif
#endif

View File

@ -0,0 +1 @@
#include <stdint.h>

View File

@ -0,0 +1,292 @@
/* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */
/* Copyright (C) 1997, 1999, 2000, 2004, 2008, 2009
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.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_GTHR_SINGLE_H
#define GCC_GTHR_SINGLE_H
/* Just provide compatibility for mutex handling. */
typedef int __gthread_key_t;
typedef int __gthread_once_t;
typedef int __gthread_mutex_t;
typedef int __gthread_recursive_mutex_t;
#define __GTHREAD_ONCE_INIT 0
#define __GTHREAD_MUTEX_INIT 0
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
#define UNUSED __attribute__((unused))
#ifdef _LIBOBJC
/* Thread local storage for a single thread */
static void *thread_local_storage = NULL;
/* Backend initialization functions */
/* Initialize the threads subsystem. */
static inline int
__gthread_objc_init_thread_system (void)
{
/* No thread support available */
return -1;
}
/* Close the threads subsystem. */
static inline int
__gthread_objc_close_thread_system (void)
{
/* No thread support available */
return -1;
}
/* Backend thread functions */
/* Create a new thread of execution. */
static inline objc_thread_t
__gthread_objc_thread_detach (void (* func)(void *), void * arg UNUSED)
{
/* No thread support available */
return NULL;
}
/* Set the current thread's priority. */
static inline int
__gthread_objc_thread_set_priority (int priority UNUSED)
{
/* No thread support available */
return -1;
}
/* Return the current thread's priority. */
static inline int
__gthread_objc_thread_get_priority (void)
{
return OBJC_THREAD_INTERACTIVE_PRIORITY;
}
/* Yield our process time to another thread. */
static inline void
__gthread_objc_thread_yield (void)
{
return;
}
/* Terminate the current thread. */
static inline int
__gthread_objc_thread_exit (void)
{
/* No thread support available */
/* Should we really exit the program */
/* exit (&__objc_thread_exit_status); */
return -1;
}
/* Returns an integer value which uniquely describes a thread. */
static inline objc_thread_t
__gthread_objc_thread_id (void)
{
/* No thread support, use 1. */
return (objc_thread_t) 1;
}
/* Sets the thread's local storage pointer. */
static inline int
__gthread_objc_thread_set_data (void *value)
{
thread_local_storage = value;
return 0;
}
/* Returns the thread's local storage pointer. */
static inline void *
__gthread_objc_thread_get_data (void)
{
return thread_local_storage;
}
/* Backend mutex functions */
/* Allocate a mutex. */
static inline int
__gthread_objc_mutex_allocate (objc_mutex_t mutex UNUSED)
{
return 0;
}
/* Deallocate a mutex. */
static inline int
__gthread_objc_mutex_deallocate (objc_mutex_t mutex UNUSED)
{
return 0;
}
/* Grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_lock (objc_mutex_t mutex UNUSED)
{
/* There can only be one thread, so we always get the lock */
return 0;
}
/* Try to grab a lock on a mutex. */
static inline int
__gthread_objc_mutex_trylock (objc_mutex_t mutex UNUSED)
{
/* There can only be one thread, so we always get the lock */
return 0;
}
/* Unlock the mutex */
static inline int
__gthread_objc_mutex_unlock (objc_mutex_t mutex UNUSED)
{
return 0;
}
/* Backend condition mutex functions */
/* Allocate a condition. */
static inline int
__gthread_objc_condition_allocate (objc_condition_t condition UNUSED)
{
return 0;
}
/* Deallocate a condition. */
static inline int
__gthread_objc_condition_deallocate (objc_condition_t condition UNUSED)
{
return 0;
}
/* Wait on the condition */
static inline int
__gthread_objc_condition_wait (objc_condition_t condition UNUSED,
objc_mutex_t mutex UNUSED)
{
return 0;
}
/* Wake up all threads waiting on this condition. */
static inline int
__gthread_objc_condition_broadcast (objc_condition_t condition UNUSED)
{
return 0;
}
/* Wake up one thread waiting on this condition. */
static inline int
__gthread_objc_condition_signal (objc_condition_t condition UNUSED)
{
return 0;
}
#else /* _LIBOBJC */
static inline int
__gthread_active_p (void)
{
return 0;
}
static inline int
__gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED)
{
return 0;
}
static inline int UNUSED
__gthread_key_create (__gthread_key_t *__key UNUSED, void (*__func) (void *) UNUSED)
{
return 0;
}
static int UNUSED
__gthread_key_delete (__gthread_key_t __key UNUSED)
{
return 0;
}
static inline void *
__gthread_getspecific (__gthread_key_t __key UNUSED)
{
return 0;
}
static inline int
__gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED)
{
return 0;
}
static inline int
__gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED)
{
return 0;
}
static inline int
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_lock (__mutex);
}
static inline int
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_trylock (__mutex);
}
static inline int
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_unlock (__mutex);
}
#endif /* _LIBOBJC */
#undef UNUSED
#endif /* ! GCC_GTHR_SINGLE_H */

View File

@ -0,0 +1 @@
../../contrib/stdcxx-4.6.1/libsupc++/exception

View File

@ -0,0 +1,14 @@
REP_INC_DIR += include/stdcxx
REP_INC_DIR += include/stdcxx/std
REP_INC_DIR += include/stdcxx/c_std
REP_INC_DIR += include/stdcxx/c_global
REP_INC_DIR += include/stdcxx-genode
LIBS += libc
include $(call select_from_repositories,lib/import/import-libc.mk)
# prevent gcc headers from defining mbstate
CC_OPT += -D_GLIBCXX_HAVE_MBSTATE_T
# use compiler-builtin atomic operations
CC_OPT += -D_GLIBCXX_ATOMIC_BUILTINS_4

40
libports/lib/mk/stdcxx.mk Normal file
View File

@ -0,0 +1,40 @@
# determine location of libstdc++ source tree
include $(REP_DIR)/ports/stdcxx.inc
STDCXX_DIR = $(REP_DIR)/contrib/$(STDCXX)
# enable 'atomic.cc' to find 'gstdint.h'
INC_DIR += $(REP_DIR)/include/stdcxx-genode/bits
# exclude code that is no single compilation unit
FILTER_OUT = hash-long-double-aux.cc
# exclude deprecated parts
FILTER_OUT += strstream.cc
# add libsupc++ sources
SRC_CC = $(filter-out $(FILTER_OUT),$(notdir $(wildcard $(STDCXX_DIR)/src/*.cc)))
# add config/locale/generic sources
SRC_CC += $(notdir $(wildcard $(STDCXX_DIR)/config/locale/generic/*.cc))
CC_OPT += -D__GXX_EXPERIMENTAL_CXX0X__ -std=c++0x
# add config/io backend
SRC_CC += basic_file_stdio.cc
INC_DIR += $(STDCXX_DIR)/config/io
# add bits of libsupc++ (most parts are already contained in the cxx library)
SRC_CC += new_op.cc new_opnt.cc new_opv.cc new_opvnt.cc new_handler.cc
SRC_CC += del_op.cc del_opnt.cc del_opv.cc del_opvnt.cc
SRC_CC += bad_cast.cc bad_alloc.cc bad_typeid.cc
SRC_CC += eh_aux_runtime.cc hash_bytes.cc
INC_DIR += $(STDCXX_DIR)/libsupc++
include $(REP_DIR)/lib/import/import-stdcxx.mk
vpath %.cc $(STDCXX_DIR)/src
vpath %.cc $(STDCXX_DIR)/config/locale/generic
vpath %.cc $(STDCXX_DIR)/config/io
vpath %.cc $(STDCXX_DIR)/libsupc++
SHARED_LIB = yes

View File

@ -0,0 +1,2 @@
STDCXX_VERSION = 4.6.1
STDCXX = stdcxx-$(STDCXX_VERSION)

85
libports/ports/stdcxx.mk Normal file
View File

@ -0,0 +1,85 @@
include ports/stdcxx.inc
STDCXX_TBZ2 = $(STDCXX).tar.bz2
STDCXX_URL = ftp://ftp.fu-berlin.de/gnu/gcc/gcc-$(STDCXX_VERSION)/gcc-g++-$(STDCXX_VERSION).tar.bz2
#
# Interface to top-level prepare Makefile
#
PORTS += $(STDCXX)
STDCXX_GEN_INCLUDES := \
include/stdcxx-genode/new \
include/stdcxx-genode/exception \
include/stdcxx-genode/initializer_list \
include/stdcxx-genode/bits/c++locale.h \
include/stdcxx-genode/bits/hash_bytes.h \
include/stdcxx-genode/bits/error_constants.h \
include/stdcxx-genode/bits/cxxabi_forced.h \
include/stdcxx-genode/bits/basic_file.h \
include/stdcxx-genode/bits/c++io.h \
include/stdcxx-genode/bits/atomic_word.h \
include/stdcxx-genode/bits/ctype_base.h \
include/stdcxx-genode/bits/ctype_inline.h \
include/stdcxx-genode/bits/ctype_noninline.h \
include/stdcxx-genode/bits/time_members.h \
include/stdcxx-genode/bits/messages_members.h \
include/stdcxx-genode/bits/exception_ptr.h \
include/stdcxx-genode/bits/nested_exception.h
prepare-stdcxx: $(CONTRIB_DIR)/$(STDCXX) include/stdcxx $(STDCXX_GEN_INCLUDES)
$(CONTRIB_DIR)/$(STDCXX): clean-stdcxx
#
# Port-specific local rules
#
$(DOWNLOAD_DIR)/$(STDCXX_TBZ2):
$(VERBOSE)wget -c -P $(DOWNLOAD_DIR) -O$@ $(STDCXX_URL) && touch $@
$(CONTRIB_DIR)/$(STDCXX): $(DOWNLOAD_DIR)/$(STDCXX_TBZ2)
@#$(VERBOSE)tar xfj $< --transform "s/nova-userland/vancouver/" -C $(CONTRIB_DIR)
$(VERBOSE)tar xfj $< -C $(CONTRIB_DIR) gcc-$(STDCXX_VERSION)/libstdc++-v3 \
--transform "s/gcc-$(STDCXX_VERSION).libstdc++-v3/stdcxx-$(STDCXX_VERSION)/" && touch $@
include/stdcxx:
$(VERBOSE)ln -s ../$(CONTRIB_DIR)/$(STDCXX)/include $@
include/stdcxx-genode/new:
$(VERBOSE)ln -s ../../$(CONTRIB_DIR)/$(STDCXX)/libsupc++/new $@
include/stdcxx-genode/exception:
$(VERBOSE)ln -s ../../$(CONTRIB_DIR)/$(STDCXX)/libsupc++/exception $@
include/stdcxx-genode/initializer_list:
$(VERBOSE)ln -s ../../$(CONTRIB_DIR)/$(STDCXX)/libsupc++/initializer_list $@
include/stdcxx-genode/bits/hash_bytes.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/libsupc++/hash_bytes.h $@
include/stdcxx-genode/bits/exception_ptr.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/libsupc++/exception_ptr.h $@
include/stdcxx-genode/bits/nested_exception.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/libsupc++/nested_exception.h $@
include/stdcxx-genode/bits/cxxabi_forced.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/libsupc++/cxxabi_forced.h $@
include/stdcxx-genode/bits/c++locale.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/locale/generic/c_locale.h $@
include/stdcxx-genode/bits/error_constants.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/os/generic/error_constants.h $@
include/stdcxx-genode/bits/basic_file.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/io/basic_file_stdio.h $@
include/stdcxx-genode/bits/c++io.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/io/c_io_stdio.h $@
include/stdcxx-genode/bits/atomic_word.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/cpu/generic/atomic_word.h $@
include/stdcxx-genode/bits/ctype_base.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/os/generic/ctype_base.h $@
include/stdcxx-genode/bits/ctype_inline.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/os/generic/ctype_inline.h $@
include/stdcxx-genode/bits/ctype_noninline.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/os/generic/ctype_noninline.h $@
include/stdcxx-genode/bits/time_members.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/locale/generic/time_members.h $@
include/stdcxx-genode/bits/messages_members.h:
$(VERBOSE)ln -s ../../../$(CONTRIB_DIR)/$(STDCXX)/config/locale/generic/messages_members.h $@
clean-stdcxx:
$(VERBOSE)rm -rf $(CONTRIB_DIR)/$(STDCXX)
$(VERBOSE)rm -f include/stdcxx
$(VERBOSE)rm -f $(STDCXX_GEN_INCLUDES)

View File

@ -51,6 +51,9 @@
extern "C++" { __gnu_cxx::__verbose_terminate_handler*; };
extern "C++" { std::terminate*; };
extern "C++" { std::bad_exception*; };
extern "C++" { std::exception*; };
extern "C++" { std::uncaught_exception*; };
/* x86 */
__cxa*;