diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-02-07 12:06:26 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-02-07 12:06:26 +0000 |
commit | f169838ac346df666209dc62686101b3eb34c37a (patch) | |
tree | 18cf2a273c175c85d0c89d3ab4047148ae70b05f /libgo | |
parent | 7bbe35d80a621c1cf198e59e464b486f95634c00 (diff) | |
download | gcc-f169838ac346df666209dc62686101b3eb34c37a.tar.gz |
2011-02-02 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged as suggest by Andread Schwab
http://gcc.gnu.org/ml/gcc/2011-02/msg00099.html
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@169879 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/Makefile.am | 2 | ||||
-rw-r--r-- | libgo/Makefile.in | 2 | ||||
-rw-r--r-- | libgo/config.h.in | 7 | ||||
-rw-r--r-- | libgo/config/libtool.m4 | 17 | ||||
-rw-r--r-- | libgo/configure | 118 | ||||
-rw-r--r-- | libgo/configure.ac | 64 | ||||
-rw-r--r-- | libgo/runtime/go-semacquire.c | 32 | ||||
-rw-r--r-- | libgo/runtime/go-unwind.c | 2 | ||||
-rw-r--r-- | libgo/testsuite/lib/libgo.exp | 4 |
9 files changed, 238 insertions, 10 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am index b6beb1e2fb3..05fa5db8509 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -2608,7 +2608,7 @@ testing/script/check: $(CHECK_DEPS) sysinfo.go: s-sysinfo; @true s-sysinfo: $(srcdir)/mksysinfo.sh config.h - CC="$(CC)" $(SHELL) $(srcdir)/mksysinfo.sh + CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)" $(SHELL) $(srcdir)/mksysinfo.sh $(SHELL) $(srcdir)/../move-if-change tmp-sysinfo.go sysinfo.go $(STAMP) $@ diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 729c6e2c723..e0e12a63db1 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -4992,7 +4992,7 @@ testing/script/check: $(CHECK_DEPS) sysinfo.go: s-sysinfo; @true s-sysinfo: $(srcdir)/mksysinfo.sh config.h - CC="$(CC)" $(SHELL) $(srcdir)/mksysinfo.sh + CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)" $(SHELL) $(srcdir)/mksysinfo.sh $(SHELL) $(srcdir)/../move-if-change tmp-sysinfo.go sysinfo.go $(STAMP) $@ diff --git a/libgo/config.h.in b/libgo/config.h.in index 382362beb40..18a51cc8f02 100644 --- a/libgo/config.h.in +++ b/libgo/config.h.in @@ -43,6 +43,10 @@ function for uint32 */ #undef HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4 +/* Define to 1 if the compiler provides the __sync_fetch_and_add function for + uint32 */ +#undef HAVE_SYNC_FETCH_AND_ADD_4 + /* Define to 1 if you have the <syscall.h> header file. */ #undef HAVE_SYSCALL_H @@ -70,6 +74,9 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Define if the C++ compiler is configured for setjmp/longjmp exceptions. */ +#undef LIBGO_SJLJ_EXCEPTIONS + /* Define if the linker support split stack adjustments */ #undef LINKER_SUPPORTS_SPLIT_STACK diff --git a/libgo/config/libtool.m4 b/libgo/config/libtool.m4 index c4c9d188ea2..d7b689e3e1b 100644 --- a/libgo/config/libtool.m4 +++ b/libgo/config/libtool.m4 @@ -1287,14 +1287,27 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) CFLAGS="$SAVE_CFLAGS" fi ;; -sparc*-*solaris*) +*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" diff --git a/libgo/configure b/libgo/configure index ad4cc25810a..fbaac8e3d61 100644 --- a/libgo/configure +++ b/libgo/configure @@ -786,6 +786,7 @@ enable_libtool_lock enable_version_specific_runtime_libs with_libffi with_system_libunwind +enable_sjlj_exceptions ' ac_precious_vars='build_alias host_alias @@ -1425,6 +1426,8 @@ Optional Features: --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory + --enable-sjlj-exceptions + force use of builtin_setjmp for exceptions Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -6391,7 +6394,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; } CFLAGS="$SAVE_CFLAGS" fi ;; -sparc*-*solaris*) +*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 @@ -6402,7 +6405,20 @@ sparc*-*solaris*) case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -10890,7 +10906,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10893 "configure" +#line 10909 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10996,7 +11012,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10999 "configure" +#line 11015 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14063,6 +14079,68 @@ $as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h fi +# Check whether --enable-sjlj-exceptions was given. +if test "${enable_sjlj_exceptions+set}" = set; then : + enableval=$enable_sjlj_exceptions; case "$enableval" in + yes|no|auto) ;; + *) as_fn_error "unknown argument to --enable-sjlj-exceptions" "$LINENO" 5 ;; + esac +else + enable_sjlj_exceptions=auto +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use setjmp/longjmp exceptions" >&5 +$as_echo_n "checking whether to use setjmp/longjmp exceptions... " >&6; } +if test "${libgo_cv_lib_sjlj_exceptions+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +void bar (); +void clean (int *); +void foo () +{ + int i __attribute__ ((cleanup (clean))); + bar(); +} + +_ACEOF +CFLAGS_hold=$CFLAGS +CFLAGS="--save-temps -fexceptions" +libgo_cv_lib_sjlj_exceptions=unknown +if ac_fn_c_try_compile; then : + if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1; then + libgo_cv_lib_sjlj_exceptions=yes + elif grep _Unwind_Resume conftest.s >/dev/null 2>&1; then + libgo_cv_lib_sjlj_exceptions=no + fi +fi +CFLAGS=$CFLAGS_hold +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgo_cv_lib_sjlj_exceptions" >&5 +$as_echo "$libgo_cv_lib_sjlj_exceptions" >&6; } + +if test "$enable_sjlj_exceptions" = "auto"; then + enable_sjlj_exceptions=$libgo_cv_lib_sjlj_exceptions +fi + +case $enable_sjlj_exceptions in +yes) + +$as_echo "#define LIBGO_SJLJ_EXCEPTIONS 1" >>confdefs.h + + ;; +no) + ;; +*) + as_fn_error "unable to detect exception model" "$LINENO" 5 + ;; +esac + for ac_header in sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/user.h sys/utsname.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -14123,7 +14201,37 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgo_cv_func___sync_bool_compare_and_swap_4" >&5 $as_echo "$libgo_cv_func___sync_bool_compare_and_swap_4" >&6; } if test "$libgo_cv_func___sync_bool_compare_and_swap_4" = "yes"; then - $as_echo "#define HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4 1" >>confdefs.h + +$as_echo "#define HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __sync_fetch_and_add_4" >&5 +$as_echo_n "checking for __sync_fetch_and_add_4... " >&6; } +if test "${libgo_cv_func___sync_fetch_and_add_4+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +typedef unsigned int uint32 __attribute__ ((mode (SI))); +uint32 i; +int main() { return __sync_fetch_and_add (&i, 1); } + +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + libgo_cv_func___sync_fetch_and_add_4=yes +else + libgo_cv_func___sync_fetch_and_add_4=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgo_cv_func___sync_fetch_and_add_4" >&5 +$as_echo "$libgo_cv_func___sync_fetch_and_add_4" >&6; } +if test "$libgo_cv_func___sync_fetch_and_add_4" = "yes"; then + +$as_echo "#define HAVE_SYNC_FETCH_AND_ADD_4 1" >>confdefs.h fi diff --git a/libgo/configure.ac b/libgo/configure.ac index 6cd04d2609c..da56610b579 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -328,6 +328,56 @@ AC_C_BIGENDIAN GCC_CHECK_UNWIND_GETIPINFO +AC_ARG_ENABLE(sjlj-exceptions, + AC_HELP_STRING([--enable-sjlj-exceptions], + [force use of builtin_setjmp for exceptions]), + [case "$enableval" in + yes|no|auto) ;; + *) AC_MSG_ERROR([unknown argument to --enable-sjlj-exceptions]) ;; + esac], + [enable_sjlj_exceptions=auto]) + +AC_CACHE_CHECK([whether to use setjmp/longjmp exceptions], +[libgo_cv_lib_sjlj_exceptions], +[AC_LANG_CONFTEST( + [AC_LANG_SOURCE([ +void bar (); +void clean (int *); +void foo () +{ + int i __attribute__ ((cleanup (clean))); + bar(); +} +])]) +CFLAGS_hold=$CFLAGS +CFLAGS="--save-temps -fexceptions" +libgo_cv_lib_sjlj_exceptions=unknown +AS_IF([ac_fn_c_try_compile], + [if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1; then + libgo_cv_lib_sjlj_exceptions=yes + elif grep _Unwind_Resume conftest.s >/dev/null 2>&1; then + libgo_cv_lib_sjlj_exceptions=no + fi]) +CFLAGS=$CFLAGS_hold +rm -f conftest* +]) + +if test "$enable_sjlj_exceptions" = "auto"; then + enable_sjlj_exceptions=$libgo_cv_lib_sjlj_exceptions +fi + +case $enable_sjlj_exceptions in +yes) + AC_DEFINE(LIBGO_SJLJ_EXCEPTIONS, 1, + [Define if the C++ compiler is configured for setjmp/longjmp exceptions.]) + ;; +no) + ;; +*) + AC_MSG_ERROR([unable to detect exception model]) + ;; +esac + AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/user.h sys/utsname.h) AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes) AC_CHECK_FUNCS(srandom random strsignal) @@ -346,6 +396,20 @@ if test "$libgo_cv_func___sync_bool_compare_and_swap_4" = "yes"; then [Define to 1 if the compiler provides the __sync_bool_compare_and_swap function for uint32]) fi +AC_CACHE_CHECK([for __sync_fetch_and_add_4], +[libgo_cv_func___sync_fetch_and_add_4], +[AC_LINK_IFELSE([ +typedef unsigned int uint32 __attribute__ ((mode (SI))); +uint32 i; +int main() { return __sync_fetch_and_add (&i, 1); } +], +[libgo_cv_func___sync_fetch_and_add_4=yes], +[libgo_cv_func___sync_fetch_and_add_4=no])]) +if test "$libgo_cv_func___sync_fetch_and_add_4" = "yes"; then + AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD_4, 1, + [Define to 1 if the compiler provides the __sync_fetch_and_add function for uint32]) +fi + dnl For x86 we want to use the -minline-all-stringops option to avoid dnl forcing a stack split when calling memcpy and friends. AC_CACHE_CHECK([whether compiler supports -minline-all-stringops], diff --git a/libgo/runtime/go-semacquire.c b/libgo/runtime/go-semacquire.c index 67a86ef695f..24c6a7388f6 100644 --- a/libgo/runtime/go-semacquire.c +++ b/libgo/runtime/go-semacquire.c @@ -117,3 +117,35 @@ semrelease (uint32 *addr) __go_assert (i == 0); } } + + +#ifndef HAVE_SYNC_FETCH_AND_ADD_4 + +/* For targets which don't have the required sync support. Really + this should be provided by gcc itself. FIXME. */ + +static pthread_mutex_t sync_lock = PTHREAD_MUTEX_INITIALIZER; + +uint32 +__sync_fetch_and_add_4(uint32*, uint32) + __attribute__((visibility("hidden"))); + +uint32 +__sync_fetch_and_add_4(uint32* ptr, uint32 add) +{ + int i; + uint32 ret; + + i = pthread_mutex_lock(&sync_lock); + __go_assert(i == 0); + + ret = *ptr; + *ptr += add; + + i = pthread_mutex_unlock(&sync_lock); + __go_assert(i == 0); + + return ret; +} + +#endif diff --git a/libgo/runtime/go-unwind.c b/libgo/runtime/go-unwind.c index cf586bbdbde..c0fc59cef84 100644 --- a/libgo/runtime/go-unwind.c +++ b/libgo/runtime/go-unwind.c @@ -126,7 +126,7 @@ __go_check_defer (void *frame) hdr = (struct _Unwind_Exception *) __go_panic_defer->__exception; -#ifdef _GLIBCXX_SJLJ_EXCEPTIONS +#ifdef LIBGO_SJLJ_EXCEPTIONS _Unwind_SjLj_Resume_or_Rethrow (hdr); #else #if defined(_LIBUNWIND_STD_ABI) diff --git a/libgo/testsuite/lib/libgo.exp b/libgo/testsuite/lib/libgo.exp index 29764d92446..a6d44323d3e 100644 --- a/libgo/testsuite/lib/libgo.exp +++ b/libgo/testsuite/lib/libgo.exp @@ -21,6 +21,10 @@ if {$gccdir != ""} { set GOC_UNDER_TEST "$gccdir/gccgo -B$gccdir/" set TESTING_IN_BUILD_TREE 1 +if [info exists GOTEST_TMPDIR] { + set tmpdir $GOTEST_TMPDIR +} + proc go_maybe_build_wrapper { args } { libgo_maybe_build_wrapper $args } |