testsuite: Move C++ tests in gdc.test into own subdirectory.

Tests have been moved into runnable_cxx as part of upstream dmd 3e10e2dd2.

The extra flags required for tests that mix C++ and D are now limited to
only a small subset of tests, rather than applied to all tests across
gdc.dg and gdc.test.

Reviewed-on: https://github.com/dlang/dmd/pull/10980

gcc/testsuite/ChangeLog:

	* gdc.test/runnable_cxx/runnable_cxx.exp: New file.
	* lib/gdc-utils.exp (gdc-do-test): Add case for runnable_cxx.
	* lib/gdc.exp (gdc_include_flags): Only add flags for libstdc++-v3 if
	GDC_INCLUDE_CXX_FLAGS is true.
	(gdc_link_flags): Likewise.
	(gdc_init): Move setting of default gdc test flags to...
	(gdc_target_compile): ...here.
This commit is contained in:
Iain Buclaw 2020-03-29 13:27:22 +02:00
parent 85f6f317ec
commit afd9da8b8a
15 changed files with 122 additions and 43 deletions

View File

@ -1,4 +1,4 @@
d1a606599e7c2bea8fda8bf5e3ddceb486ae69ac
3e10e2dd29e583f1d94d84de5e4bd858e0303669
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.

View File

@ -1,3 +1,13 @@
2020-03-29 Iain Buclaw <ibuclaw@gdcproject.org>
* gdc.test/runnable_cxx/runnable_cxx.exp: New file.
* lib/gdc-utils.exp (gdc-do-test): Add case for runnable_cxx.
* lib/gdc.exp (gdc_include_flags): Only add flags for libstdc++-v3 if
GDC_INCLUDE_CXX_FLAGS is true.
(gdc_link_flags): Likewise.
(gdc_init): Move setting of default gdc test flags to...
(gdc_target_compile): ...here.
2020-03-29 Iain Buclaw <ibuclaw@gdcproject.org>
* gdc.test/compilable/compilable.exp: New file.

View File

@ -0,0 +1,46 @@
# Copyright (C) 2012-2020 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/>.
# Runnable C++ tests for the D2 testsuite.
# Load support procs.
load_lib gdc-dg.exp
load_lib gdc-utils.exp
# If the D runtime library is missing, bail.
if { ![check_effective_target_d_runtime] } {
return
}
# We are mixing D and C++ code, need to pull in libstdc++
global GDC_INCLUDE_CXX_FLAGS
set GDC_INCLUDE_CXX_FLAGS 1
# Initialize `dg'.
dg-init
# Main loop.
if [check_no_compiler_messages extern_c++_tests assembly {
// C++
int main() { return 0; }
}] {
gdc-do-test [glob -nocomplain $srcdir/$subdir/*.d]
}
set GDC_INCLUDE_CXX_FLAGS 0
# All done.
dg-finish

View File

@ -404,6 +404,7 @@ proc gdc-do-test { testcases } {
set options [gdc-permute-options [lsort -unique $PERMUTE_ARGS]]
switch $dir {
runnable_cxx -
runnable {
for { set i 0 } { $i<[llength $options] } { incr i } {
set flags [lindex $options $i]

View File

@ -69,6 +69,7 @@ proc gdc_version { } {
proc gdc_include_flags { paths } {
global srcdir
global GDC_INCLUDE_CXX_FLAGS
global TESTING_IN_BUILD_TREE
set flags ""
@ -77,6 +78,12 @@ proc gdc_include_flags { paths } {
return "${flags}"
}
if [info exists GDC_INCLUDE_CXX_FLAGS] {
set include_cxx_flags $GDC_INCLUDE_CXX_FLAGS
} else {
set include_cxx_flags 0
}
set gccpath ${paths}
if { $gccpath != "" } {
@ -88,11 +95,13 @@ proc gdc_include_flags { paths } {
append flags "-I${srcdir}/../../libphobos/src "
# For the tests that mix C++ and D, need to know where headers are located.
set odir [lookfor_file ${gccpath} libstdc++-v3]
if { ${odir} != "" } {
set cxxflags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
set idx [lsearch $cxxflags "-nostdinc++"]
append flags [lreplace $cxxflags $idx $idx]
if $include_cxx_flags {
set odir [lookfor_file ${gccpath} libstdc++-v3]
if { ${odir} != "" && [file exists ${odir}/scripts/testsuite_flags] } {
set cxxflags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
set idx [lsearch $cxxflags "-nostdinc++"]
append flags [lreplace $cxxflags $idx $idx]
}
}
return "$flags"
@ -106,6 +115,7 @@ proc gdc_link_flags { paths } {
global srcdir
global ld_library_path
global GDC_UNDER_TEST
global GDC_INCLUDE_CXX_FLAGS
global shlib_ext
global SHARED_OPTION
@ -117,6 +127,12 @@ proc gdc_link_flags { paths } {
set SHARED_OPTION ""
verbose "shared lib extension: $shlib_ext"
if [info exists GDC_INCLUDE_CXX_FLAGS] {
set include_cxx_flags $GDC_INCLUDE_CXX_FLAGS
} else {
set include_cxx_flags 0
}
if { $gccpath != "" } {
# Path to libgphobos.spec.
append flags "-B${gccpath}/libphobos/src "
@ -148,11 +164,13 @@ proc gdc_link_flags { paths } {
if [file exists "${gccpath}/libiberty/libiberty.a"] {
append flags "-L${gccpath}/libiberty "
}
# For the tests that mix C++ and D, we should try and handle this better.
if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
|| [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
append flags "-L${gccpath}/libstdc++-v3/src/.libs "
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
# For the tests that mix C++ and D, need to know where library is located.
if $include_cxx_flags {
if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
|| [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
append flags "-L${gccpath}/libstdc++-v3/src/.libs "
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
}
}
append ld_library_path [gcc-set-multilib-library-path $GDC_UNDER_TEST]
} else {
@ -172,6 +190,13 @@ proc gdc_link_flags { paths } {
if { $libiberty != "" } {
append flags "-L${libiberty} "
}
if $include_cxx_flags {
set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]
if { $libstdcpp != "" } {
append flags "-L${libstdcpp} "
append ld_library_path ":${libstdcpp}"
}
}
}
set_ld_library_path_env_vars
@ -184,18 +209,14 @@ proc gdc_link_flags { paths } {
#
proc gdc_init { args } {
global subdir
global gdc_initialized
global base_dir
global tmpdir
global libdir
global gluefile wrap_flags
global objdir srcdir
global ALWAYS_DFLAGS
global TOOL_EXECUTABLE TOOL_OPTIONS
global TOOL_EXECUTABLE
global GDC_UNDER_TEST
global TESTING_IN_BUILD_TREE
global TEST_ALWAYS_FLAGS
global gcc_warning_prefix
global gcc_error_prefix
@ -231,31 +252,6 @@ proc gdc_init { args } {
gdc_maybe_build_wrapper "${tmpdir}/d-testglue.o"
set ALWAYS_DFLAGS ""
# TEST_ALWAYS_FLAGS are flags that should be passed to every
# compilation. They are passed first to allow individual
# tests to override them.
if [info exists TEST_ALWAYS_FLAGS] {
lappend ALWAYS_DFLAGS "additional_flags=$TEST_ALWAYS_FLAGS"
}
if ![is_remote host] {
if [info exists TOOL_OPTIONS] {
lappend ALWAYS_DFLAGS "additional_flags=[gdc_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
lappend ALWAYS_DFLAGS "ldflags=[gdc_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
} else {
lappend ALWAYS_DFLAGS "additional_flags=[gdc_include_flags [get_multilibs] ]"
lappend ALWAYS_DFLAGS "ldflags=[gdc_link_flags [get_multilibs] ]"
}
}
if [info exists TOOL_OPTIONS] {
lappend ALWAYS_DFLAGS "additional_flags=$TOOL_OPTIONS"
}
verbose -log "ALWAYS_DFLAGS set to $ALWAYS_DFLAGS"
set gcc_warning_prefix "warning:"
set gcc_error_prefix "(fatal )?error:"
@ -269,18 +265,44 @@ proc gdc_init { args } {
proc gdc_target_compile { source dest type options } {
global tmpdir
global gluefile wrap_flags
global ALWAYS_DFLAGS
global GDC_UNDER_TEST
global TOOL_OPTIONS
global TEST_ALWAYS_FLAGS
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
lappend options "libs=${gluefile}"
lappend options "ldflags=${wrap_flags}"
}
set always_dflags ""
# TEST_ALWAYS_FLAGS are flags that should be passed to every
# compilation. They are passed first to allow individual
# tests to override them.
if [info exists TEST_ALWAYS_FLAGS] {
lappend always_dflags "additional_flags=$TEST_ALWAYS_FLAGS"
}
if ![is_remote host] {
if [info exists TOOL_OPTIONS] {
lappend always_dflags "additional_flags=[gdc_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
lappend always_dflags "ldflags=[gdc_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
} else {
lappend always_dflags "additional_flags=[gdc_include_flags [get_multilibs] ]"
lappend always_dflags "ldflags=[gdc_link_flags [get_multilibs] ]"
}
}
if [info exists TOOL_OPTIONS] {
lappend always_dflags "additional_flags=$TOOL_OPTIONS"
}
verbose "always_dflags set to: $always_dflags"
lappend options "timeout=[timeout_value]"
lappend options "compiler=$GDC_UNDER_TEST"
set options [concat "$ALWAYS_DFLAGS" $options]
set options [concat "$always_dflags" $options]
set options [dg-additional-files-options $options $source]
return [target_compile $source $dest $type $options]
}