2006-10-09 Benjamin Kosnik PR libstdc++/29095 * libsupc++/cxxabi.h (__cxa_cdtor_type): Explicit "C" linkage. * config/cpu/arm/cxxabi_tweaks.h: Same. * config/cpu/generic/cxxabi_tweaks.h: Same. * testsuite/abi: Add. * testsuite/abi/header_cxxabi.cc: New. * testsuite/demangle: Move... * testsuite/abi/demangle: ...here. * testsuite/libstdc++-dg/conformance.exp: Adjust testsuite file calculation. * scripts/create_testsuite_files: Same. * testsuite/lib/libstdc++.exp (v3_target_compile_as_c): New. (libstdc++-dg-test): Use it. Index: config/cpu/arm/cxxabi_tweaks.h =================================================================== --- config/cpu/arm/cxxabi_tweaks.h (revision 117587) +++ config/cpu/arm/cxxabi_tweaks.h (working copy) @@ -1,6 +1,6 @@ // Control various target specific ABI tweaks. ARM version. -// Copyright (C) 2004 Free Software Foundation, Inc. +// Copyright (C) 2004, 2006 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 @@ -33,6 +33,8 @@ #ifdef __cplusplus namespace __cxxabiv1 { + extern "C" + { #endif #ifdef __ARM_EABI__ @@ -67,7 +69,8 @@ #endif //!__ARM_EABI__ #ifdef __cplusplus + } } // namespace __cxxabiv1 #endif -#endif // __cxxabiv1 +#endif Index: config/cpu/generic/cxxabi_tweaks.h =================================================================== --- config/cpu/generic/cxxabi_tweaks.h (revision 117587) +++ config/cpu/generic/cxxabi_tweaks.h (working copy) @@ -1,6 +1,6 @@ // Control various target specific ABI tweaks. Generic version. -// Copyright (C) 2004 Free Software Foundation, Inc. +// Copyright (C) 2004, 2006 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 @@ -33,6 +33,8 @@ #ifdef __cplusplus namespace __cxxabiv1 { + extern "C" + { #endif // The generic ABI uses the first byte of a 64-bit guard variable. @@ -47,7 +49,8 @@ typedef void __cxa_cdtor_return_type; #ifdef __cplusplus + } } // namespace __cxxabiv1 #endif -#endif // __cxxabiv1 +#endif Index: testsuite/lib/libstdc++.exp =================================================================== --- testsuite/lib/libstdc++.exp (revision 117587) +++ testsuite/lib/libstdc++.exp (working copy) @@ -272,6 +272,7 @@ } } + set select_compile "v3_target_compile" set options "" if { $extra_tool_flags != "" } { verbose -log "extra_tool_flags are:" @@ -279,16 +280,17 @@ if { [string first "-x c" $extra_tool_flags ] != -1 } { # Short-circut a bunch of complicated goo here for the # special case of compiling a test file as a "C" file, not - # as C++: just use target_compile, instead of the usual - # gimmicks. + # as C++. Why? So -nostdc++ doesn't trip us up. So all the + # extra object files don't trip us up. So automatically + # linking in libstdc++ doesn't happen. So CXXFLAGS don't + # error. verbose -log "compiling and executing as C, not C++" - set compile_type "executable" - set output_file "./[file rootname [file tail $prog]].exe" - remote_file build delete $output_file; - lappend options "additional_flags=$extra_tool_flags" - set comp_output [target_compile "$prog" "$output_file" "$compile_type" $options]; - set comp_output [ prune_g++_output $comp_output ]; - return [list $comp_output $output_file] + + set edit_tool_flags $extra_tool_flags + regsub -all ".x c" $edit_tool_flags "" edit_tool_flags + lappend options "additional_flags=$edit_tool_flags" + + set select_compile "v3_target_compile_as_c" } else { lappend options "additional_flags=$extra_tool_flags" } @@ -296,7 +298,7 @@ # There is a libstdc++_compile made for us by default (via the tool- # and-target file), but the defaults are lacking in goodness. - set comp_output [v3_target_compile "$prog" "$output_file" "$compile_type" $options]; + set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options]; set comp_output [ prune_g++_output $comp_output ]; return [list $comp_output $output_file] @@ -323,7 +325,6 @@ global cxxflags global cxxldflags global includes - global blddir global v3-test_objs if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { @@ -340,8 +341,9 @@ # Flag setting based on type argument. if { $type == "executable" } { # Link the support objects into executables. + set cxx_final [concat $cxx_final $cxxldflags] + # lappend options "additional_flags=./libtestc++.a" set cxx_final [concat $cxx_final ${v3-test_objs}] - set cxx_final [concat $cxx_final $cxxldflags] } else { if { $type == "sharedlib" } { # Don't link in anything. @@ -356,6 +358,31 @@ } +# Called from libstdc++-dg-test above, but only for "C" compilation. +# Calls back into system's target_compile to actually do the work. +proc v3_target_compile_as_c { source dest type options } { + global gluefile + global wrap_flags + global includes + + if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=${wrap_flags}" + } + + set tname [target_info name] + set cc_final [board_info $tname compiler] + set cxxlibglossflags [libgloss_link_flags] + set cc_final [concat $cc_final $cxxlibglossflags] + set cc_final [concat $cc_final $includes] + regsub -all ".nostdinc.." $cc_final "" cc_final + + lappend options "compiler=$cc_final" + lappend options "timeout=600" + + return [target_compile $source $dest $type $options] +} + # Build the support objects linked in with the libstdc++ tests. In # addition, set v3-wchar_t, v3-threads, v3-test_objs, and v3-symver # appropriately. Index: testsuite/libstdc++-dg/conformance.exp =================================================================== --- testsuite/libstdc++-dg/conformance.exp (revision 117587) +++ testsuite/libstdc++-dg/conformance.exp (working copy) @@ -53,12 +53,12 @@ } else { # Find directories that might have tests. set subdirs [glob "$srcdir/\[0-9\]\[0-9\]*"] + lappend subdirs "$srcdir/abi" lappend subdirs "$srcdir/backward" - lappend subdirs "$srcdir/demangle" lappend subdirs "$srcdir/ext" lappend subdirs "$srcdir/performance" + lappend subdirs "$srcdir/thread" lappend subdirs "$srcdir/tr1" - lappend subdirs "$srcdir/thread" verbose "subdirs are $subdirs" # Find all the tests. Index: testsuite/abi/header_cxxabi.c =================================================================== --- testsuite/abi/header_cxxabi.c (revision 0) +++ testsuite/abi/header_cxxabi.c (revision 0) @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-options "-x c" } +// Copyright (C) 2006 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 2, 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// Must be compilable as "C" +#include Index: libsupc++/cxxabi.h =================================================================== --- libsupc++/cxxabi.h (revision 117587) +++ libsupc++/cxxabi.h (working copy) @@ -1,6 +1,6 @@ // new abi support -*- C++ -*- -// Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. // // This file is part of GCC. // @@ -54,12 +54,12 @@ #ifdef __cplusplus namespace __cxxabiv1 { - typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *); - extern "C" { #endif + typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *); + // Allocate array. void* __cxa_vec_new(size_t __element_count, size_t __element_size, Index: scripts/create_testsuite_files =================================================================== --- scripts/create_testsuite_files (revision 117587) +++ scripts/create_testsuite_files (working copy) @@ -32,7 +32,7 @@ # This is the ugly version of "everything but the current directory". It's # what has to happen when find(1) doesn't support -mindepth, or -xtype. dlist=`echo [0-9][0-9]*` -dlist="$dlist backward demangle ext performance thread tr1" +dlist="$dlist abi backward ext performance thread tr1" find $dlist "(" -type f -o -type l ")" -name "*.cc" -print > $tmp.01 find $dlist "(" -type f -o -type l ")" -name "*.c" -print > $tmp.02 cat $tmp.01 $tmp.02 | sort > $tmp.1