]>
Commit | Line | Data |
---|---|---|
a5544970 | 1 | # Copyright (C) 2005-2019 Free Software Foundation, Inc. |
99ff9e7a BE |
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 | |
cd976c16 | 5 | # the Free Software Foundation; either version 3 of the License, or |
99ff9e7a BE |
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 | |
cd976c16 NC |
14 | # along with GCC; see the file COPYING3. If not see |
15 | # <http://www.gnu.org/licenses/>. | |
99ff9e7a BE |
16 | |
17 | # Run the LANGUAGE compiler with GCC_OPTIONS and inspect the compiler, | |
18 | # assembler and linker output (from gcc -v) to make sure that they | |
19 | # match the patterns COMPILER_PATTERN, AS_PATTERN and LD_PATTERN, | |
20 | # respectively. | |
21 | ||
717c4789 JJ |
22 | load_lib gcc-defs.exp |
23 | ||
55466f20 NS |
24 | # disable for non-profile targets explitly, rather than |
25 | # rely on check-effective target. We're explicitly trying to check | |
26 | # profiling works, and if it doesn't check-effective-target will | |
27 | # simply skip the tests, rather than have this test shout at us. | |
28 | if [ istarget "nvptx-*-*" ] { return 0 } | |
29 | ||
717c4789 JJ |
30 | # These tests don't run runtest_file_p consistently if it |
31 | # doesn't return the same values, so disable parallelization | |
32 | # of this *.exp file. The first parallel runtest to reach | |
33 | # this will run all the tests serially. | |
34 | if ![gcc_parallel_test_run_p options] { | |
35 | return | |
36 | } | |
37 | gcc_parallel_test_enable 0 | |
38 | ||
1b1c508f | 39 | proc check_for_all_options {language gcc_options compiler_pattern as_pattern ld_pattern} { |
e4461577 BE |
40 | set filename test-[pid] |
41 | set fd [open $filename.c w] | |
42 | puts $fd "int main (void) \{ return 0; \}" | |
43 | close $fd | |
44 | remote_download host $filename.c | |
45 | ||
99ff9e7a BE |
46 | set test "compiler driver $gcc_options option(s)" |
47 | set gcc_options "\{additional_flags=$gcc_options -v\}" | |
99ff9e7a BE |
48 | |
49 | switch "$language" { | |
50 | "c" { set compiler cc1 } | |
51 | default { error "unknown language" } | |
52 | } | |
e4461577 BE |
53 | set gcc_output [gcc_target_compile $filename.c $filename.x executable $gcc_options] |
54 | remote_file build delete $filename.c $filename.x $filename.gcno | |
bb120fb0 TV |
55 | set dumpfiles [glob -nocomplain $filename.c.*] |
56 | foreach dumpfile $dumpfiles { | |
57 | remote_file build delete $dumpfile | |
58 | } | |
99ff9e7a | 59 | |
7cff41e8 | 60 | if {![regexp -- "/${compiler}(\\.exe)? -quiet.*$compiler_pattern" $gcc_output]} { |
99ff9e7a BE |
61 | fail "$test (compiler options)" |
62 | return | |
63 | } | |
7cff41e8 | 64 | if {![regexp -- " *as(\\.exe)? .*$as_pattern" $gcc_output]} { |
99ff9e7a BE |
65 | fail "$test (assembler options)" |
66 | return | |
67 | } | |
7cff41e8 | 68 | if {![regexp -- "/collect2(\\.exe)? .*$ld_pattern" $gcc_output]} { |
99ff9e7a BE |
69 | fail "$test (linker options)" |
70 | return | |
71 | } | |
72 | pass $test | |
73 | } | |
74 | ||
1b1c508f | 75 | check_for_all_options c {--coverage} {-fprofile-arcs -ftest-coverage} {} {-lgcov} |
717c4789 | 76 | |
bb120fb0 TV |
77 | proc get_dump_flags {} { |
78 | set res [list] | |
79 | ||
80 | global srcdir | |
81 | set file "$srcdir/../dumpfile.c" | |
82 | ||
83 | set a [open $file] | |
84 | set lines [split [read $a] "\n"] | |
85 | close $a | |
86 | ||
87 | set domatch 0 | |
88 | foreach line $lines { | |
89 | if { [regexp "dump_options.* =" $line] } { | |
90 | set domatch 1 | |
91 | } elseif { [regexp "^\};" $line] } { | |
92 | set domatch 0 | |
93 | } | |
94 | if { $domatch } { | |
95 | if { [regexp "\"(.*)\"" $line match submatch] } { | |
96 | lappend res $submatch | |
97 | } | |
98 | } | |
99 | } | |
100 | ||
101 | return $res | |
102 | } | |
103 | ||
104 | foreach flag [get_dump_flags] { | |
105 | check_for_all_options c -fdump-tree-all-$flag {} {} {} | |
106 | check_for_all_options c -fdump-ipa-all-$flag {} {} {} | |
107 | check_for_all_options c -fdump-rtl-all-$flag {} {} {} | |
108 | check_for_all_options c -fdump-lang-all-$flag {} {} {} | |
109 | } | |
110 | ||
717c4789 | 111 | gcc_parallel_test_enable 1 |