Bug 22205 - [4.1 Regression] errors debug mode on aix
Summary: [4.1 Regression] errors debug mode on aix
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Benjamin Kosnik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-27 19:47 UTC by Benjamin Kosnik
Modified: 2005-09-22 08:16 UTC (History)
3 users (show)

See Also:
Host: powerpc-ibm-aix5.2.0.0
Target: powerpc-ibm-aix5.2.0.0
Build: powerpc-ibm-aix5.2.0.0
Known to work:
Known to fail:
Last reconfirmed: 2005-07-31 04:06:12


Attachments
libstdc++.log for AIX, demonstrating issue (52.38 KB, application/x-bzip2)
2005-06-27 19:47 UTC, Benjamin Kosnik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Kosnik 2005-06-27 19:47:15 UTC
On systems without weak, debug mode tests will fail. This causes some
unpleasantness on AIX, for instance.

This can be verified on x86/linux using -fno-weak.

What needs to happen is that the debug mode tests should be smart enough to tell
if the underlying system doesn't support weak, so that the test case cannot be
run. There are several other things that work like this ("C" locale, etc) so
adding one more shouldn't be a big deal.
Comment 1 Benjamin Kosnik 2005-06-27 19:47:50 UTC
Created attachment 9162 [details]
libstdc++.log for AIX, demonstrating issue
Comment 2 Andrew Pinski 2005-06-27 21:59:14 UTC
This is a regression in that you no longer can use the debug mode with -fno-weak.
Comment 3 David Edelsohn 2005-06-27 22:01:22 UTC
AIX 5.2 does support weak, so I believe that there is something wrong with the
analysis.
Comment 4 Andrew Pinski 2005-06-27 22:03:49 UTC
Actually if you look into the email which David sent, you would see:
# 0 "<built-in>"
#define __GXX_WEAK__

Which means there is weak support.
Comment 5 Paolo Carlini 2005-06-28 11:41:55 UTC
Humm, I wonder whether the problem isn't *really* trivial :)
In include/bits/c++config we have:

#ifdef _GLIBCXX_DEBUG
# if __GXX_WEAK__
#  define _GLIBCXX_STD __gnu_norm
#  define _GLIBCXX_EXTERN_TEMPLATE 0
...
...
# else
#  warning debug mode disabled due to lack of weak symbol support
# endif

Should be, instead, 'ifdef __GXX_WEAK__' ?!?
Comment 6 Paolo Carlini 2005-06-28 11:45:47 UTC
Or, wrt Andrew's comment, AIX should really have, consistently with the docs:
#define __GXX_WEAK__ 1

??
Comment 7 David Edelsohn 2005-06-28 14:16:59 UTC
I do not understand the comment about GCC for AIX setting GXX_WEAK consistently.
    The value is set by GCC itself, not overridden by AIX.

GXX_WEAK is defined by c-cppbuiltin.c:

      if (flag_weak && SUPPORTS_ONE_ONLY) 
        cpp_define (pfile, "__GXX_WEAK__=1");
      else
        cpp_define (pfile, "__GXX_WEAK__=0");

and depends on SUPPORTS_ONE_ONLY, not just weak support.  I will test if setting
MAKE_DECL_ONE_ONLY works on AIX.
Comment 8 Paolo Carlini 2005-06-28 14:27:53 UTC
A clarification about __GXX_WEAK__: Andrew reports that, on AIX we have:
#define __GXX_WEAK__
If that is really the case (I cannot check, sorry), then the library is not
checking correctly the macro, because uses:
# if __GXX_WEAK__
which should be changed to:
# ifdef __GXX_WEAK__
Alternately, on AIX we should have:
#define __GXX_WEAK__ 1

I'm saying everywhere "on AIX" because for sure many other "weak" targets
are ok as they are. 

Agreed?
Comment 9 David Edelsohn 2005-07-31 04:25:39 UTC
I tried overriding libstdc++'s definition of __GXX_WEAK__ and GCC's definition
of ONE_ONLY.  Both caused additional C++ testsuite failures.  AIX does support
weak, but not exactly the way that G++ is expecting.
Comment 10 Andrew Pinski 2005-08-11 14:16:23 UTC
A real good question is why does debug mode need link once at all?
Comment 11 Benjamin Kosnik 2005-09-13 23:21:10 UTC
It was discovered that to use string, you have to do all this magic with the
debug mode that involves not using extern template and a bunch of the other
linkage optimizations. There were some PRs about this.

That's why systems without weak will no longer support the debug mode. That's
not going to change.

However, fixing this so that debug mode is not tested (marked unsupported)
instead of failing seems reasonable.

Working on a patch...
Comment 12 GCC Commits 2005-09-15 18:59:03 UTC
Subject: Bug 22205

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bkoz@gcc.gnu.org	2005-09-15 18:58:04

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: c++config 
	libstdc++-v3/testsuite/21_strings/basic_string/element_access/char: 
	                                                                    21674.cc 
	libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t: 
	                                                                       21674.cc 
	libstdc++-v3/testsuite/lib: dg-options.exp libstdc++.exp 

Log message:
	2005-09-15  Benjamin Kosnik  <bkoz@redhat.com>
	
	PR libstdc++/21674
	PR libstdc++/22205
	PR libstdc++/22222
	* include/bits/c++config: Set _GLIBCXX_STD regardless of __GXX_WEAK__.
	Add in check for __NO_INLINE__ for warning.
	* testsuite/lib/dg-options.exp (dg-require-debug-mode): New.
	* testsuite/lib/libstdc++.exp (check_v3_target_debug_mode): New.
	* testsuite/21_strings/basic_string/element_access/char/21674.cc:
	Use it.
	* testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc:
	Use it.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.3107&r2=1.3108
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/c++config.diff?cvsroot=gcc&r1=1.1408&r2=1.1409
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/lib/dg-options.exp.diff?cvsroot=gcc&r1=1.5&r2=1.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/lib/libstdc++.exp.diff?cvsroot=gcc&r1=1.48&r2=1.49

Comment 13 Benjamin Kosnik 2005-09-22 08:16:29 UTC
Fixed.