ld testsuite: change unresolved to unsupported/fail
[binutils-gdb.git] / ld / testsuite / ld-plugin / lto.exp
index 6a37025db59d3abd0397242f6e10d780482a4327..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] } {
@@ -71,11 +55,11 @@ set lto_link_tests [list \
    "-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin" \
    {lto-1a.c lto-1b.c} {} "lto-1.exe"] \
   [list "Compile 2" \
-   "" "-O2 -flto -fuse-linker-plugin $NOSANTIZE_CFLAGS" \
+   "" "-O2 -flto -fuse-linker-plugin $NOSANITIZE_CFLAGS" \
    {lto-2.c} {} ""] \
   [list "LTO 2" \
    "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" \
-   "$NOSANTIZE_CFLAGS" \
+   "$NOSANITIZE_CFLAGS" \
    {dummy.c} {} "lto-2.exe"] \
   [list "Compile 3a" \
    "" "-flto" \
@@ -138,11 +122,11 @@ set lto_link_tests [list \
    "" "" \
    {pr12758a.s} {} ""] \
   [list "Build libpr12758.a" \
-   "" "-flto -O2 $lto_fat $NOSANTIZE_CFLAGS" \
+   "" "-flto -O2 $lto_fat $NOSANITIZE_CFLAGS" \
    {pr12758b.c} {} "libpr12758.a"] \
   [list "PR ld/12758" \
-   "$NOPIE_LDFLAGS -O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" \
-   "$NOSANTIZE_CFLAGS" \
+   "$NOPIE_LDFLAGS $NOSANITIZE_CFLAGS -O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" \
+   "$NOSANITIZE_CFLAGS" \
    {dummy.c} {} "pr12758.exe"] \
   [list "Build libpr13183.a" \
    "-T" "-flto -O2 $lto_fat" \
@@ -419,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
@@ -427,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
@@ -439,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.
@@ -458,10 +485,12 @@ set lto_link_symbol_tests [list \
    "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" "" \
    {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"] \
   [list "LTO 16a symbol" \
-   "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" "-flto" \
+   "-O2 $NOSANITIZE_CFLAGS -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" \
+   "-flto $NOSANITIZE_CFLAGS" \
    {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"] \
   [list "LTO 16b symbol" \
-   "-O2 -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" "-flto" \
+   "-O2 $NOSANITIZE_CFLAGS -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" \
+   "-flto $NOSANITIZE_CFLAGS" \
    {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"] \
   [list "PR ld/13183" \
    "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" "" \
@@ -582,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
@@ -630,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
 }
@@ -667,7 +716,8 @@ if { [at_least_gcc_version 4 7] } {
        run_cc_link_tests [list \
            [list \
                "Build pr22721a.so" \
-               "-shared -nostdlib -nostartfiles -Wl,-version-script,pr22721.t" \
+               "-shared $NOSANITIZE_CFLAGS -nostdlib -nostartfiles \
+                -Wl,-version-script,pr22721.t" \
                "" \
                {pr22721a.s} \
                {} \
@@ -675,15 +725,16 @@ if { [at_least_gcc_version 4 7] } {
            ] \
            [list \
                "Build pr22721b.o" \
-               "$plug_opt" \
+               "$plug_opt $NOSANITIZE_CFLAGS" \
                "-O2 -fPIC -flto $lto_no_fat" \
                {pr22721b.c} \
            ] \
            [list \
                "Build PR ld/pr22721" \
                "-O2 -flto -fuse-linker-plugin -nostdlib -nostartfiles \
-               -Wl,-e,_start tmpdir/pr22721b.o tmpdir/pr22721a.so" \
-               "" \
+                $NOSANITIZE_CFLAGS \
+                -Wl,-e,_start tmpdir/pr22721b.o tmpdir/pr22721a.so" \
+               "$NOSANITIZE_CFLAGS" \
                {dummy.c} \
                {} \
                "pr22721.exe"
@@ -708,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 \