Ticket #1110 (closed bug: fixed)

Opened 12 years ago

Last modified 12 years ago

parrot fails to build with g++ 4.4.1 on Ubuntu 9.10 beta amd64

Reported by: mikehh Owned by: NotFound
Priority: normal Milestone:
Component: build Version: trunk
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

I got an early build failure building parrot with g++ 4.4.1 on Ubuntu 9.10 beta (updated to latest from repos) - it builds with no problems using gcc 4.4.1 and builds with g++ 4.3 on Ubuntu 9.04 amd64.

It appears g++ 4.4 is much more strict than g++ 4.3

using the following config options:

perl Configure.pl --optimize --test --cc=g++ --cxx=g++ --link=g++ --ld=g++ --maintainer --configure_trace

with g++ 4.4 we get (at r41838 - Ubuntu 9.10 beta (updated) amd64)

The first few lines are: (the third line is line wrapped)

Compiling with:
xx.c
g++ -I./include -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -DDEBIAN -pipe -fstack-protector
 -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHASATTRIBUTE_CONST
 -DHASATTRIBUTE_DEPRECATED -DHASATTRIBUTE_MALLOC  -DHASATTRIBUTE_NONNULL -DHASATTRIBUTE_NORETURN
 -DHASATTRIBUTE_PURE -DHASATTRIBUTE_UNUSED -DHASATTRIBUTE_WARN_UNUSED_RESULT -falign-functions=16
 -fvisibility=hidden -funit-at-a-time -maccumulate-outgoing-args -W -Wall -Waggregate-return
 -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wdisabled-optimization -Wendif-labels
 -Wextra -Wformat -Wformat-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k
 -Wimplicit -Wimport -Winit-self -Winline -Winvalid-pch -Wlogical-op -Wmissing-braces
 -Wmissing-field-initializers -Wno-missing-format-attribute -Wmissing-include-dirs -Wpacked
 -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wno-shadow -Wsign-compare
 -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wtrigraphs -Wundef
 -Wunknown-pragmas -Wno-unused -Wvariadic-macros -Wwrite-strings -Wlarger-than-4096
 -DDISABLE_GC_DEBUG=1 -DNDEBUG -O2 -g -DHAS_GETTEXT -DHAVE_COMPUTED_GOTO
 -DCLOCK_BEST=CLOCK_PROCESS_CPUTIME_ID -fPIC -I. -o xx.o -c xx.c
/usr/local/bin/perl tools/build/vtable_extend.pl
/usr/local/bin/perl tools/build/pbcversion_h.pl > include/parrot/pbcversion.h
...
... all /usr/bin/perl tools/build ...
...
/usr/local/bin/perl tools/build/c2str.pl --all
src/string/api.c
In file included from src/string/api.c:29:
src/string/private_cstring.h:20: warning: size of ‘parrot_cstrings’ is 19856 bytes
src/string/api.c: In function ‘STRING* Parrot_str_unescape(parrot_interp_t*, const char*, char, const char*)’:
src/string/api.c:2801: error: invalid conversion from ‘const char*’ to ‘char*’
make: *** [src/string/api.o] Error 1

the relevant lines from src/string.api.c are:

starting at line 2774 - the last line is where it fails (2801) p = strchr(enc_char, ':'); although I think the problem is the if just above -> enc_char = "ascii";

PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
STRING *
Parrot_str_unescape(PARROT_INTERP,
    ARGIN(const char *cstring), char delimiter, ARGIN_NULLOK(const char *enc_char))
{
    ASSERT_ARGS(Parrot_str_unescape)
    size_t          clength = strlen(cstring);
    Parrot_UInt4    r;
    String_iter     iter;
    STRING         *result;
    const ENCODING *encoding;
    const CHARSET  *charset;
    char           *p;
    UINTVAL         offs, d;

    /* we are constructing const table strings here */
    const UINTVAL   flags = PObj_constant_FLAG;

    if (delimiter && clength)
        --clength;

    /* default is ascii */
    if (!enc_char)
        enc_char = "ascii";

    /* check for encoding: */
    p = strchr(enc_char, ':');

with g++ 4.3 the above section is (at r41808 - Ubuntu 9.04 amd64):

The first few lines are: (the third line is line wrapped)

Compiling with:
xx.c
g++ -I./include -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -pipe -fstack-protector -I/usr/local/include
 -DHASATTRIBUTE_CONST -DHASATTRIBUTE_DEPRECATED -DHASATTRIBUTE_MALLOC -DHASATTRIBUTE_NONNULL
 -DHASATTRIBUTE_NORETURN -DHASATTRIBUTE_PURE -DHASATTRIBUTE_UNUSED -DHASATTRIBUTE_WARN_UNUSED_RESULT
 -falign-functions=16 -fvisibility=hidden -funit-at-a-time -maccumulate-outgoing-args -W -Wall
 -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wdisabled-optimization
 -Wendif-labels -Wextra -Wformat -Wformat-extra-args -Wformat-nonliteral -Wformat-security
 -Wformat-y2k -Wimplicit -Wimport -Winit-self -Winline -Winvalid-pch -Wlogical-op -Wmissing-braces
 -Wmissing-field-initializers -Wno-missing-format-attribute -Wmissing-include-dirs -Wpacked
 -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wno-shadow -Wsign-compare
 -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wtrigraphs -Wundef
 -Wunknown-pragmas -Wno-unused -Wvariadic-macros -Wwrite-strings -Wlarger-than-4096
 -DDISABLE_GC_DEBUG=1 -DNDEBUG -O2 -g -DHAS_GETTEXT -DHAVE_COMPUTED_GOTO
 -DCLOCK_BEST=CLOCK_PROCESS_CPUTIME_ID -fPIC -I. -o xx.o -c xx.c
/usr/local/bin/perl tools/build/vtable_extend.pl
/usr/local/bin/perl tools/build/pbcversion_h.pl > include/parrot/pbcversion.h
...
... all /usr/bin/perl tools/build ...
...
/usr/local/bin/perl tools/build/c2str.pl --all
src/string/api.c
In file included from src/string/api.c:29:
src/string/private_cstring.h:20: warning: size of ‘parrot_cstrings’ is 19632 bytes
src/ops/core_ops.c
...
... continues to a sucessfull build
...
Linked: parrot_nqp

Notes:

perl is 5.10.1 in both cases but I built perl from origin/Maint-5.10 on Ubuntu 9.10 beta amd64 whereas I built from tags/Perl-5.10.1 on Ubuntu 9.04 amd64 - I might have got a couple of options different in sh Configure

src/string/api.c was last modified at r41543

Attachments

20091013.41850.parrot.txt.gz Download (8.9 KB) - added by jkeenan 12 years ago.
build in trunk on Linux/i386 with this configuration: perl Configure.pl --optimize --cc=g++ --cxx=g++ --link=g++ --ld=g++ --maintainer

Change History

follow-up: ↓ 2   Changed 12 years ago by jkeenan

mikehh:

I took your inspiration and tried with similar options (all except --test and --configure_trace, which are not at issue here) on Linux/i386:

perl Configure.pl --optimize --cc=g++ --cxx=g++ --link=g++ --ld=g++ --maintainer

I should note that I've never before tried to configure/build with any of these options.

Results: I was able to build successfully, though I saw quite a few more warnings during make than I normally do. See attachment 20091013.41850.parrot.txt.gz.

make test, however, passed with shining colors.

So (regrettably) this seems to be a platform-specific issue.

Thank you very much.

kid51

Changed 12 years ago by jkeenan

build in trunk on Linux/i386 with this configuration: perl Configure.pl --optimize --cc=g++ --cxx=g++ --link=g++ --ld=g++ --maintainer

in reply to: ↑ 1   Changed 12 years ago by jkeenan

Replying to jkeenan:

mikehh: I took your inspiration and tried with similar options (all except --test and --configure_trace, which are not at issue here) on Linux/i386: {{{ perl Configure.pl --optimize --cc=g++ --cxx=g++ --link=g++ --ld=g++ --maintainer }}}

I should have noted:

g++ --version
g++ (Debian 4.3.2-1.1) 4.3.2

mikehh indicated on channel that the problem for him was g++ 4.4.1 versus g++ 4.3. So maybe this is not a platform-specific issue after all, but, rather, a compiler version issue.

  Changed 12 years ago by mikehh

on irc NotFound++ stated that there were a lot of problems with strchr in C++. I searched for g++ and strchr and found quite a few entries - I found some information on launchpad that might be relevant.

In  https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/412933 I found the following comment

Matthias Klose  wrote on 2009-08-13: 
this is unrelated to GCC, but is seen with glibc-2.10; see a diff of the preprocessed file (built with libc6-dev 2.9, vs built with 2.10.1)

-extern char *strchr (__const char *__s, int __c)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));

-extern char *strrchr (__const char *__s, int __c)
- throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
+extern "C++"
+{
+extern char *strchr (char *__s, int __c)
+ throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
+extern __const char *strchr (__const char *__s, int __c)
+ throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
+
+
+extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) char *
+strchr (char *__s, int __c) throw ()
+{
+ return __builtin_strchr (__s, __c);
+}

+extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__)) __const char *
+strchr (__const char *__s, int __c) throw ()
+{
+ return __builtin_strchr (__s, __c);
+}

  Changed 12 years ago by mikehh

at parrot r42035 I built with g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3 on Ubuntu 9.04 amd64 and got the following results:

trunk - pre/post-config, smoke (#29338) PASS, fulltest FAIL at r42035 - Ubuntu 9.04 amd64 (g++)
t/op/annotate-old.t -  Failed test:  1 - in testf and testg (TT #1135)
t/pmc/threads.t - Failed tests:  9, 14 - in testr
the remainder of fulltest passes

at the same revision I attempted to build with g++ (Ubuntu 4.4.1-4ubuntu8) 4.4.1 on Ubuntu 9.10 beta (updated) amd64 - the build failed in src/string/api.c as follows:

...
/usr/local/bin/perl tools/build/c2str.pl --all
src/string/api.c
In file included from src/string/api.c:29:
src/string/private_cstring.h:20: warning: size of ‘parrot_cstrings’ is 19904 bytes
src/string/api.c: In function ‘STRING* Parrot_str_unescape(parrot_interp_t*, const char*, char, const char*)’:
src/string/api.c:2790: error: invalid conversion from ‘const char*’ to ‘char*’
make: *** [src/string/api.o] Error 1

The size warning is because I configured with --maintainer (which reports strings greater than 4096 chars), the relevant line in src/string.api.c is the last line in the following section of the code:

PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
STRING *
Parrot_str_unescape(PARROT_INTERP,
    ARGIN(const char *cstring), char delimiter, ARGIN_NULLOK(const char *enc_char))
{
    ASSERT_ARGS(Parrot_str_unescape)

    STRING         *result;
    const ENCODING *encoding;
    const CHARSET  *charset;

    /* the default encoding is ascii */
    const char     *enc_name = enc_char ? enc_char : "ascii";

    /* does the encoding have a character set? */
    char           *p        = enc_char ? strchr(enc_char, ':') : NULL;

Note that this builds with no problems with g++ 4.3.3 but fails with g++ 4.4.1 - this might be due to the later library used. (see the previous comment)

  Changed 12 years ago by mikehh

I looked at the definition problem after the release version of Ubuntu 9.10 amd64

extract from /usr/include/string.h with Ubuntu 9.04 amd64

__BEGIN_NAMESPACE_STD
/* Find the first occurrence of C in S.  */
extern char *strchr (__const char *__s, int __c)
     __THROW __attribute_pure__ __nonnull ((1));

extract from /usr/include/string.h with Ubuntu 9.10 amd64

__BEGIN_NAMESPACE_STD
/* Find the first occurrence of C in S.  */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
{
extern char *strchr (char *__s, int __c)
     __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
extern __const char *strchr (__const char *__s, int __c)
     __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));

# ifdef __OPTIMIZE__
__extern_always_inline char *
strchr (char *__s, int __c) __THROW
{
  return __builtin_strchr (__s, __c);
}

__extern_always_inline __const char *
strchr (__const char *__s, int __c) __THROW
{
  return __builtin_strchr (__s, __c);
}
# endif
}
#else
extern char *strchr (__const char *__s, int __c)
     __THROW __attribute_pure__ __nonnull ((1));
#endif

as far as gcc is concerned the definition is the same (the #else branch at the end) however the g++ definition is now different.

  Changed 12 years ago by NotFound

  • status changed from new to assigned
  • owner set to NotFound

After upgrading my laptop to Ubuntu 9.10, fixed all problems manifested by strchr, that were really char * constness problems. in r42248

If there are no more reports related, I'll close the ticket in a few days.

  Changed 12 years ago by mikehh

the build works fine for me with g++ on my available test platforms: Ubuntu 9.04 and 9.10 amd64 (g++ 4.3.3 and 4.4.1) and also on Ubuntu 9.10 i386 (also gcc builds ok).

  Changed 12 years ago by NotFound

  • status changed from assigned to closed
  • resolution set to fixed

Resolving ticket

Note: See TracTickets for help on using tickets.