public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1611] [Ada] GNAT.Compiler_Version and LTO
@ 2021-06-18 8:37 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-18 8:37 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4153c7547146cbd775385569bfdaa6cb3fe19007
commit r12-1611-g4153c7547146cbd775385569bfdaa6cb3fe19007
Author: Arnaud Charlet <charlet@adacore.com>
Date: Fri Mar 12 07:57:03 2021 -0500
[Ada] GNAT.Compiler_Version and LTO
gcc/ada/
* bindgen.adb (Gen_Output_File_Ada): Generate a new constant
GNAT_Version_Address.
* libgnat/g-comver.adb (GNAT_Version_Address): New;
(GNAT_Version): Use GNAT_Version_Address to disable LTO warning.
Diff:
---
gcc/ada/bindgen.adb | 6 +++++-
gcc/ada/libgnat/g-comver.adb | 11 ++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
index 303bcdea344..0014f6a46da 100644
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -2388,7 +2388,11 @@ package body Bindgen is
Gnat_Version_String &
""" & ASCII.NUL;");
WBI (" pragma Export (C, GNAT_Version, ""__gnat_version"");");
-
+ WBI ("");
+ WBI (" GNAT_Version_Address : constant System.Address := " &
+ "GNAT_Version'Address;");
+ WBI (" pragma Export (C, GNAT_Version_Address, " &
+ """__gnat_version_address"");");
WBI ("");
Set_String (" Ada_Main_Program_Name : constant String := """);
Get_Name_String (Units.Table (First_Unit_Entry).Uname);
diff --git a/gcc/ada/libgnat/g-comver.adb b/gcc/ada/libgnat/g-comver.adb
index e2aef3e6399..575caac5095 100644
--- a/gcc/ada/libgnat/g-comver.adb
+++ b/gcc/ada/libgnat/g-comver.adb
@@ -33,6 +33,8 @@
-- GNAT compiler used to compile the program. It relies on the generated
-- constant in the binder generated package that records this information.
+with System;
+
package body GNAT.Compiler_Version is
Ver_Len_Max : constant := 256;
@@ -43,8 +45,15 @@ package body GNAT.Compiler_Version is
-- This is logically a reference to Gnatvsn.Ver_Prefix but we cannot
-- import this directly since run-time units cannot WITH compiler units.
+ GNAT_Version_Address : constant System.Address;
+ pragma Import (C, GNAT_Version_Address, "__gnat_version_address");
+
GNAT_Version : constant String (1 .. Ver_Len_Max + Ver_Prefix'Length);
- pragma Import (C, GNAT_Version, "__gnat_version");
+ pragma Import (Ada, GNAT_Version);
+ for GNAT_Version'Address use GNAT_Version_Address;
+ -- Use a level of indirection via __gnat_version_address to avoid LTO
+ -- type mismtch warnings between two string objects of potentially
+ -- different size.
-------------
-- Version --
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-18 8:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 8:37 [gcc r12-1611] [Ada] GNAT.Compiler_Version and LTO Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).