From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 7A7693857806; Mon, 7 Nov 2022 08:39:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A7693857806 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667810388; bh=S+1qaWq89WWwsT3bJowcLKPr/nGV2Hf5Jd8LYOoFDeE=; h=From:To:Subject:Date:From; b=fpWmmzlgkFzS/9TQABO3GafNga4Jrt4xcy+I3d8XeTM/kuYJ/YN2JpOVsA579GEgE slZ7U+t2eCcPXjoCqu4pSX7fKws5VtXurTCIlup/ESicxUsDlvuHtxLSz42fgIxdbV yaMuY4Aqmqj6t0Ozq/Q+KzBx4wMtLCEvukLfSOVA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3739] ada: Fixed elaboration of CUDA programs. X-Act-Checkin: gcc X-Git-Author: Quentin Ochem X-Git-Refname: refs/heads/master X-Git-Oldrev: aa0e7d31a803f948504f8692c4ae48e3ba1b677b X-Git-Newrev: b86ff061234ff42934bc08c5dc1ba041724eba22 Message-Id: <20221107083948.7A7693857806@sourceware.org> Date: Mon, 7 Nov 2022 08:39:48 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b86ff061234ff42934bc08c5dc1ba041724eba22 commit r13-3739-gb86ff061234ff42934bc08c5dc1ba041724eba22 Author: Quentin Ochem Date: Fri Oct 14 06:30:04 2022 -0400 ada: Fixed elaboration of CUDA programs. The names of imported / exported symbols were not consistent between the device and the host when compiling for CUDA. Remove the function Device_Ada_Final_Link_Name as it is no longer referenced. gcc/ada/ * bindgen.adb: fixed the way the device init and final symbols are computed, re-using the normal way these symbols would be computed with a __device_ prefix. Also fixed the "is null;" procedure on the host side which are not Ada 95, replaced with a procedure raising an exception as it should never be called. Remove the unused function Device_Ada_Final_Link_Name. Co-authored-by: Steve Baird Diff: --- gcc/ada/bindgen.adb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb index b942985b2e8..e72cdf81227 100644 --- a/gcc/ada/bindgen.adb +++ b/gcc/ada/bindgen.adb @@ -131,8 +131,6 @@ package body Bindgen is function Device_Ada_Init_Link_Name return String is (Device_Link_Name (Suffix => "init")); - function Device_Ada_Final_Link_Name return String - is (Device_Link_Name (Suffix => "final")); ---------------------------------- -- Interface_State Pragma Table -- @@ -1357,11 +1355,6 @@ package body Bindgen is WBI (" pragma Export (C, " & Device_Ada_Init_Subp_Name & ", Link_Name => """ & Device_Ada_Init_Link_Name & """);"); - -- It would be nice to declare a real body that raises P_E, but - -- generating a subprogram body at the right point is harder - -- than generating a null procedure here. - WBI (" procedure " & Device_Ada_Init_Subp_Name & " is null;"); - -- C-string declaration for adainit WBI (" " & Adainit_String_Obj_Name & " : Interfaces.C.Strings.Chars_Ptr;"); @@ -2673,7 +2666,8 @@ package body Bindgen is WBI (" procedure " & Ada_Init_Name.all & ";"); if Enable_CUDA_Device_Expansion then WBI (" pragma Export (C, " & Ada_Init_Name.all & - ", Link_Name => """ & Device_Ada_Init_Link_Name & """);"); + ", Link_Name => """ & Device_Link_Name_Prefix + & Ada_Init_Name.all & """);"); WBI (" pragma CUDA_Global (" & Ada_Init_Name.all & ");"); else WBI (" pragma Export (C, " & Ada_Init_Name.all & ", """ & @@ -2692,7 +2686,8 @@ package body Bindgen is WBI (" procedure " & Ada_Final_Name.all & ";"); if Enable_CUDA_Device_Expansion then WBI (" pragma Export (C, " & Ada_Final_Name.all & - ", Link_Name => """ & Device_Ada_Final_Link_Name & """);"); + ", Link_Name => """ & Device_Link_Name_Prefix & + Ada_Final_Name.all & """);"); WBI (" pragma CUDA_Global (" & Ada_Final_Name.all & ");"); else WBI (" pragma Export (C, " & Ada_Final_Name.all & ", """ & @@ -2922,6 +2917,13 @@ package body Bindgen is Gen_Adainit (Elab_Order); + if Enable_CUDA_Expansion then + WBI (" procedure " & Device_Ada_Init_Subp_Name & " is"); + WBI (" begin"); + WBI (" raise Program_Error;"); + WBI (" end " & Device_Ada_Init_Subp_Name & ";"); + end if; + if Bind_Main_Program then Gen_Main; end if;