1 # Copyright (C) 2021-2022 Free Software Foundation, Inc.
3 # This file is part of the GNU Binutils.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 load_file $srcdir/../../ld/testsuite/lib/ld-lib.exp
23 global srcdir subdir OBJDUMP
27 set subsrcdir "$srcdir/$subdir/"
28 set testname "$dir/libctf-repeat-cu.exp"
31 unsupported "CTF needs bfd changes to be emitted on non-ELF"
35 if {![check_ctf_available]} {
36 unsupported "no CTF format support in the compiler"
40 if {[info exists env(LC_ALL)]} {
41 set old_lc_all $env(LC_ALL)
45 # Compile one SRC to OBJ and put it into ARCHIVE.
46 proc one_lib_compile { src flags obj archive } {
47 global CC_FOR_TARGET CFLAGS_FOR_TARGET AR subsrcdir
50 set src [remote_download host [file join $subsrcdir $src]]
52 set src [file join $subsrcdir $src]
55 set comp_output [prune_warnings [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET $flags -gctf -fPIC -c -o $obj $src"]]
56 if { $comp_output != "" } {
60 set ar_output [prune_warnings [run_host_cmd "$AR" "rc $archive $obj"]]
64 # Compile one SRC to OBJ and put it into ARCHIVE: error-check the result.
65 proc one_lib_compile_check { src flags obj archive } {
68 set comp_output [one_lib_compile $src $flags $obj $archive]
70 if { $comp_output != ""} {
71 send_log "compilation of $src with $flags failed with <$comp_output>"
72 perror "compilation of $src with $flags failed"
79 if { ! [one_lib_compile_check libctf-repeat-cu-lib.c "-DINT -DFUN=a" tmpdir/libctf-repeat-cu-lib.o tmpdir/a.a] } {
83 if { ! [one_lib_compile_check libctf-repeat-cu-lib.c "-DCHAR -DFUN=b" tmpdir/libctf-repeat-cu-lib.o tmpdir/b.a] } {
87 if { ! [one_lib_compile_check libctf-repeat-cu-lib.c "-DFUN=c" tmpdir/libctf-repeat-cu-lib.o tmpdir/c.a] } {
92 set src [remote_download host [file join $subsrcdir libctf-repeat-cu-main.c]]
94 set src [file join $subsrcdir libctf-repeat-cu-main.c]
97 set comp_output [prune_warnings [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET -gctf -fPIC -shared -o tmpdir/libctf-repeat-cu-main.so $src tmpdir/a.a tmpdir/b.a tmpdir/c.a"]]
98 if { $comp_output != "" } {
99 send_log "compilation of tmpdir/libctf-repeat-cu-main.so failed"
100 perror "compilation of tmpdir/libctf-repeat-cu-main.so failed"
105 set comp_output [prune_warnings [run_host_cmd "$OBJDUMP" "--ctf tmpdir/libctf-repeat-cu-main.so > tmpdir/dump.out"]]
107 if { [regexp_diff "tmpdir/dump.out" [file join $subsrcdir libctf-repeat-cu.d] ] } {
109 if { $verbose == 2 } then { verbose "output is [file_contents tmpdir/dump.out]" 2 }
114 if {[info exists old_lc_all]} {
115 set env(LC_ALL) $old_lc_all