This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Help with integrating my test program into dejagnu


Thanks again for help getting started with this Mike!

I've gotten rid of the Makefile and everything is run now from msabi.exp. I've also gotten rid of the header file, now that I know how to define a "_noinfo" fn pointer, so it's down to just 4 files: msabi.exp, gen.cc, msabi.c and do_test.S.

After running using DG_TORTURE_OPTIONS, it became clear that the resulting program was just too big, so I've modified the generator so that the test can be done in little bits. Otherwise, the build eats 6GiB+ and takes forever on the final set of cflags. I also needed to add an option to the generator to skip RBP clobbers in cases where the whole program is being built with hard frame pointers (-O0 or -fno-omit-frame-pointers).

And now for 50 questions. :) Am I using DG_TORTURE_OPTIONS correctly or should such a test only exist under gcc.torture? I'm not sure if I'm managing this correctly, as I'm calling pass/fail $subdir after each iteration of the test (should this only be called once?). Also, being that the generator is C++, I've added HOSTCXX and HOSTCXXFLAGS to site.exp, I hope that's OK. Finally, would you please look at my runtest_msabi procedure to make sure that I'm doing the build correctly? I'm using "remote_exec build" for most of it and I'm not 100% certain if that is the correct way to do it.

Once I get this cleaned up a bit more I'm going to send it as an RFC and hopefully get some feedback from the i386 maintainers.

Thanks again
Daniel
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 2aae684cad0..15e51b4cdc5 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3789,7 +3789,9 @@ site.exp: ./config.status Makefile
 	@echo "set CFLAGS \"\"" >> ./site.tmp
 	@echo "set CXXFLAGS \"\"" >> ./site.tmp
 	@echo "set HOSTCC \"$(CC)\"" >> ./site.tmp
+	@echo "set HOSTCXX \"$(CXX)\"" >> ./site.tmp
 	@echo "set HOSTCFLAGS \"$(CFLAGS)\"" >> ./site.tmp
+	@echo "set HOSTCXXFLAGS \"$(CXXFLAGS)\"" >> ./site.tmp
 # TEST_ALWAYS_FLAGS are flags that should be passed to every compilation.
 # They are passed first to allow individual tests to override them.
 	@echo "set TEST_ALWAYS_FLAGS \"$(SYSROOT_CFLAGS_FOR_TARGET)\"" >> ./site.tmp
diff --git a/gcc/testsuite/gcc.target/i386/msabi/msabi.exp b/gcc/testsuite/gcc.target/i386/msabi/msabi.exp
new file mode 100644
index 00000000000..d89f78f7ae1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/msabi/msabi.exp
@@ -0,0 +1,129 @@
+# Copyright (C) 2017 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 GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+# Exit immediately if this isn't a native x86_64 GNU target.
+if { ![istarget x86_64-*-gnu] || ![isnative] } then {
+    unsupported "$subdir"
+    return
+}
+
+global DG_TORTURE_OPTIONS
+
+# Load procedures from common libraries.
+load_lib gcc-dg.exp
+load_lib c-torture.exp
+
+dg-init
+
+proc runtest_msabi { cflags generator_args } {
+    global GCC_UNDER_TEST HOSTCXX HOSTCXXFLAGS tmpdir srcdir subdir
+
+    set objdir "$tmpdir/msabi"
+    set generator "$tmpdir/msabi_generate.exe"
+    set generated_header "$objdir/msabi-generated.h"
+    set do_test_o "$objdir/do_test.o"
+    set msabi_o "$objdir/msabi.o"
+    set msabi_exe "$objdir/msabi.exe"
+    set status 0
+
+    file delete -force $objdir
+    file mkdir $objdir
+
+    # Build the generator (only needs to be done once).
+    set src "$srcdir/$subdir/gen.cc"
+    if { (![file exists "$generator"]) || ([file mtime "$generator"]
+					 < [file mtime "$src"]) } {
+	# Temporarily switch to the environment for the host compiler.
+	restore_ld_library_path_env_vars
+	set cxx "$HOSTCXX $HOSTCXXFLAGS"
+	set status [remote_exec host "$cxx -o $generator $src"]
+	set status [lindex $status 0]
+	set_ld_library_path_env_vars
+	if { $status != 0 } then {
+	    warning "Could not build $subdir generator"
+	}
+    }
+
+    # Generate header
+    if { $status == 0 } then {
+	set status [remote_exec host "$generator $generator_args $generated_header"]
+	set status [lindex $status 0]
+	if { $status != 0 } then {
+	    warning "Could not generate $generated_header"
+	}
+    }
+
+    set cc "$GCC_UNDER_TEST -I$objdir -I$srcdir/$subdir $cflags"
+
+    # Assemble do_test.S
+    set src "$srcdir/$subdir/do_test.S"
+    if { $status == 0 } then {
+	set status [remote_exec build "$cc -c -o $do_test_o $src"]
+	set status [lindex $status 0]
+	if { $status != 0 } then {
+	    warning "Could not assemble $src"
+	}
+    }
+
+    # Build msabi.c
+    set src "$srcdir/$subdir/msabi.c"
+    if { $status == 0 } then {
+	set status [remote_exec build "$cc -c -o $msabi_o $src" "" "" "" 7200]
+	set status [lindex $status 0]
+	if { $status != 0 } then {
+	    warning "Could not build $src."
+	}
+    }
+
+    # Link
+    if { $status == 0 } then {
+	set status [remote_exec build "$cc -o $msabi_exe $msabi_o $do_test_o"]
+	set status [lindex $status 0]
+	if { $status != 0 } then {
+	    warning "Link failed."
+	}
+    }
+
+    # Execute
+    if { $status == 0 } then {
+	set status [remote_exec build "$msabi_exe"]
+	set status [lindex $status 0]
+    }
+
+    if { $status != 0 } then {
+	fail $subdir
+    } else {
+	pass $subdir
+    }
+}
+
+foreach options $DG_TORTURE_OPTIONS {
+    set gen_extra_options ""
+    if { [string match *-O0* "$options"]
+		    || [string match *-fno-omit-frame-pointer* "$options"]} {
+	set gen_extra_options "--omit-rbp-clobbers"
+    }
+
+    for {set i 0} {$i < 5} {incr i} {
+      runtest_msabi "$options" "-p$i $gen_extra_options"
+    }
+}
+
+dg-finish



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]