2017-01-01 13:07:43 +01:00
|
|
|
# Copyright (C) 2009-2017 Free Software Foundation, Inc.
|
2009-05-06 18:22:19 +02:00
|
|
|
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
# This file contains the support procedures for testing the plugin mechanism.
|
|
|
|
|
|
|
|
load_lib dg.exp
|
|
|
|
load_lib gcc.exp
|
|
|
|
|
|
|
|
#
|
|
|
|
# plugin-get-options -- process test directives
|
|
|
|
#
|
|
|
|
# SRC is the full pathname of the plugin source file.
|
|
|
|
#
|
|
|
|
proc plugin-get-options { src } {
|
|
|
|
# dg-options sets a variable called dg-extra-tool-flags.
|
|
|
|
set dg-extra-tool-flags ""
|
|
|
|
|
|
|
|
# dg-require-* sets dg-do-what.
|
|
|
|
upvar dg-do-what dg-do-what
|
|
|
|
|
|
|
|
set tmp [dg-get-options $src]
|
|
|
|
foreach op $tmp {
|
|
|
|
set cmd [lindex $op 0]
|
|
|
|
if { ![string compare "dg-options" $cmd] } {
|
|
|
|
set status [catch "$op" errmsg]
|
|
|
|
if { $status != 0 } {
|
|
|
|
perror "src: $errmsg for \"$op\"\n"
|
|
|
|
unresolved "$src: $errmsg for \"$op\""
|
|
|
|
return
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
# Ignore unrecognized dg- commands, but warn about them.
|
|
|
|
warning "plugin.exp does not support $cmd"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return flags to use for compiling the plugin source file
|
|
|
|
return ${dg-extra-tool-flags}
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# plugin-test-execute -- build the plugin first and then compile the
|
|
|
|
# test files with the plugin.
|
|
|
|
#
|
|
|
|
# PLUGIN_SRC is the full pathname of the plugin source file.
|
|
|
|
# PLUGIN_TESTS is a list of input test source files.
|
|
|
|
#
|
|
|
|
proc plugin-test-execute { plugin_src plugin_tests } {
|
|
|
|
global srcdir objdir
|
|
|
|
global verbose
|
|
|
|
global GMPINC
|
2010-03-05 23:52:02 +01:00
|
|
|
global PLUGINCC
|
|
|
|
global PLUGINCFLAGS
|
2009-05-06 18:22:19 +02:00
|
|
|
|
|
|
|
set basename [file tail $plugin_src]
|
|
|
|
set base [file rootname $basename]
|
|
|
|
set plugin_lib $base.so
|
|
|
|
|
2012-04-16 12:14:40 +02:00
|
|
|
set testcase [dg-trim-dirname $srcdir $plugin_src]
|
|
|
|
verbose "Test the plugin $testcase" 1
|
2009-05-06 18:22:19 +02:00
|
|
|
|
|
|
|
# Build the plugin itself
|
|
|
|
set extra_flags [plugin-get-options $plugin_src]
|
|
|
|
|
|
|
|
# Note that the plugin test support currently only works when the GCC
|
|
|
|
# build tree is available. (We make sure that is the case in plugin.exp.)
|
|
|
|
# Once we have figured out how/where to package/install GCC header files
|
|
|
|
# for general plugin support, we should modify the following include paths
|
|
|
|
# accordingly.
|
|
|
|
set gcc_srcdir "$srcdir/../.."
|
|
|
|
set gcc_objdir "$objdir/../../.."
|
|
|
|
set includes "-I. -I${srcdir} -I${gcc_srcdir}/gcc -I${gcc_objdir}/gcc \
|
|
|
|
-I${gcc_srcdir}/include -I${gcc_srcdir}/libcpp/include \
|
2010-07-16 12:41:36 +02:00
|
|
|
$GMPINC -I${gcc_objdir}/intl"
|
2009-05-06 18:22:19 +02:00
|
|
|
|
2010-04-26 22:33:49 +02:00
|
|
|
if { [ ishost *-*-darwin* ] } {
|
2010-11-04 11:43:47 +01:00
|
|
|
# -mdynamic-no-pic is incompatible with -fPIC.
|
|
|
|
set plug_cflags ""
|
|
|
|
foreach op $PLUGINCFLAGS {
|
|
|
|
if { [string compare "-mdynamic-no-pic" $op] } {
|
|
|
|
set plug_cflags [concat $plug_cflags " $op"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set optstr "$includes"
|
|
|
|
foreach op $extra_flags {
|
|
|
|
if { [string compare "-mdynamic-no-pic" $op] } {
|
|
|
|
set optstr [concat $optstr " $op"]
|
|
|
|
}
|
|
|
|
}
|
2013-08-07 03:25:22 +02:00
|
|
|
set optstr [concat $optstr "-DIN_GCC -fPIC -shared -fno-rtti -undefined dynamic_lookup"]
|
2010-11-04 11:43:47 +01:00
|
|
|
} else {
|
|
|
|
set plug_cflags $PLUGINCFLAGS
|
2013-08-05 22:19:29 +02:00
|
|
|
set optstr "$includes $extra_flags -DIN_GCC -fPIC -shared -fno-rtti"
|
2010-04-26 22:33:49 +02:00
|
|
|
}
|
|
|
|
|
2010-03-05 23:52:02 +01:00
|
|
|
# Temporarily switch to the environment for the plugin compiler.
|
2009-05-06 23:31:56 +02:00
|
|
|
restore_ld_library_path_env_vars
|
2010-11-04 11:43:47 +01:00
|
|
|
set status [remote_exec build "$PLUGINCC $plug_cflags $plugin_src $optstr -o $plugin_lib"]
|
2009-05-06 23:31:56 +02:00
|
|
|
set status [lindex $status 0]
|
|
|
|
set_ld_library_path_env_vars
|
|
|
|
|
|
|
|
if { $status != 0 } then {
|
2012-04-16 12:14:40 +02:00
|
|
|
fail "$testcase compilation"
|
|
|
|
# Strictly, this is wrong: the tests compiled with the plugin should
|
|
|
|
# become unresolved instead.
|
2009-05-06 18:22:19 +02:00
|
|
|
return
|
2012-04-16 12:14:40 +02:00
|
|
|
} else {
|
|
|
|
pass "$testcase compilation"
|
2009-05-06 18:22:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Compile the input source files with the plugin
|
|
|
|
global default_flags
|
|
|
|
set plugin_enabling_flags "-fplugin=./$plugin_lib"
|
|
|
|
dg-runtest $plugin_tests $plugin_enabling_flags $default_flags
|
|
|
|
|
|
|
|
# Clean up
|
|
|
|
remote_file build delete $plugin_lib
|
|
|
|
}
|