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 +# . + +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