ld testsuite: change unresolved to unsupported/fail
[binutils-gdb.git] / ld / testsuite / ld-plugin / lto.exp
index 684d1db314ad8bfe8e4256e5c3cff9221a7c716c..38cea30aed41e23fc00cd563e6823e2890b4ff91 100644 (file)
@@ -1,5 +1,5 @@
 # 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.
 #
@@ -41,22 +41,6 @@ proc restore_notify { } {
   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] } {
@@ -320,6 +304,21 @@ set lto_link_elf_tests [list \
   [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"] \
@@ -404,6 +403,51 @@ set lto_link_elf_tests [list \
    "-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}] \
+  [list {pr27311a.so} \
+   {-shared -Wl,--version-script=pr27311.ver} {-fPIC} \
+   {pr27311a.c} {} {pr27311a.so}] \
+  [list {pr27311b.so} \
+   {-shared -Wl,--no-as-needed tmpdir/pr27311a.so} {-fPIC} \
+   {pr27311b.c} {} {pr27311b.so}] \
+  [list {pr27311c.o} \
+   {} {-flto} \
+   {pr27311c.c} {} {} {c}] \
+  [list {pr27311d.o} \
+   {} {-flto} \
+   {pr27311d.c} {} {} {c}] \
+  [list {pr27311-1} \
+   {tmpdir/pr27311c.o -Wl,--no-as-needed,--rpath-link=. tmpdir/pr27311b.so} {} \
+   {dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311-1}] \
+  [list {pr27311-2} \
+   {tmpdir/pr27311d.o -Wl,--no-as-needed,--rpath-link=. tmpdir/pr27311b.so} {} \
+   {dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311-2}] \
 ]
 
 # PR 14918 checks that libgcc is not spuriously included in a shared link of
@@ -412,11 +456,10 @@ set lto_link_elf_tests [list \
 # __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 "PR ld/14918" \
    "-flto" "-flto" \
-   {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"] \
-  ]]
+   {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"]
 }
 
 # PR 12982 checks that an executable stack is not created by default
@@ -424,11 +467,10 @@ if { ! [istarget "arm*-*-*"] } {
 # 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 "PR ld/12982" \
    "-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
-   {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"] \
-  ]]
+   {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"]
 }
 
 # Check final symbols in executables.
@@ -569,6 +611,26 @@ set lto_run_elf_shared_tests [list \
   [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
@@ -590,6 +652,13 @@ run_cc_link_tests $lto_compile_elf_tests
 # 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 ] } {
@@ -610,7 +679,7 @@ set testname "Build liblto-11.a"
 remote_file host delete "tmpdir/liblto-11.a"
 set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
 if {![string match "" $catch_output]} {
-    unresolved $testname
+    fail $testname
     restore_notify
     return
 }
@@ -690,7 +759,7 @@ if { [at_least_gcc_version 4 7] } {
        ] \
     ]
     set exec_output [run_host_cmd "sh" \
-                                 "-c \"ulimit -n 16; \
+                                 "-c \"ulimit -n 20; \
                                   $ar -rc $plug_opt \
                                   tmpdir/libpr23460.a \
                                   tmpdir/pr23460a.o \