Fix link failure with debug info in LTO mode
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 25 Feb 2020 11:34:00 +0000 (12:34 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 25 Feb 2020 11:39:14 +0000 (12:39 +0100)
This fixes a regression whereby the program fails to link with debug
info in LTO mode because of an undefined reference to a symbol coming
from the object files containing the early debug info.

* dwarf2out.c (dwarf2out_size_function): Run in early-DWARF mode.

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/lto24.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/lto24_pkg1.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/lto24_pkg2.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/lto24_pkg2.ads [new file with mode: 0644]

index 64120a9160978e07f9f8b214e1ef1e6aee68fc38..78191a6b8c365ecb910a7a59ac7bb85d26ae1a3f 100644 (file)
@@ -1,3 +1,7 @@
+2019-02-25  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * dwarf2out.c (dwarf2out_size_function): Run in early-DWARF mode.
+
 2020-02-25  Roman Zhuykov  <zhroma@ispras.ru>
 
        * doc/install.texi (--enable-checking): Adjust wording.
index fe46c7e1eee8f977e71cb36b5ff13a8413516739..1fcb19a0489c1a09684e665d1663d8312fd75857 100644 (file)
@@ -27610,6 +27610,7 @@ dwarf2out_inline_entry (tree block)
 static void
 dwarf2out_size_function (tree decl)
 {
+  set_early_dwarf s;
   function_to_dwarf_procedure (decl);
 }
 
index 10bbb73fc3d92497b301045add16e0747710d8cd..3a22e8608df00faf171e3e5654e3673f9b2310ec 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-25  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/lto24.adb: New test.
+       * gnat.dg/lto24_pkg1.ads: New helper.
+       * gnat.dg/lto24_pkg2.ad[sb]: Likewise.
+
 2020-02-25  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/tree-ssa/ssa-fre-86.c: New testcase.
diff --git a/gcc/testsuite/gnat.dg/lto24.adb b/gcc/testsuite/gnat.dg/lto24.adb
new file mode 100644 (file)
index 0000000..998b447
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do link }
+-- { dg-options "-O -g -flto" { target lto } }
+
+with Lto24_Pkg1;
+
+procedure Lto24 is
+  R : Lto24_Pkg1.Rec (False);
+begin
+  R.Empty := True;
+end;
diff --git a/gcc/testsuite/gnat.dg/lto24_pkg1.ads b/gcc/testsuite/gnat.dg/lto24_pkg1.ads
new file mode 100644 (file)
index 0000000..abe7e91
--- /dev/null
@@ -0,0 +1,17 @@
+with Lto24_Pkg2;
+
+package Lto24_Pkg1 is
+
+  Max_Elem : constant Natural := Lto24_Pkg2.Get;
+
+  type Arr is array (Natural range <>) of Boolean;
+
+  type Rec (B : Boolean) is record
+     I : Integer;
+     case B is
+       when True => A : Arr (1 .. Max_Elem);
+       when False => Empty : Boolean;
+     end case;
+  end record;
+
+end Lto24_Pkg1;
diff --git a/gcc/testsuite/gnat.dg/lto24_pkg2.adb b/gcc/testsuite/gnat.dg/lto24_pkg2.adb
new file mode 100644 (file)
index 0000000..12fb34e
--- /dev/null
@@ -0,0 +1,8 @@
+package body Lto24_Pkg2 is
+
+  function Get return Natural is
+  begin
+    return 16;
+  end;
+
+end Lto24_Pkg2;
diff --git a/gcc/testsuite/gnat.dg/lto24_pkg2.ads b/gcc/testsuite/gnat.dg/lto24_pkg2.ads
new file mode 100644 (file)
index 0000000..79a916e
--- /dev/null
@@ -0,0 +1,5 @@
+package Lto24_Pkg2 is
+
+  function Get return Natural;
+
+end Lto24_Pkg2;