From patchwork Mon Jan 24 14:01:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 80163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 11A90B710E for ; Tue, 25 Jan 2011 01:02:08 +1100 (EST) Received: (qmail 26865 invoked by alias); 24 Jan 2011 14:02:01 -0000 Received: (qmail 26796 invoked by uid 22791); 24 Jan 2011 14:01:54 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL, BAYES_40, TW_BJ, TW_GC, TW_JG, TW_SR, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Jan 2011 14:01:45 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id BBEA495A; Mon, 24 Jan 2011 15:01:42 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0+oqzfQUgieq; Mon, 24 Jan 2011 15:01:30 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 28CE8955; Mon, 24 Jan 2011 15:01:30 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p0OE1SuW007727; Mon, 24 Jan 2011 15:01:28 +0100 (MET) From: Rainer Orth To: IainS Cc: Ralf Wildenhues , gcc-patches@gcc.gnu.org, java-patches@gcc.gnu.org, Hans Boehm , Paolo Bonzini , Janis Johnson , Ben Elliston Subject: Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412) References: <20110106211734.GG17791@gmx.de> Date: Mon, 24 Jan 2011 15:01:28 +0100 In-Reply-To: (IainS's message of "Mon, 17 Jan 2011 13:31:18 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi Iain, > One issue on powerpc-darwin9**** > (which I would expect to manifest on *-*-darwin*) > > On 17 Jan 2011, at 12:11, Rainer Orth wrote: >> I've now got a patch I'm reasonably happy with. It incorporates all the >> review comments. Tested on i386-pc-solaris2.10, i386-pc-solaris2.10 and >> sparc-sun-solaris2.11. > > + > Native configuration is powerpc-apple-darwin9 > > === boehm-gc tests === > > Schedule of variations: > unix/-m32 > unix/-m64 > > Running target unix/-m32 > Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as board > description file for target. > Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as generic > interface file for target. > Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as > tool-and-target-specific interface file. > Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ... > Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/lib.exp ... > FAIL: staticrootslib.lo -O2 (test for excess errors) > > [[[ **** this is failing because of ranlib output: > > Executing on host: ../libtool --silent --tag=CC --mode=link /GCC/ > gcc-4-6-trunk-build/gcc/xgcc -B/GCC/gcc-4-6-trunk-build/gcc/ > staticrootslib.lo /GCC/gcc-4-6-tr > unk-build/powerpc-apple-darwin9/./boehm-gc/libgcjgc.la -O2 -version- > info 1:2:0 -no-undefined -rpath /nowhere -Wc,-shared-libgcc /GCC/ > gcc-4-6-trunk-build/power > pc-apple-darwin9/./boehm-gc/libgcjgc_convenience.la -I/GCC/gcc-4-6- > trunk-build/powerpc-apple-darwin9/./boehm-gc/include -I/GCC/gcc-live- > trunk/boehm-gc/testsuite > /../include -Wc,-shared-libgcc -lpthread -lm -m32 -o > libstaticrootslib.la (timeout = 300) > ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols > > ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no symbols > output is: > ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols > > ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no symbols > > I would imagine that a similar situation must have been handled somewhere > else in the test-suite - but not sure where... ]]] Could you give this version a try? I've introduced boehm-gc-dg-prune, but couldn't test on Darwin. What I've done instead is remove --silent from the libtool invocations and prune the resulting libtool message in the -dg-prune function to make sure the basics are ok. Unfortunately, I've just discovered another issue: on IRIX 6.5, site.exp can differ between different multilibs: for the N32 multilib, we have set extra_test_libs "-ldl" while for N64, libdl doesn't exist. I'll have to investigate how to avoid this. Thanks. Rainer diff -r ea50a33cef8f boehm-gc/Makefile.am --- a/boehm-gc/Makefile.am Fri Jan 21 22:12:30 2011 +0100 +++ b/boehm-gc/Makefile.am Fri Jan 21 23:12:22 2011 +0100 @@ -4,10 +4,10 @@ ## files that should be in the distribution are not mentioned in this ## Makefile.am. -AUTOMAKE_OPTIONS = cygnus subdir-objects +AUTOMAKE_OPTIONS = foreign subdir-objects ACLOCAL_AMFLAGS = -I .. -I ../config -SUBDIRS = include +SUBDIRS = include testsuite noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la @@ -35,7 +35,7 @@ # Include THREADLIBS here to ensure that the correct versions of # linuxthread semaphore functions get linked: -libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) $(UNWINDLIBS) +libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) libgcjgc_la_DEPENDENCIES = $(addobjs) libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 -rpath $(toolexeclibdir) libgcjgc_la_LINK = $(LINK) $(libgcjgc_la_LDFLAGS) @@ -48,43 +48,6 @@ AM_LDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) override CFLAGS := $(filter-out $(O0_CFLAGS), $(CFLAGS)) $(O0_CFLAGS) -test_ldadd = libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS) - -check_PROGRAMS = gctest -gctest_SOURCES = tests/test.c -gctest_LDADD = $(test_ldadd) -gctest_LDFLAGS = -shared-libgcc -gctest_LINK = $(LINK) $(gctest_LDFLAGS) -TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc -TESTS = gctest - -TESTS += leaktest$(EXEEXT) -check_PROGRAMS += leaktest -leaktest_SOURCES = tests/leak_test.c -leaktest_LDADD = $(test_ldadd) -leaktest_LDFLAGS = -shared-libgcc -leaktest_LINK = $(LINK) $(leaktest_LDFLAGS) - -TESTS += middletest$(EXEEXT) -check_PROGRAMS += middletest -middletest_SOURCES = tests/middle.c -middletest_LDADD = $(test_ldadd) -middletest_LDFLAGS = -shared-libgcc -middletest_LINK = $(LINK) $(middletest_LDFLAGS) - -TESTS += staticrootstest$(EXEEXT) -check_PROGRAMS += staticrootstest -staticrootstest_SOURCES = tests/staticrootstest.c -staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la -staticrootstest_LDFLAGS = -shared-libgcc -staticrootstest_LINK = $(LINK) $(staticrootstest_LDFLAGS) -check_LTLIBRARIES = libstaticrootslib.la -libstaticrootslib_la_SOURCES = tests/staticrootslib.c -libstaticrootslib_la_LIBADD = libgcjgc_convenience.la -libstaticrootslib_la_LDFLAGS = -version-info 1:2:0 -no-undefined \ - -rpath /nowhere -shared-libgcc -libstaticrootslib_la_DEPENDENCIES = libgcjgc_convenience.la - ## FIXME: we shouldn't have to do this, but automake forces us to. .s.lo: ## We use -Wp,-P to strip #line directives. Irix `as' chokes on @@ -116,7 +79,6 @@ "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \ "SHELL=$(SHELL)" \ "EXPECT=$(EXPECT)" \ - "RUNTEST=$(RUNTEST)" \ "RUNTESTFLAGS=$(RUNTESTFLAGS)" \ "exec_prefix=$(exec_prefix)" \ "infodir=$(infodir)" \ diff -r ea50a33cef8f boehm-gc/configure.ac --- a/boehm-gc/configure.ac Fri Jan 21 22:12:30 2011 +0100 +++ b/boehm-gc/configure.ac Fri Jan 21 23:12:22 2011 +0100 @@ -1,4 +1,4 @@ -# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010 by Red Hat, Inc. +# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010, 2011 by Red Hat, Inc. # All rights reserved. # Copyright 2004 Nathanael Nerode # @@ -544,5 +544,5 @@ AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h]) -AC_CONFIG_FILES(Makefile include/Makefile threads.mk) +AC_CONFIG_FILES(Makefile include/Makefile testsuite/Makefile threads.mk) AC_OUTPUT diff -r ea50a33cef8f boehm-gc/testsuite/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boehm-gc/testsuite/Makefile.am Fri Jan 21 23:12:22 2011 +0100 @@ -0,0 +1,43 @@ +## Process this file with automake to produce Makefile.in. + +AUTOMAKE_OPTIONS = foreign dejagnu + +# Setup the testing framework, if you have one +EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \ + echo $(top_builddir)/../expect/expect ; \ + else echo expect ; fi` + +RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \ + echo $(top_srcdir)/../dejagnu/runtest ; \ + else echo runtest; fi` + +# Override default. +DEJATOOL = boehm-gc + +CLEANFILES = *.exe core* *.log *.sum + +# We need more things in site.exp, but automake completely controls the +# creation of that file; there's no way to append to it without messing up +# the dependancy chains. So we overrule automake. This rule is exactly +# what it would have generated, plus our own additions. +site.exp: Makefile + @echo 'Making a new site.exp file...' + @echo '## these variables are automatically generated by make ##' >site.tmp + @echo '# Do not edit here. If you wish to override these values' >>site.tmp + @echo '# edit the last section' >>site.tmp + @echo 'set srcdir $(srcdir)' >>site.tmp + @echo "set objdir `pwd`" >>site.tmp + @echo 'set build_alias "$(build_alias)"' >>site.tmp + @echo 'set build_triplet $(build_triplet)' >>site.tmp + @echo 'set host_alias "$(host_alias)"' >>site.tmp + @echo 'set host_triplet $(host_triplet)' >>site.tmp + @echo 'set target_alias "$(target_alias)"' >>site.tmp + @echo 'set target_triplet $(target_triplet)' >>site.tmp + @echo 'set threadlibs "$(THREADLIBS)"' >>site.tmp + @echo 'set extra_test_libs "$(EXTRA_TEST_LIBS)"' >>site.tmp + @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp + @test ! -f site.exp || \ + sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp + @-rm -f site.bak + @test ! -f site.exp || mv site.exp site.bak + @mv site.tmp site.exp diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.c/c.exp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boehm-gc/testsuite/boehm-gc.c/c.exp Fri Jan 21 23:12:22 2011 +0100 @@ -0,0 +1,25 @@ +# Copyright (C) 2011 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 program; see the file COPYING3. If not see +# . + +dg-init +boehm-gc-init + +boehm-gc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "-O2" "" +dg-finish + +# Local Variables: +# tcl-indent-level:4 +# End: diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.c/trace_test.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boehm-gc/testsuite/boehm-gc.c/trace_test.c Fri Jan 21 23:12:22 2011 +0100 @@ -0,0 +1,32 @@ +/* { dg-skip-if "requires --enable-gc-debug" *-*-* } */ + +#include +#define GC_DEBUG +#include "gc.h" + +struct treenode { + struct treenode *x; + struct treenode *y; +} * root[10]; + +struct treenode * mktree(int i) { + struct treenode * r = GC_MALLOC(sizeof(struct treenode)); + if (0 == i) return 0; + if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode)); + r -> x = mktree(i-1); + r -> y = mktree(i-1); + return r; +} + +int main() +{ + int i; + for (i = 0; i < 10; ++i) { + root[i] = mktree(12); + } + GC_generate_random_backtrace(); + GC_generate_random_backtrace(); + GC_generate_random_backtrace(); + GC_generate_random_backtrace(); + return 0; +} diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.lib/lib.exp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boehm-gc/testsuite/boehm-gc.lib/lib.exp Fri Jan 21 23:12:22 2011 +0100 @@ -0,0 +1,30 @@ +# Copyright (C) 2011 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 program; see the file COPYING3. If not see +# . + +dg-init +boehm-gc-init + +# Gather list of tests, skipping library source files. +# FIXME: How does this happen for dg-additional-sources? +set tests [lsort [glob -nocomplain $srcdir/$subdir/*.c]] +set tests [prune $tests $srcdir/$subdir/*lib.c] + +boehm-gc-dg-runtest $tests "-O2" "" +dg-finish + +# Local Variables: +# tcl-indent-level:4 +# End: diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.lib/staticrootstest.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boehm-gc/testsuite/boehm-gc.lib/staticrootstest.c Fri Jan 21 23:12:22 2011 +0100 @@ -0,0 +1,48 @@ +/* { dg-add-shlib "staticrootslib.c" } */ + +#include + +#ifndef GC_DEBUG +# define GC_DEBUG +#endif + +#include "gc.h" +#include "gc_backptr.h" + +struct treenode { + struct treenode *x; + struct treenode *y; +} * root[10]; + +static char *staticroot = 0; + +extern struct treenode * libsrl_mktree(int i); +extern void * libsrl_init(void); +extern void * libsrl_collect (void); + +int main(void) +{ + int i; + staticroot = libsrl_init(); + for (i = 0; i < sizeof(struct treenode); ++i) { + staticroot[i] = 0x42; + } + libsrl_collect(); + for (i = 0; i < 10; ++i) { + root[i] = libsrl_mktree(12); + libsrl_collect(); + } + for (i = 0; i < sizeof(struct treenode); ++i) { + if (staticroot[i] != 0x42) + return -1; + } + for (i = 0; i < 10; ++i) { + root[i] = libsrl_mktree(12); + libsrl_collect(); + } + for (i = 0; i < sizeof(struct treenode); ++i) { + if (staticroot[i] != 0x42) + return -1; + } + return 0; +} diff -r ea50a33cef8f boehm-gc/testsuite/config/default.exp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boehm-gc/testsuite/config/default.exp Fri Jan 21 23:12:22 2011 +0100 @@ -0,0 +1,1 @@ +load_lib "standard.exp" diff -r ea50a33cef8f boehm-gc/testsuite/lib/boehm-gc.exp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boehm-gc/testsuite/lib/boehm-gc.exp Fri Jan 21 23:12:22 2011 +0100 @@ -0,0 +1,335 @@ +# Copyright (C) 2011 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 program; see the file COPYING3. If not see +# . + +proc load_gcc_lib { filename } { + global srcdir loaded_libs + load_file $srcdir/../../gcc/testsuite/lib/$filename + set loaded_libs($filename) "" +} + +load_lib dg.exp +load_gcc_lib target-libpath.exp +load_gcc_lib wrapper.exp +# Required by target-supports-dg.exp. +load_gcc_lib target-supports.exp +# For dg-skip-if. +load_gcc_lib target-supports-dg.exp +# For ${tool}_exit. +load_gcc_lib gcc-defs.exp +# For prune_gcc_output. +load_gcc_lib prune.exp + +set dg-do-what-default run + +# Define boehm-gc callbacks for dg.exp. + +# FIXME: The next two are independent of boehm-gc; move to some library. +proc ${tool}-dg-test-1 { target_compile prog do_what extra_tool_flags } { + + # Set up the compiler flags, based on what we're going to do. + + set options [list] + switch $do_what { + "compile" { + set compile_type "assembly" + set output_file "[file rootname [file tail $prog]].s" + } + "assemble" { + set compile_type "object" + set output_file "[file rootname [file tail $prog]].o" + } + "ltassemble" { + # Needs to be different from assemble since we cannot determine + # from $prog whether to produce a regular or a libtool object. + set compile_type "object" + set output_file "[file rootname [file tail $prog]].lo" + } + "link" { + set compile_type "executable" + set output_file "[file rootname [file tail $prog]]" + # If we're linking a libtool object, produce a libtool library. + if { [file extension $prog] == ".lo" } { + set output_file "lib$output_file.la" + } + } + "run" { + set compile_type "executable" + # FIXME: "./" is to cope with "." not being in $PATH. + # Should this be handled elsewhere? + # YES. + set output_file "./[file rootname [file tail $prog]]" + # This is the only place where we care if an executable was + # created or not. If it was, dg.exp will try to run it. + remote_file build delete $output_file + } + default { + perror "$do_what: not a valid dg-do keyword" + return "" + } + } + + if { $extra_tool_flags != "" } { + lappend options "additional_flags=$extra_tool_flags" + } + + set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options]; + + return [list $comp_output $output_file] +} + +proc ${tool}-dg-test { prog do_what extra_tool_flags } { + global tool + + return [${tool}-dg-test-1 ${tool}_target_compile $prog $do_what $extra_tool_flags] +} + +proc boehm-gc-init { args } { + global gluefile wrap_flags + global srcdir + global blddirgc + global TOOL_EXECUTABLE + global GCC_UNDER_TEST + global objdir + global gc_include + global gc_lib + global gc_lib_conv + global tool + global tool_root_dir + global ld_library_path + + set blddirgc [lookfor_file [get_multilibs] ${tool}] + verbose "blddirgc: $blddirgc" + + if ![info exists GCC_UNDER_TEST] then { + if [info exists TOOL_EXECUTABLE] { + set GCC_UNDER_TEST $TOOL_EXECUTABLE + } else { + set GCC_UNDER_TEST "[find_gcc]" + } + } + + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + } + verbose "gccdir: $gccdir" + + set ld_library_path "." + append ld_library_path ":${gccdir}" + + set compiler "${gccdir}/xgcc" + if { [is_remote host] == 0 && [which $compiler] != 0 } { + foreach i "[exec $compiler --print-multi-lib]" { + set mldir "" + regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir + set mldir [string trimright $mldir "\;@"] + if { "$mldir" == "." } { + continue + } + if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { + append ld_library_path ":${gccdir}/${mldir}" + } + } + } + # Add the library path for boehm-gc. + append ld_library_path ":${blddirgc}/.libs" + + # Add the library path for boehm-gc.lib libtool libraries. + append ld_library_path ":.libs" + + verbose "ld_library_path: $ld_library_path" + + # Point to the headers in boehm-gc. + set gc_include "${blddirgc}/include" + verbose "gc_include: $gc_include" + + set gc_lib "${blddirgc}/libgcjgc.la" + verbose "gc_lib: $gc_lib" + + set gc_lib_conv "${blddirgc}/libgcjgc_convenience.la" + verbose "gc_lib_conv: $gc_lib_conv" + + set_ld_library_path_env_vars + boehm-gc_maybe_build_wrapper "${objdir}/testglue.o" +} + +proc boehm-gc_target_compile { source dest type options } { + global gluefile wrap_flags; + global srcdir + global TOOL_OPTIONS + global GCC_UNDER_TEST + global libtool + global gc_include + global gc_lib + global gc_lib_conv + global threadlibs + global extra_test_libs + + if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=$wrap_flags" + } + + # TOOL_OPTIONS must come first, so that it doesn't override testcase + # specific options. + if [info exists TOOL_OPTIONS] { + lappend options [concat "additional_flags=$TOOL_OPTIONS" $options]; + } + + # Map type to libtool mode. + switch $type { + "object" { + set mode "compile" + } + "executable" { + set mode "link" + } + default { + perror "$type: unhandled type" + return "" + } + } + + # Set this once for reuse in boehm-gc.lib/lib.exp. + set libtool "../libtool" + # We have to run silently to avoid DejaGnu lossage. + lappend options "compiler=$libtool --silent --tag=CC --mode=$mode \ + $GCC_UNDER_TEST" + + lappend options "additional_flags=-I${gc_include} -I${srcdir}/../include" + + lappend options "libs= -Wc,-shared-libgcc" + lappend options "libs= ${gc_lib} ${threadlibs} ${extra_test_libs}" + + verbose "options: $options" + return [target_compile $source $dest $type $options] +} + +# Prune harmless messages. +proc boehm-gc-dg-prune { system text } { + # Prune the same messages as the gcc testsuite does. + set text [prune_gcc_output $text] + + # Ignore harmless Darwin ranlib warnings. + regsub -all "(^|\n)(ranlib: file: \[^\n\]* has no symbols\n?)+" $text "\\1" text + + return $text +} + +# Build shared library from LIB. +proc boehm-gc-build-shlib { lib flags extra-flags } { + global subdir + global dg-do-what-default + global libtool + global gc_lib_conv + + # Determine basename. + set basename "[file rootname [file tail $lib]]" + verbose "basename: $basename" + + # DejaGnu 1.4.4 doesn't support nested calls to dg-test. Restore + # original state before calling it again. + if { [info procs dg-save-unknown] != [list] } { + rename unknown "" + rename dg-save-unknown unknown + } + + set saved-dg-do-what ${dg-do-what-default} + + # Compile $lib into libtool object. + set dg-do-what-default ltassemble + dg-test -keep-output $lib $flags ${extra-flags} + + # FIXME: Explain options. + set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere" + # Prefix -shared-libgcc with -Wc, to get it through libtool. + lappend shopt -Wc,-shared-libgcc + # Link with libgcjgc convenience library. + lappend shopt $gc_lib_conv + + # There's no way to get output_file out of dg-test, only + # ${tool}-dg-test returns it, so hardcode that here. + set dg-do-what-default link + dg-test -keep-output $basename.lo $flags "${extra-flags} $shopt" + + set dg-do-what-default ${saved-dg-do-what} + + # Restore unknown, dg-save-unknown as DejaGnu 1.4.4 dg-test expects them. + if { [info procs dg-save-unknown] == [list] } { + rename unknown dg-save-unknown + proc unknown {} { + } + } + + catch { exec $libtool --mode=clean rm -f $basename.lo } + + return lib$basename.la +} + +# Handle dg-add-shlib. +proc dg-add-shlib { args } { + global tool + global srcdir subdir + global shlib + + if { [llength $args] > 2 } { + error "[lindex $args 0]: too many arguments" + return + } + + set lib [lindex $args 1] + set lib "$srcdir/$subdir/$lib" + verbose -log "dg-add-shlib $lib" + + upvar tool_flags flags + upvar default_extra_tool_flags extra-flags + # Build support library. + set shlib [boehm-gc-build-shlib $lib $flags ${extra-flags}] + + uplevel lappend tool_flags $shlib +} + +# Run boehm-gc testcases. +proc boehm-gc-dg-runtest { testcases flags extra-flags } { + global runtests + global libtool + global shlib + + set shlib "" + + foreach testcase $testcases { + # If we're only testing specific files and this isn't one of them, + # skip it. + if ![runtest_file_p $runtests $testcase] { + return + } + + # Run testcase. + # Keep output, otherwise libtool below won't remove the corresponding + # file in .libs. + dg-test -keep-output $testcase $flags ${extra-flags} + + # Remove $execname and eventually $shlib. + # FIXME: Is $execname right e.g. on Windows? + # FIXME: Better way to get at $shlib? + verbose -log "$libtool --mode=clean rm -f [file rootname [file tail $testcase]] $shlib" + catch { exec $libtool --mode=clean rm -f [file rootname [file tail $testcase]] $shlib } + } +} + +# Local Variables: +# tcl-indent-level:4 +# End: