Commit afd9da8b by Iain Buclaw

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.
parent 85f6f317
d1a606599e7c2bea8fda8bf5e3ddceb486ae69ac 3e10e2dd29e583f1d94d84de5e4bd858e0303669
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository. merge done from the dlang/dmd repository.
2020-03-29 Iain Buclaw <ibuclaw@gdcproject.org> 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. * gdc.test/compilable/compilable.exp: New file.
* gdc.test/fail_compilation/fail_compilation.exp: New file. * gdc.test/fail_compilation/fail_compilation.exp: New file.
* gdc.test/runnable/runnable.exp: New file. * gdc.test/runnable/runnable.exp: New file.
......
# 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
...@@ -404,6 +404,7 @@ proc gdc-do-test { testcases } { ...@@ -404,6 +404,7 @@ proc gdc-do-test { testcases } {
set options [gdc-permute-options [lsort -unique $PERMUTE_ARGS]] set options [gdc-permute-options [lsort -unique $PERMUTE_ARGS]]
switch $dir { switch $dir {
runnable_cxx -
runnable { runnable {
for { set i 0 } { $i<[llength $options] } { incr i } { for { set i 0 } { $i<[llength $options] } { incr i } {
set flags [lindex $options $i] set flags [lindex $options $i]
......
...@@ -69,6 +69,7 @@ proc gdc_version { } { ...@@ -69,6 +69,7 @@ proc gdc_version { } {
proc gdc_include_flags { paths } { proc gdc_include_flags { paths } {
global srcdir global srcdir
global GDC_INCLUDE_CXX_FLAGS
global TESTING_IN_BUILD_TREE global TESTING_IN_BUILD_TREE
set flags "" set flags ""
...@@ -77,6 +78,12 @@ proc gdc_include_flags { paths } { ...@@ -77,6 +78,12 @@ proc gdc_include_flags { paths } {
return "${flags}" 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} set gccpath ${paths}
if { $gccpath != "" } { if { $gccpath != "" } {
...@@ -88,11 +95,13 @@ proc gdc_include_flags { paths } { ...@@ -88,11 +95,13 @@ proc gdc_include_flags { paths } {
append flags "-I${srcdir}/../../libphobos/src " append flags "-I${srcdir}/../../libphobos/src "
# For the tests that mix C++ and D, need to know where headers are located. # For the tests that mix C++ and D, need to know where headers are located.
set odir [lookfor_file ${gccpath} libstdc++-v3] if $include_cxx_flags {
if { ${odir} != "" } { set odir [lookfor_file ${gccpath} libstdc++-v3]
set cxxflags [exec sh ${odir}/scripts/testsuite_flags --build-includes] if { ${odir} != "" && [file exists ${odir}/scripts/testsuite_flags] } {
set idx [lsearch $cxxflags "-nostdinc++"] set cxxflags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
append flags [lreplace $cxxflags $idx $idx] set idx [lsearch $cxxflags "-nostdinc++"]
append flags [lreplace $cxxflags $idx $idx]
}
} }
return "$flags" return "$flags"
...@@ -106,6 +115,7 @@ proc gdc_link_flags { paths } { ...@@ -106,6 +115,7 @@ proc gdc_link_flags { paths } {
global srcdir global srcdir
global ld_library_path global ld_library_path
global GDC_UNDER_TEST global GDC_UNDER_TEST
global GDC_INCLUDE_CXX_FLAGS
global shlib_ext global shlib_ext
global SHARED_OPTION global SHARED_OPTION
...@@ -117,6 +127,12 @@ proc gdc_link_flags { paths } { ...@@ -117,6 +127,12 @@ proc gdc_link_flags { paths } {
set SHARED_OPTION "" set SHARED_OPTION ""
verbose "shared lib extension: $shlib_ext" 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 != "" } { if { $gccpath != "" } {
# Path to libgphobos.spec. # Path to libgphobos.spec.
append flags "-B${gccpath}/libphobos/src " append flags "-B${gccpath}/libphobos/src "
...@@ -148,11 +164,13 @@ proc gdc_link_flags { paths } { ...@@ -148,11 +164,13 @@ proc gdc_link_flags { paths } {
if [file exists "${gccpath}/libiberty/libiberty.a"] { if [file exists "${gccpath}/libiberty/libiberty.a"] {
append flags "-L${gccpath}/libiberty " append flags "-L${gccpath}/libiberty "
} }
# For the tests that mix C++ and D, we should try and handle this better. # For the tests that mix C++ and D, need to know where library is located.
if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \ if $include_cxx_flags {
|| [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } { if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
append flags "-L${gccpath}/libstdc++-v3/src/.libs " || [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs" 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] append ld_library_path [gcc-set-multilib-library-path $GDC_UNDER_TEST]
} else { } else {
...@@ -172,6 +190,13 @@ proc gdc_link_flags { paths } { ...@@ -172,6 +190,13 @@ proc gdc_link_flags { paths } {
if { $libiberty != "" } { if { $libiberty != "" } {
append flags "-L${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 set_ld_library_path_env_vars
...@@ -184,18 +209,14 @@ proc gdc_link_flags { paths } { ...@@ -184,18 +209,14 @@ proc gdc_link_flags { paths } {
# #
proc gdc_init { args } { proc gdc_init { args } {
global subdir
global gdc_initialized global gdc_initialized
global base_dir global base_dir
global tmpdir global tmpdir
global libdir global libdir
global gluefile wrap_flags global gluefile wrap_flags
global objdir srcdir global TOOL_EXECUTABLE
global ALWAYS_DFLAGS
global TOOL_EXECUTABLE TOOL_OPTIONS
global GDC_UNDER_TEST global GDC_UNDER_TEST
global TESTING_IN_BUILD_TREE global TESTING_IN_BUILD_TREE
global TEST_ALWAYS_FLAGS
global gcc_warning_prefix global gcc_warning_prefix
global gcc_error_prefix global gcc_error_prefix
...@@ -231,31 +252,6 @@ proc gdc_init { args } { ...@@ -231,31 +252,6 @@ proc gdc_init { args } {
gdc_maybe_build_wrapper "${tmpdir}/d-testglue.o" 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_warning_prefix "warning:"
set gcc_error_prefix "(fatal )?error:" set gcc_error_prefix "(fatal )?error:"
...@@ -269,18 +265,44 @@ proc gdc_init { args } { ...@@ -269,18 +265,44 @@ proc gdc_init { args } {
proc gdc_target_compile { source dest type options } { proc gdc_target_compile { source dest type options } {
global tmpdir global tmpdir
global gluefile wrap_flags global gluefile wrap_flags
global ALWAYS_DFLAGS
global GDC_UNDER_TEST global GDC_UNDER_TEST
global TOOL_OPTIONS
global TEST_ALWAYS_FLAGS
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
lappend options "libs=${gluefile}" lappend options "libs=${gluefile}"
lappend options "ldflags=${wrap_flags}" 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 "timeout=[timeout_value]"
lappend options "compiler=$GDC_UNDER_TEST" 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] set options [dg-additional-files-options $options $source]
return [target_compile $source $dest $type $options] return [target_compile $source $dest $type $options]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment