| 1 |
# Copyright (C) 2002-2025 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 |
# <http://www.gnu.org/licenses/>. |
| 16 |
# |
| 17 |
# This file was written by Janis Johnson, <[email protected]> |
| 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_CC_UNDER_TEST in the environment. |
| 27 |
|
| 28 |
if $tracelevel then { |
| 29 |
strace $tracelevel |
| 30 |
} |
| 31 |
|
| 32 |
global GCC_UNDER_TEST |
| 33 |
global ALT_CC_UNDER_TEST |
| 34 |
global compat_save_gcc_under_test |
| 35 |
global compat_use_alt |
| 36 |
global compat_same_alt |
| 37 |
global compat_have_dfp |
| 38 |
|
| 39 |
# Load procedures from common libraries. |
| 40 |
load_lib standard.exp |
| 41 |
load_lib gcc.exp |
| 42 |
|
| 43 |
# Load the language-dependent compatibility support procedures. |
| 44 |
load_lib c-compat.exp |
| 45 |
|
| 46 |
# Load the language-independent compabibility support procedures. |
| 47 |
load_lib compat.exp |
| 48 |
|
| 49 |
gcc_init |
| 50 |
|
| 51 |
# Save variables for the C compiler under test, which each test will |
| 52 |
# change a couple of times. This must be done after calling gcc-init. |
| 53 |
set compat_save_gcc_under_test $GCC_UNDER_TEST |
| 54 |
|
| 55 |
# Define an identifier for use with this suite to avoid name conflicts |
| 56 |
# with other compat tests running at the same time. |
| 57 |
set sid "c_compat" |
| 58 |
|
| 59 |
# Find out whether there is an alternate compiler to test. If the |
| 60 |
# variable is defined but is set to "same", that means we use the same |
| 61 |
# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS |
| 62 |
# are different. |
| 63 |
set compat_use_alt 0 |
| 64 |
set compat_same_alt 0 |
| 65 |
|
| 66 |
if [info exists ALT_CC_UNDER_TEST] then { |
| 67 |
set compat_use_alt 1 |
| 68 |
if [string match "same" $ALT_CC_UNDER_TEST] then { |
| 69 |
set compat_same_alt 1 |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
compat_setup_dfp |
| 74 |
|
| 75 |
# Main loop. |
| 76 |
foreach src [lsort [find $srcdir/$subdir *_main.c]] { |
| 77 |
# If we're only testing specific files and this isn't one of them, skip it. |
| 78 |
if ![runtest_file_p $runtests $src] then { |
| 79 |
continue |
| 80 |
} |
| 81 |
|
| 82 |
compat-execute $src $sid $compat_use_alt |
| 83 |
} |
| 84 |
|
| 85 |
# Restore the original compiler under test. |
| 86 |
compat-use-tst-compiler |