From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19672 invoked by alias); 30 Apr 2004 19:22:37 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 19664 invoked from network); 30 Apr 2004 19:22:36 -0000 Received: from unknown (HELO mail.libertysurf.net) (213.36.80.91) by sources.redhat.com with SMTP; 30 Apr 2004 19:22:36 -0000 Received: from localhost.localdomain (213.36.54.75) by mail.libertysurf.net (6.5.036) id 409129180027256E for gcc@gcc.gnu.org; Fri, 30 Apr 2004 21:22:35 +0200 Content-Type: text/plain; charset="iso-8859-1" From: Eric Botcazou To: gcc@gcc.gnu.org Subject: -fzero-initialized-in-bss again Date: Fri, 30 Apr 2004 21:31:00 -0000 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200404302109.55902.ebotcazou@act-europe.fr> X-SW-Source: 2004-04/txt/msg01471.txt.bz2 Hi, We recently (after the 3.4.0 release, unfortunately) discovered that the default option -fzero-initialized-in-bss has an annoying side-effect for the Ada compiler: it may prevent the user from overriding an object in a library (e.g. the runtime) by a local, slightly modified copy of the object. Let's take an example: a user wants to modify a parameter of the runtime, by locally tweaking s-parame.ads like so @@ -73,7 +73,7 @@ -- The special value of minus one indicates that the secondary -- stack is to be allocated from the heap instead. - Sec_Stack_Ratio : constant Ratio := Dynamic; + Sec_Stack_Ratio : constant Ratio := 10; -- This constant defines the handling of the secondary stack Sec_Stack_Dynamic : constant Boolean := Sec_Stack_Ratio = Dynamic; When building the executable, gnatmake will locally recompile s-parame.adb and try link it into the executable. But that will fail with the error message: /cardiff.a/gnatmail-5_34/build-cardiff/install/lib/gcc/i686-pc-linux-gnu/3.4.1/a dalib/libgnat.a(s-parame.o)(.data+0x0): multiple definition of `system__parameters__unspecified_size' ./s-parame.o(.data+0x0): first defined here Here's what happens: the change from 'Dynamic' to '10' for Sec_Stack_Ratio causes the comparison that initializes Sec_Stack_Dynamic to become false, hence Sec_Stack_Dynamic is effectively initialized to 0. Given that the option -fzero-initialized-in-bss is enabled by default, the symbol system__parameters__sec_stack_dynamic is moved from .data to the uninitialized data section. Now -fcommon is also on by default so the Ada compiler puts uninitialized symbols in the .common section. We eventually end up with system__parameters__sec_stack_dynamic in the .common section. So the local object has system__parameters__sec_stack_dynamic in .common while the runtime has it in .data. Therefore the linker imports s-parame.o from libgnat.a, thus leading to conflicts for other symbols. A simple solution is to turn -fzero-initialized-in-bss off by default. This was discussed back in July just before the 3.3.1 release, in light of other problems with the FreeBSD kernel and GNU Emacs on Solaris. We feel that this Ada issue adds to the pile of drawbacks with having it enabled by default. Would it be feasible to do it, starting with the 3.4.1 release? -- Eric Botcazou