1 |
693 |
jeremybenn |
# Copyright (C) 2002, 2004, 2007 Free Software Foundation, Inc.
|
2 |
|
|
|
3 |
|
|
# This program is free software; you can redistribute it and/or modify
|
4 |
|
|
# it under the terms of the GNU General Public License as published by
|
5 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
6 |
|
|
# (at your option) any later version.
|
7 |
|
|
#
|
8 |
|
|
# This program is distributed in the hope that it will be useful,
|
9 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11 |
|
|
# GNU General Public License for more details.
|
12 |
|
|
#
|
13 |
|
|
# You should have received a copy of the GNU General Public License
|
14 |
|
|
# along with GCC; see the file COPYING3. If not see
|
15 |
|
|
# .
|
16 |
|
|
#
|
17 |
|
|
# This file was written by Janis Johnson,
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
# Test interoperability of two compilers that follow the same ABI.
|
21 |
|
|
#
|
22 |
|
|
# Break simple tests into two pieces and see that they work when linked
|
23 |
|
|
# together. If an alternate compiler is specified then the two main
|
24 |
|
|
# pieces of each test are compiled with different compilers. The
|
25 |
|
|
# alternate compiler must be installed, and is specified by defining
|
26 |
|
|
# ALT_CXX_UNDER_TEST in the environment.
|
27 |
|
|
|
28 |
|
|
if $tracelevel then {
|
29 |
|
|
strace $tracelevel
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
global GXX_UNDER_TEST
|
33 |
|
|
global ld_library_path
|
34 |
|
|
|
35 |
|
|
# Load procedures from common libraries.
|
36 |
|
|
load_lib standard.exp
|
37 |
|
|
load_lib g++.exp
|
38 |
|
|
load_lib target-libpath.exp
|
39 |
|
|
|
40 |
|
|
#
|
41 |
|
|
# compat-use-alt-compiler -- make the alternate compiler the default
|
42 |
|
|
#
|
43 |
|
|
proc compat-use-alt-compiler { } {
|
44 |
|
|
global GXX_UNDER_TEST ALT_CXX_UNDER_TEST
|
45 |
|
|
global CXXFLAGS
|
46 |
|
|
global ALWAYS_CXXFLAGS
|
47 |
|
|
global ld_library_path alt_ld_library_path
|
48 |
|
|
global same_alt
|
49 |
|
|
|
50 |
|
|
# We don't need to do this if the alternate compiler is actually
|
51 |
|
|
# the same as the compiler under test.
|
52 |
|
|
if { $same_alt == 0 } then {
|
53 |
|
|
set GXX_UNDER_TEST $ALT_CXX_UNDER_TEST
|
54 |
|
|
set CXXFLAGS ""
|
55 |
|
|
set ALWAYS_CXXFLAGS ""
|
56 |
|
|
set ld_library_path $alt_ld_library_path
|
57 |
|
|
set_ld_library_path_env_vars
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
#
|
62 |
|
|
# compat-use-tst-compiler -- make compiler under test the default
|
63 |
|
|
#
|
64 |
|
|
proc compat-use-tst-compiler { } {
|
65 |
|
|
global GXX_UNDER_TEST save_gxx_under_test
|
66 |
|
|
global CXXFLAGS save_cxxflags
|
67 |
|
|
global ALWAYS_CXXFLAGS save_always_cxxflags
|
68 |
|
|
global ld_library_path save_ld_library_path
|
69 |
|
|
global same_alt
|
70 |
|
|
|
71 |
|
|
# We don't need to do this if the alternate compiler is actually
|
72 |
|
|
# the same as the compiler under test.
|
73 |
|
|
|
74 |
|
|
if { $same_alt == 0 } then {
|
75 |
|
|
set GXX_UNDER_TEST $save_gxx_under_test
|
76 |
|
|
set CXXFLAGS $save_cxxflags
|
77 |
|
|
set ALWAYS_CXXFLAGS $save_always_cxxflags
|
78 |
|
|
set ld_library_path $save_ld_library_path
|
79 |
|
|
set_ld_library_path_env_vars
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
# Load the language-independent compabibility support procedures.
|
84 |
|
|
# This must be done after the compat-use-*-compiler definitions.
|
85 |
|
|
load_lib compat.exp
|
86 |
|
|
|
87 |
|
|
g++_init
|
88 |
|
|
|
89 |
|
|
# Save variables for the C++ compiler under test, which each test will
|
90 |
|
|
# change a couple of times. This must be done after calling g++-init.
|
91 |
|
|
set save_gxx_under_test $GXX_UNDER_TEST
|
92 |
|
|
set save_cxxflags $CXXFLAGS
|
93 |
|
|
set save_always_cxxflags $ALWAYS_CXXFLAGS
|
94 |
|
|
set save_ld_library_path $ld_library_path
|
95 |
|
|
|
96 |
|
|
# Define an identifier for use with this suite to avoid name conflicts
|
97 |
|
|
# with other compat tests running at the same time.
|
98 |
|
|
set sid "cp_compat"
|
99 |
|
|
|
100 |
|
|
# Find out whether there is an alternate compiler to test. If the
|
101 |
|
|
# variable is defined but is set to "same", that means we use the same
|
102 |
|
|
# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS
|
103 |
|
|
# are different.
|
104 |
|
|
set use_alt 0
|
105 |
|
|
set same_alt 0
|
106 |
|
|
set alt_ld_library_path "."
|
107 |
|
|
if [info exists ALT_CXX_UNDER_TEST] then {
|
108 |
|
|
set use_alt 1
|
109 |
|
|
if [string match "same" $ALT_CXX_UNDER_TEST] then {
|
110 |
|
|
set same_alt 1
|
111 |
|
|
} else {
|
112 |
|
|
if [info exists ALT_LD_LIBRARY_PATH] then {
|
113 |
|
|
append alt_ld_library_path ":${ALT_LD_LIBRARY_PATH}"
|
114 |
|
|
}
|
115 |
|
|
}
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
# Main loop.
|
119 |
|
|
foreach src [lsort [find $srcdir/$subdir *_main.C]] {
|
120 |
|
|
# If we're only testing specific files and this isn't one of them, skip it.
|
121 |
|
|
if ![runtest_file_p $runtests $src] then {
|
122 |
|
|
continue
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
compat-execute $src $sid $use_alt
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
# Restore the original compiler under test.
|
129 |
|
|
compat-use-tst-compiler
|