Bug 35597 - libstdc++ -ffunction-sections -fdata-sections disabled on AIX
Summary: libstdc++ -ffunction-sections -fdata-sections disabled on AIX
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.3.0
: P3 major
Target Milestone: 4.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2008-03-15 02:54 UTC by David Edelsohn
Modified: 2008-04-24 18:06 UTC (History)
2 users (show)

See Also:
Host: powerpc-ibm.aix5.3.0.0
Target: powerpc-ibm-aix5.3.0.0
Build: powerpc-ibm-aix5.3.0.0
Known to work: 4.2.3
Known to fail: 4.3.0
Last reconfirmed: 2008-03-15 02:54:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Edelsohn 2008-03-15 02:54:12 UTC
"-g" was added to CXXFLAGS in the GLIBCXX_CHECK_COMPILER_FEATURES configure test in libstdc++.  This option causes G++ to warn: "-ffunction-sections may affect debugging on some targets".  CXXFLAGS also includes "-Werror" causing the warning to become an error.  This results in -ffunction-sections -fdata-sections being disabled.

"-ffunction-sections -fdata-sections" works fine on AIX and should be used because it generates functions as intended and improves performance by allowing the AIX linker to reorder functions.
Comment 1 Richard Biener 2008-03-15 10:46:11 UTC
So isn't this a target bug then?  That is, the warning should be disabled for
targets that "work"?
Comment 2 David Edelsohn 2008-03-15 13:32:05 UTC
The change was applied to libstdc++.  The patch affects building libstdc++.

The warning was added in 1996 for all targets and debugging formats:

Mon Apr 15 03:43:11 1996  Jeffrey A. Law  <law@cygnus.com>
        * toplev.c (compile_file): Add warnings when -ffunction-sections is
        used with -g, or profiling.

The warning was disabled for ELF in 1999 and later for MACH-O.  If we disable the warning for all object file formats, what's the point of the warning?
Comment 3 Benjamin Kosnik 2008-03-20 16:16:52 UTC
From:
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01135.html

2007-05-17  Benjamin Kosnik  <bkoz@redhat.com>

	* acinclude.m4 (GLIBCXX_CHECK_COMPILER_FEATURES): Add -g to
	compile flags, move code to test to global scope.
	* configure: Regenerate.


David says that -ffunction-sections -g works on AIX. Presumably this means that it should also not warn. 

Question to me is, what is the behavior on cygwin? Does -ffunction-sections -g work? Does it warn?

-benjamin
Comment 4 brian 2008-03-20 22:19:57 UTC
Subject: Re:  libstdc++ -ffunction-sections -fdata-sections 
 disabled on AIX

bkoz at gcc dot gnu dot org wrote:

> Question to me is, what is the behavior on cygwin? Does -ffunction-sections -g
> work? Does it warn?

Yes it warns, and yes this warning needs to die.  I see no problem
debugging with -ffunction-sections on Cygwin:

$ cat <<EOF >tc.c

int func1 (int a)
{
  return a + 1;
}

int func2 (int a)
{
  return a + 1;
}

int func3 (int a)
{
  return a + 1;
}

int func4 (int a)
{
  return a + 1;
}

int func5 (int a)
{
  return a + 1;
}

int func6 (int a)
{
  return a + 1;
}

int func7 (int a)
{
  return a + 1;
}

int func8 (int a)
{
  return a + 1;
}

int main (int argc, char **argv)
{
  return func5 (func6 (func7 (func8 (argc)))) * 
         func4 (func3 (func2 (func1 (argc))));
}
EOF

$ gcc -ggdb3 -ffunction-sections -fdata-sections -c tc.c -o tc.o
tc.c:1: warning: -ffunction-sections may affect debugging on some
targets

$ objdump -h tc.o | egrep '\.text'
  0 .text         00000000  00000000  00000000  00000000  2**4
  7 .text$func1   0000000c  00000000  00000000  00000e8b  2**2
  8 .text$func2   0000000c  00000000  00000000  00000e97  2**2
  9 .text$func3   0000000c  00000000  00000000  00000ea3  2**2
 10 .text$func4   0000000c  00000000  00000000  00000eaf  2**2
 11 .text$func5   0000000c  00000000  00000000  00000ebb  2**2
 12 .text$func6   0000000c  00000000  00000000  00000ec7  2**2
 13 .text$func7   0000000c  00000000  00000000  00000ed3  2**2
 14 .text$func8   0000000c  00000000  00000000  00000edf  2**2
 15 .text$main    00000080  00000000  00000000  00000eeb  2**2

$ gcc tc.o -o tc

$ gdb --quiet tc
(gdb) start
Breakpoint 1 at 0x4013c6: file tc.c, line 43.
[New thread 3064.0xee4]
[New thread 3064.0x19a4]
main (argc=1, argv=0x6aa1a8) at tc.c:43
43      {
(gdb) rbreak func[1-8]
Breakpoint 2 at 0x401343: file tc.c, line 4.
int func1(int);
Breakpoint 3 at 0x40134f: file tc.c, line 9.
int func2(int);
Breakpoint 4 at 0x40135b: file tc.c, line 14.
int func3(int);
Breakpoint 5 at 0x401367: file tc.c, line 19.
int func4(int);
Breakpoint 6 at 0x401373: file tc.c, line 24.
int func5(int);
Breakpoint 7 at 0x40137f: file tc.c, line 29.
int func6(int);
Breakpoint 8 at 0x40138b: file tc.c, line 34.
int func7(int);
Breakpoint 9 at 0x401397: file tc.c, line 39.
int func8(int);
(gdb) disp/i $pc
(gdb) c

Breakpoint 9, func8 (a=1) at tc.c:39
39        return a + 1;
1: x/i $pc
0x401397 <func8+3>:     mov    0x8(%ebp),%eax
(gdb)

Breakpoint 8, func7 (a=2) at tc.c:34
34        return a + 1;
1: x/i $pc
0x40138b <func7+3>:     mov    0x8(%ebp),%eax
(gdb)

Breakpoint 7, func6 (a=3) at tc.c:29
29        return a + 1;
1: x/i $pc
0x40137f <func6+3>:     mov    0x8(%ebp),%eax
(gdb)

Breakpoint 6, func5 (a=4) at tc.c:24
24        return a + 1;
1: x/i $pc
0x401373 <func5+3>:     mov    0x8(%ebp),%eax
(gdb)

Breakpoint 2, func1 (a=1) at tc.c:4
4         return a + 1;
1: x/i $pc
0x401343 <func1+3>:     mov    0x8(%ebp),%eax
(gdb)

Breakpoint 3, func2 (a=2) at tc.c:9
9         return a + 1;
1: x/i $pc
0x40134f <func2+3>:     mov    0x8(%ebp),%eax
(gdb)

Breakpoint 4, func3 (a=3) at tc.c:14
14        return a + 1;
1: x/i $pc
0x40135b <func3+3>:     mov    0x8(%ebp),%eax
(gdb)

Breakpoint 5, func4 (a=4) at tc.c:19
19        return a + 1;
1: x/i $pc
0x401367 <func4+3>:     mov    0x8(%ebp),%eax
(gdb)

Program exited with code 014400.
(gdb) quit
Comment 5 David Edelsohn 2008-04-09 14:41:53 UTC
Subject: Bug 35597

Author: dje
Date: Wed Apr  9 14:41:07 2008
New Revision: 134143

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134143
Log:
        PR libstdc++/35597
        * toplev.c (process_options): Remove -ffunction-sections debugging
        warning.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/toplev.c

Comment 6 Benjamin Kosnik 2008-04-14 20:08:27 UTC
David, can you put this fix on gcc-4_3-branch and close this PR please?
Comment 7 Benjamin Kosnik 2008-04-24 16:58:46 UTC
Second ping. David, I'm setting the target milestone to 4.3.1 for this. Can you please check in your patch to gcc-4_3-branch?
Comment 8 David Edelsohn 2008-04-24 17:59:47 UTC
Subject: Bug 35597

Author: dje
Date: Thu Apr 24 17:59:01 2008
New Revision: 134644

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134644
Log:
        PR libstdc++/35597
        * toplev.c (process_options): Remove -ffunction-sections debugging
        warning.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/toplev.c

Comment 9 David Edelsohn 2008-04-24 18:06:46 UTC
Well, I did not receive your second ping.  But I was traveling and had been planning to check it in today.