# Expect script for ld-plugin LTO tests
-# Copyright (C) 2011-2020 Free Software Foundation, Inc.
+# Copyright (C) 2011-2021 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
set CXXFLAGS "$saved_CXXFLAGS"
}
-set plugin_names {
- liblto_plugin.so
- liblto_plugin-0.dll
- cyglto_plugin-0.dll
-}
-set plug_opt ""
-foreach plug $plugin_names {
- set plug_so [run_host_cmd $CC "--print-prog-name $plug"]
- if { $plug_so eq $plug } then {
- set plug_so [run_host_cmd $CC "--print-file-name $plug"]
- }
- if { $plug_so ne $plug } then {
- set plug_opt "--plugin $plug_so"
- break
- }
-}
set lto_fat ""
set lto_no_fat ""
if { [check_lto_fat_available] } {
[list "PR ld/13244" \
"-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto" \
{pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"] \
- [list "Build libpr15146a.a" \
- "$plug_opt" "-flto -O2" \
- {pr15146a.c} {} "lib15146a.a"] \
- [list "Build pr15146b.so" \
- "-shared" "-O2 -fpic" \
- {pr15146b.c} {} "pr15146b.so" "c"] \
- [list "Build pr15146c.so" \
- "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic $no_lto" \
- {pr15146c.c} {} "pr15146c.so" "c"] \
- [list "PR ld/15146 (1)" \
- "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" "" \
- {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"] \
- [list "Build libpr15146d.a" \
- "$plug_opt" "-flto -O2" \
- {pr15146d.c} {} "lib15146d.a"] \
[list "Build libpr16746a.a" \
"" "" \
{pr16746a.c pr16746b.c} {} "lib15146a.a"] \
"-shared -Wl,--exclude-libs,ALL tmpdir/pr25618a.o tmpdir/pr25618.a" \
"-fpic" \
{dummy.c} {{readelf {--dyn-syms --wide} pr25618.d}} "pr25618.so" "c++"] \
+ [list {liblto-18b.so} \
+ {-shared} {-O2 -fpic} \
+ {lto-18b.c} {} {liblto-18b.so}] \
+ [list {liblto-18b.a} \
+ "$plug_opt" {-flto -O2} \
+ {lto-18b.c} {} {liblto-18b.a}] \
+ [list {liblto-18c.so} \
+ {-shared} {-O2 -fpic} \
+ {lto-18c.c} {} {liblto-18c.so}] \
+ [list {liblto-18c.a} \
+ "$plug_opt" {-flto -O2} \
+ {lto-18c.c} {} {liblto-18c.a}] \
+ [list {lto-18d.o} \
+ {} {-flto -O2} \
+ {lto-18d.c} {} {}] \
+ [list {liblto-19.a} \
+ "$plug_opt" {-flto -O2 -fPIC} \
+ {lto-19a.c} {} {liblto-19.a}] \
+ [list {compile lto-19b.c} \
+ "$plug_opt" {-flto -O2 -fPIC} \
+ {lto-19b.c} {} {} {c}] \
+ [list {liblto-19.so} \
+ {-shared tmpdir/lto-19b.o tmpdir/liblto-19.a} {-O2 -fPIC} \
+ {dummy.c} {} {liblto-19.so}] \
+ [list {pr26806.so} \
+ {-shared} {-fpic -O2 -flto} \
+ {pr26806.c} {{nm {-D} pr26806.d}} {pr26806.so}] \
]
# PR 14918 checks that libgcc is not spuriously included in a shared link of
# __aeabi_unwind_cpp_pr0@@GCC_3.5 which is provided by libgcc_s.so.1, so the
# test fails. Hence this code to skip the test.
if { ! [istarget "arm*-*-*"] } {
- set lto_link_elf_tests [concat $lto_link_elf_tests [list \
+ lappend lto_link_elf_tests [list \
[list "PR ld/14918" \
"-flto" "-flto" \
{pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"] \
- ]]
+ ]
}
# PR 12982 checks that an executable stack is not created by default
# executable stack for syscall restarts and signal returns, so we
# skip this test for that target.
if { ! [istarget "hppa*-*-*"] } {
- set lto_link_elf_tests [concat $lto_link_elf_tests [list \
+ lappend lto_link_elf_tests [list \
[list "PR ld/12982" \
"-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
{pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"] \
- ]]
+ ]
}
# Check final symbols in executables.
[list {pr22220b} \
{-flto -fuse-linker-plugin -Wl,--no-as-needed tmpdir/pr22220lib.so tmpdir/pr22220main.o} {} \
{dummy.c} {pr22220b.exe} {pass.out} {} {c++}] \
+ [list {lto-18 (1)} \
+ {-flto -fuse-linker-plugin} {} \
+ {lto-18a.c} {lto-18-1.exe} {lto-18.out} {-flto -O2} {c} {} \
+ {tmpdir/lto-18d.o -Wl,--as-needed,-R,tmpdir -Ltmpdir -llto-18b -llto-18c}] \
+ [list {lto-18 (2)} \
+ {-flto -fuse-linker-plugin} {} \
+ {lto-18a.c} {lto-18-2.exe} {lto-18.out} {-flto -O2} {c} {} \
+ {-Wl,--as-needed,-R,tmpdir -Ltmpdir -llto-18b -llto-18c tmpdir/lto-18d.o}] \
+ [list {lto-18 (3)} \
+ {-static -flto -fuse-linker-plugin} {} \
+ {lto-18a.c} {lto-18-3.exe} {lto-18.out} {-flto -O2} {c} {} \
+ {tmpdir/lto-18d.o -Ltmpdir -llto-18b -llto-18c}] \
+ [list {lto-18 (4)} \
+ {-static -flto -fuse-linker-plugin} {} \
+ {lto-18a.c} {lto-18-4.exe} {lto-18.out} {-flto -O2} {c} {} \
+ { -Ltmpdir -llto-18b -llto-18c tmpdir/lto-18d.o}] \
+ [list {lto-19} \
+ {-Wl,--as-needed,-R,tmpdir} {} \
+ {lto-19c.c} {lto-19.exe} {pass.out} {-flto -O2} {c} {} \
+ {tmpdir/liblto-19.so tmpdir/liblto-19.a}] \
]
# LTO run-time tests for ELF
# Restrict these to ELF targets that support shared libs and PIC.
if { [is_elf_format] && [check_lto_shared_available] } {
run_cc_link_tests $lto_link_elf_tests
- set testname "PR ld/15146 (2)"
- set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"]
- if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } {
- pass $testname
- } {
- fail $testname
- }
set testname "PR ld/16746 (3)"
set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {