+2019-07-03 Arnaud Charlet <charlet@adacore.com>
+
+ * bindgen.adb (Gen_Main): Disable generation of reference to
+ Ada_Main_Program_Name for CCG.
+ * bindusg.adb (Display): Add -G to the command-line usage for
+ gnatbind.
+ * opt.ads (Generate_C_Code): Update comment.
+ * switch-b.adb (Scan_Binder_Switches): Add handling for -G.
+
2019-07-03 Arnaud Charlet <charlet@adacore.com>
* sem_ch7.adb (Has_Referencer): Do not consider inlined
-- referenced elsewhere in the generated program, but is needed by
-- the debugger (that's why it is generated in the first place). The
-- reference stops Ada_Main_Program_Name from being optimized away by
- -- smart linkers, such as the AiX linker.
+ -- smart linkers.
-- Because this variable is unused, we make this variable "aliased"
-- with a pragma Volatile in order to tell the compiler to preserve
-- this variable at any level of optimization.
- if Bind_Main_Program and not CodePeer_Mode then
+ -- CodePeer and CCG do not need this extra code on the other hand.
+
+ if Bind_Main_Program
+ and then not CodePeer_Mode
+ and then not Generate_C_Code
+ then
WBI (" Ensure_Reference : aliased System.Address := " &
"Ada_Main_Program_Name'Address;");
WBI (" pragma Volatile (Ensure_Reference);");
Write_Line
(" -F Force checking of elaboration Flags");
+ -- Line for -G switch
+
+ Write_Line
+ (" -G Generate binder file suitable for CCG");
+
-- Line for -h switch
Write_Line
-- file name with extension stripped.
Generate_C_Code : Boolean := False;
- -- GNAT
+ -- GNAT, GNATBIND
-- If True, the Cprint circuitry to generate C code output is activated.
- -- Set True by use of -gnateg or -gnatd.V.
+ -- Set True by use of -gnateg or -gnatd.V for GNAT, and -G for GNATBIND.
Generate_CodePeer_Messages : Boolean := False;
-- GNAT
Debugger_Level := 2;
end if;
+ -- Processing for G switch
+
+ when 'G' =>
+ Ptr := Ptr + 1;
+ Generate_C_Code := True;
+
-- Processing for h switch
when 'h' =>