mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-11 15:10:12 +08:00
jit.exp: support C++ testcases
gcc/jit/ChangeLog: * TODO.rst (Test suite): Remove item about running C++ testcases. * docs/internals/index.rst (Working on the JIT library): Add "c++" to the enabled languages in the suggested "configure" invocation, and add a description of why this is necessary. * docs/_build/texinfo/libgccjit.texi: Regenerate. gcc/testsuite/ChangeLog: * jit.dg/jit.exp: Load wrapper.exp with %{tool} set to "g++" rather than "jit". Load g++.exp, and call g++_init. Run test-*.cc files within the testsuite and *.cc files within docs/examples. (jit-dg-test): Drop the addition of -fgnu89-inline to DEFAULT_CFLAGS in favor of adding it to additional_flags, only doing it when compiling C testcases (since g++ does not handle it). Reset "orig_environment_saved" so that LD_LIBRARY_PATH is restored to the value after g++_init ran, rather than the value before g++_init ran. Return a list of $comp_output $output_file, as dg-test assumes. From-SVN: r219318
This commit is contained in:
parent
23608da4db
commit
433d16df13
@ -1,3 +1,11 @@
|
||||
2015-01-07 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
* TODO.rst (Test suite): Remove item about running C++ testcases.
|
||||
* docs/internals/index.rst (Working on the JIT library): Add
|
||||
"c++" to the enabled languages in the suggested "configure"
|
||||
invocation, and add a description of why this is necessary.
|
||||
* docs/_build/texinfo/libgccjit.texi: Regenerate.
|
||||
|
||||
2015-01-07 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
* docs/internals/index.rst: Update to reflect that built
|
||||
|
@ -81,8 +81,6 @@ Bugs
|
||||
|
||||
Test suite
|
||||
==========
|
||||
* get DejaGnu to build and run C++ testcases
|
||||
|
||||
* measure code coverage in testing of libgccjit.so
|
||||
|
||||
Future milestones
|
||||
|
17
gcc/jit/docs/_build/texinfo/libgccjit.texi
vendored
17
gcc/jit/docs/_build/texinfo/libgccjit.texi
vendored
@ -11937,7 +11937,7 @@ PREFIX=$(pwd)/install
|
||||
cd build
|
||||
../src/configure \
|
||||
--enable-host-shared \
|
||||
--enable-languages=jit \
|
||||
--enable-languages=jit,c++ \
|
||||
--disable-bootstrap \
|
||||
--enable-checking=release \
|
||||
--prefix=$PREFIX
|
||||
@ -11968,12 +11968,23 @@ position-independent code, which incurs a slight performance hit,
|
||||
but it necessary for a shared library.
|
||||
@end deffn
|
||||
|
||||
@geindex command line option; --enable-languages=jit
|
||||
@geindex command line option; --enable-languages=jit@comma{}c++
|
||||
@anchor{internals/index cmdoption--enable-languages}@anchor{177}
|
||||
@deffn {Option} --enable-languages=jit
|
||||
@deffn {Option} --enable-languages=jit,c++
|
||||
|
||||
This specifies which frontends to build. The JIT library looks like
|
||||
a frontend to the rest of the code.
|
||||
|
||||
The C++ portion of the JIT test suite requires the C++ frontend to be
|
||||
enabled at configure-time, or you may see errors like this when
|
||||
running the test suite:
|
||||
|
||||
@example
|
||||
xgcc: error: /home/david/jit/src/gcc/testsuite/jit.dg/test-quadratic.cc: C++ compiler not installed on this system
|
||||
c++: error trying to exec 'cc1plus': execvp: No such file or directory
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
@end deffn
|
||||
|
||||
@geindex command line option; --disable-bootstrap
|
||||
|
@ -31,7 +31,7 @@ the JIT library like this:
|
||||
cd build
|
||||
../src/configure \
|
||||
--enable-host-shared \
|
||||
--enable-languages=jit \
|
||||
--enable-languages=jit,c++ \
|
||||
--disable-bootstrap \
|
||||
--enable-checking=release \
|
||||
--prefix=$PREFIX
|
||||
@ -54,11 +54,20 @@ Here's what those configuration options mean:
|
||||
position-independent code, which incurs a slight performance hit,
|
||||
but it necessary for a shared library.
|
||||
|
||||
.. option:: --enable-languages=jit
|
||||
.. option:: --enable-languages=jit,c++
|
||||
|
||||
This specifies which frontends to build. The JIT library looks like
|
||||
a frontend to the rest of the code.
|
||||
|
||||
The C++ portion of the JIT test suite requires the C++ frontend to be
|
||||
enabled at configure-time, or you may see errors like this when
|
||||
running the test suite:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
xgcc: error: /home/david/jit/src/gcc/testsuite/jit.dg/test-quadratic.cc: C++ compiler not installed on this system
|
||||
c++: error trying to exec 'cc1plus': execvp: No such file or directory
|
||||
|
||||
.. option:: --disable-bootstrap
|
||||
|
||||
For hacking on the "jit" subdirectory, performing a full
|
||||
|
@ -1,3 +1,17 @@
|
||||
2015-01-07 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
* jit.dg/jit.exp: Load wrapper.exp with %{tool} set to "g++"
|
||||
rather than "jit". Load g++.exp, and call g++_init.
|
||||
Run test-*.cc files within the testsuite and *.cc files within
|
||||
docs/examples.
|
||||
(jit-dg-test): Drop the addition of -fgnu89-inline to
|
||||
DEFAULT_CFLAGS in favor of adding it to additional_flags, only
|
||||
doing it when compiling C testcases (since g++ does not handle
|
||||
it). Reset "orig_environment_saved" so that LD_LIBRARY_PATH
|
||||
is restored to the value after g++_init ran, rather than the
|
||||
value before g++_init ran. Return a list of
|
||||
$comp_output $output_file, as dg-test assumes.
|
||||
|
||||
2015-01-07 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
* jit.dg/harness.h (CHECK_NON_NULL): Add __func__ to output, to
|
||||
|
@ -14,6 +14,20 @@
|
||||
# up into the Tcl world, reporting a summary of all results
|
||||
# across all of the executables.
|
||||
|
||||
# Kludge alert:
|
||||
# We need g++_init so that it can find the stdlib include path.
|
||||
#
|
||||
# g++_init (in lib/g++.exp) uses g++_maybe_build_wrapper,
|
||||
# which normally comes from the definition of
|
||||
# ${tool}_maybe_build_wrapper within lib/wrapper.exp.
|
||||
#
|
||||
# However, for us, ${tool} is "jit".
|
||||
# Hence we load wrapper.exp with tool == "g++", so that
|
||||
# g++_maybe_build_wrapper is defined.
|
||||
set tool g++
|
||||
load_lib wrapper.exp
|
||||
set tool jit
|
||||
|
||||
load_lib dg.exp
|
||||
load_lib prune.exp
|
||||
load_lib target-supports.exp
|
||||
@ -21,6 +35,7 @@ load_lib gcc-defs.exp
|
||||
load_lib timeout.exp
|
||||
load_lib target-libpath.exp
|
||||
load_lib gcc.exp
|
||||
load_lib g++.exp
|
||||
load_lib dejagnu.exp
|
||||
|
||||
# Look for lines of the form:
|
||||
@ -264,17 +279,25 @@ if ![info exists GCC_UNDER_TEST] {
|
||||
set GCC_UNDER_TEST "[find_gcc]"
|
||||
}
|
||||
|
||||
g++_init
|
||||
|
||||
# Initialize dg.
|
||||
dg-init
|
||||
|
||||
# Gather a list of all tests.
|
||||
|
||||
# Tests within the testsuite: gcc/testsuite/jit.dg/test-*.c
|
||||
set tests [lsort [find $srcdir/$subdir test-*.c]]
|
||||
# C tests within the testsuite: gcc/testsuite/jit.dg/test-*.c
|
||||
set tests [find $srcdir/$subdir test-*.c]
|
||||
|
||||
# C++ tests within the testsuite: gcc/testsuite/jit.dg/test-*.cc
|
||||
set tests [concat $tests [find $srcdir/$subdir test-*.cc]]
|
||||
|
||||
# We also test the examples within the documentation, to ensure that
|
||||
# they compile:
|
||||
set tests [lsort [concat $tests [find $srcdir/../jit/docs/examples *.c]]]
|
||||
set tests [concat $tests [find $srcdir/../jit/docs/examples *.c]]
|
||||
set tests [concat $tests [find $srcdir/../jit/docs/examples *.cc]]
|
||||
|
||||
set tests [lsort $tests]
|
||||
|
||||
verbose "tests: $tests"
|
||||
|
||||
@ -318,8 +341,24 @@ proc jit-dg-test { prog do_what extra_tool_flags } {
|
||||
verbose "output_file: $output_file"
|
||||
|
||||
# Create the test executable:
|
||||
set comp_output [gcc_target_compile $prog $output_file $do_what \
|
||||
"{additional_flags=$extra_tool_flags}"]
|
||||
set extension [file extension $prog]
|
||||
if {$extension == ".cc"} {
|
||||
set compilation_function "g++_target_compile"
|
||||
set options "{additional_flags=$extra_tool_flags}"
|
||||
} else {
|
||||
set compilation_function "gcc_target_compile"
|
||||
# Until recently, <dejagnu.h> assumed -fgnu89-inline
|
||||
# Ideally we should fixincludes it (PR other/63613), but
|
||||
# for now add -fgnu89-inline when compiling C JIT testcases.
|
||||
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63613
|
||||
# and http://lists.gnu.org/archive/html/dejagnu/2014-10/msg00011.html
|
||||
set options "{additional_flags=$extra_tool_flags -fgnu89-inline}"
|
||||
}
|
||||
verbose "compilation_function=$compilation_function"
|
||||
verbose "options=$options"
|
||||
|
||||
set comp_output [$compilation_function $prog $output_file \
|
||||
"executable" $options]
|
||||
upvar 1 name name
|
||||
if ![jit_check_compile "$name" "initial compilation" \
|
||||
$output_file $comp_output] then {
|
||||
@ -332,6 +371,28 @@ proc jit-dg-test { prog do_what extra_tool_flags } {
|
||||
# We need to set LD_LIBRARY_PATH so that the test files can find
|
||||
# libgccjit.so
|
||||
# Do this using set_ld_library_path_env_vars from target-libpath.exp
|
||||
# We will restore the old value later using
|
||||
# restore_ld_library_path_env_vars.
|
||||
|
||||
# Unfortunately this API only supports a single saved value, rather
|
||||
# than a stack, and g++_init has already called into this API,
|
||||
# injecting the appropriate value for LD_LIBRARY_PATH for finding
|
||||
# the built copy of libstdc++.
|
||||
# Hence the call to restore_ld_library_path_env_vars would restore
|
||||
# the *initial* value of LD_LIBRARY_PATH, and attempts to run
|
||||
# a C++ testcase after running any prior testcases would thus look
|
||||
# in the wrong place for libstdc++. This led to failures at startup
|
||||
# of the form:
|
||||
# ./tut01-hello-world.cc.exe: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./tut01-hello-world.cc.exe)
|
||||
# when the built libstdc++ is more recent that the system libstdc++.
|
||||
#
|
||||
# As a workaround, reset the variable "orig_environment_saved" within
|
||||
# target-libpath.exp, so that the {set|restore}_ld_library_path_env_vars
|
||||
# API saves/restores the current value of LD_LIBRARY_PATH (as set up
|
||||
# by g++_init).
|
||||
global orig_environment_saved
|
||||
set orig_environment_saved 0
|
||||
|
||||
global ld_library_path
|
||||
global base_dir
|
||||
set ld_library_path "$base_dir/../../"
|
||||
@ -394,17 +455,14 @@ proc jit-dg-test { prog do_what extra_tool_flags } {
|
||||
}
|
||||
|
||||
restore_ld_library_path_env_vars
|
||||
|
||||
return [list $comp_output $output_file]
|
||||
}
|
||||
|
||||
# We need to link with --export-dynamic for test-calling-external-function.c
|
||||
# so that the JIT-built code can call into functions from the main program.
|
||||
set DEFAULT_CFLAGS "-I$srcdir/../jit -lgccjit -g -Wall -Werror -Wl,--export-dynamic"
|
||||
|
||||
# <dejagnu.h> assumes -fgnu89-inline
|
||||
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63613
|
||||
# and http://lists.gnu.org/archive/html/dejagnu/2014-10/msg00011.html
|
||||
append DEFAULT_CFLAGS " -fgnu89-inline"
|
||||
|
||||
# Main loop. This will invoke jig-dg-test on each test-*.c file.
|
||||
dg-runtest $tests "" $DEFAULT_CFLAGS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user