Patchwork [Ada] Pass -shared-libgcc when building Ada shared libraries on Windows

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 5, 2010, 9:57 a.m.
Message ID <20101005095736.GA7077@adacore.com>
Download mbox | patch
Permalink /patch/66782/
State New
Headers show

Comments

Arnaud Charlet - Oct. 5, 2010, 9:57 a.m.
Unlike on most platforms, the compiler doesn't automatically set -shared-libgcc
when building shared libraries on Windows.  Now a shared libgcc is required for
the propagation of Ada exceptions in this case so we explicitly pass it, as is
done in C++.

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-10-05  Eric Botcazou  <ebotcazou@adacore.com>

	* mlib-tgt-specific-mingw.adb (No_Argument_List): Delete.
	(Shared_Libgcc): New aliased variable.
	(Shared_Libgcc_Switch): New constant.
	(Build_Dynamic_Library): Pass Shared_Libgcc_Switch to the compiler
	* gcc-interface/Makefile.in (gnatlib-shared-win32): Pass -shared-libgcc
	to the compiler.

Patch

Index: mlib-tgt-specific-mingw.adb
===================================================================
--- mlib-tgt-specific-mingw.adb	(revision 164906)
+++ mlib-tgt-specific-mingw.adb	(working copy)
@@ -7,7 +7,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2002-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 2002-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -61,8 +61,10 @@  package body MLib.Tgt.Specific is
 
    function PIC_Option return String;
 
-   No_Argument_List : constant String_List := (1 .. 0 => null);
-   --  Used as value of parameter Options or Options2 in calls to Gcc
+   Shared_Libgcc : aliased String := "-shared-libgcc";
+
+   Shared_Libgcc_Switch : constant Argument_List :=
+                            (1 => Shared_Libgcc'Access);
 
    ---------------------------
    -- Build_Dynamic_Library --
@@ -99,7 +101,7 @@  package body MLib.Tgt.Specific is
       Tools.Gcc
         (Output_File => Lib_File,
          Objects     => Ofiles,
-         Options     => No_Argument_List,
+         Options     => Shared_Libgcc_Switch,
          Options_2   => Options,
          Driver_Name => Driver_Name);
    end Build_Dynamic_Library;
Index: gcc-interface/Makefile.in
===================================================================
--- gcc-interface/Makefile.in	(revision 164906)
+++ gcc-interface/Makefile.in	(working copy)
@@ -2561,11 +2561,13 @@  gnatlib-shared-win32:
 	     THREAD_KIND="$(THREAD_KIND)" \
              gnatlib
 	$(RM) $(RTSDIR)/libgna*$(soext)
-	cd $(RTSDIR); ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
+	cd $(RTSDIR); ../../xgcc -B../../ -shared -shared-libgcc \
+		$(TARGET_LIBGCC2_CFLAGS) \
 		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
 		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
 		$(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB)
-	cd $(RTSDIR); ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
+	cd $(RTSDIR); ../../xgcc -B../../ -shared -shared-libgcc \
+		$(TARGET_LIBGCC2_CFLAGS) \
 		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
 		$(GNATRTL_TASKING_OBJS) \
 		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \