_h2ph_pre.ph / $Config{cppsymbols} omits gcc-3.4+ cpp "predefined macros"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a bug report for perl from jvdias@xxxxxxxxxx,
generated with the help of perlbug 1.35 running under perl v5.8.8.


-----------------------------------------------------------------
[Please enter your report here]

The gcc cpp "predefined macros" have no definitions in _h2ph_pre.ph,
causing many includes of .ph files to fail, eg. :
<pre>
$ perl -e 'require "sys/socket.ph";'
Undefined subroutine &main::__LONG_MAX__ called at (eval 259) line 1.
Compilation failed in require at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/sys/socket.ph line 11.
Compilation failed in require at -e line 1
</pre>

__LONG_MAX__, and __INT_MAX__, and many other '#define's, have NO
definition in ANY header file with gcc-3.4+, but are built-in to
cpp, as described in the gcc.info documention on the cpp option '-dM':
<pre>
  `-dCHARS' ...
        `M'
          Instead of the normal output, generate a list of `#define'
          directives for all the macros defined during the execution of
          the preprocessor, including predefined macros.  This gives
          you a way of finding out what is predefined in your version
          of the preprocessor.  Assuming you have no file `foo.h', the
          command

               touch foo.h; cpp -dM foo.h

          will show all the predefined macros.
</pre>

With gcc-4+ on i386 Fedora Core, many '#define's are "predefined" in cpp:
<pre>
$ >foo.h; cpp -dM foo.h | egrep '_MAX__|__VERSION|long '
#define __WCHAR_MAX__ 2147483647
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
#define __UINTMAX_TYPE__ long long unsigned int
#define __SCHAR_MAX__ 127
#define __DBL_MAX__ 1.7976931348623157e+308
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __VERSION__ "4.1.0 20060128 (Red Hat 4.1.0-0.17)"
#define __LONG_MAX__ 2147483647L
#define __WCHAR_TYPE__ long int
#define __INT_MAX__ 2147483647
#define __INTMAX_MAX__ 9223372036854775807LL
#define __FLT_MAX__ 3.40282347e+38F
#define __INTMAX_TYPE__ long long int
</pre>

Also, many of these '#define's will cause the current version of
h2ph to emit bad definitions - ie
  __VERSION__="4.1.0\ 20060128\ (Red\ Hat\ 4.1.0-0.17)"
would have become:
<pre>
 unless (defined &__VERSION__) { sub __VERSION__() { "\"4\.1\.0\\" } }
</pre>
because h2ph split the $Config{cppsymbols} on /\s/ only.
Also floating point defintions were mangled into strings by h2ph:
<pre>
 unless (defined &__LDBL_MAX__) { sub __LDBL_MAX__() { "1\.18973149535723176502e\+4932L" }
</pre>
This problem was originally reported as Red Hat bugzilla #178343:
  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=178343
and is present in all current perl versions - 5.8.7, 5.8.8-RC1, and 5.9.3+ (bleadperl).

So here's a patch against the 5.8.8-RC1 source to merge in the cpp internal 
"predefined macro" definitions into Cppsym.true in Configure, so they appear in 
$Config{cppsymbols}, and to fix h2ph's _extract_cc_defines() and 
build_preamble_if_necessary() subs to deal with escaped whitespace symbol values,
floating point constants, signed numeric constants, and parethensized values properly:

<pre>
___ BEGIN PATCH: ___
--- perl-5.8.8-RC1/Configure.bz178343   2006-01-08 09:51:03.000000000 -0500
+++ perl-5.8.8-RC1/Configure    2006-01-31 11:50:02.000000000 -0500
@@ -20230,6 +20230,19 @@
 chmod +x Cppsym.try
 $eunicefix Cppsym.try
 ./Cppsym < Cppsym.know > Cppsym.true
+: Add in any linux cpp "predefined macros":
+if [[ "$osname" == *linux* ]] && [[ "$ccname" == *gcc* ]]; then
+tHdrH=`mktemp ./XXXXXX`
+rm -f $tHdrH'.h' $tHdrH
+touch $tHdrH'.h'
+if cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ] ; then
+   sed 's/#define[\ \  ]*//;s/[\ \     ].*$//' < $tHdrH'_cppsym.h' > $tHdrH'_cppsym.real';
+   if [ -s $tHdrH'_cppsym.real' ]; then
+      cat $tHdrH'_cppsym.real' Cppsym.know  | sort | uniq | ./Cppsym | sort | uniq > Cppsym.true;
+   fi;
+fi
+rm -f $tHdrH'.h' $tHdrH'_cppsym.h' $tHdrH'_cppsym.real';
+fi;
 : now check the C compiler for additional symbols
 postprocess_cc_v=''
 case "$osname" in
--- perl-5.8.8-RC1/utils/h2ph.PL.bz178343       2006-01-13 12:56:47.000000000 -0500
+++ perl-5.8.8-RC1/utils/h2ph.PL        2006-01-31 11:53:24.000000000 -0500
@@ -778,8 +778,16 @@
             if ($opt_D) {
                 print PREAMBLE "# $_=$define{$_}\n";
             }
-
-            if ($define{$_} =~ /^(\d+)U?L{0,2}$/i) {
+           if ($define{$_} =~ /^\((.*)\)$/) {
+             # parenthesized value:  d=(v)
+               $define{$_} = $1;
+           };
+           if ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/ ) {
+             # float:
+               print PREAMBLE
+                    "unless (defined &$_) { sub $_() { $1 } }\n\n";
+           } elsif ($define{$_} =~ /^([+-]?\d+)U?L{0,2}$/i) {
+             # integer:
                 print PREAMBLE
                     "unless (defined &$_) { sub $_() { $1 } }\n\n";
             } elsif ($define{$_} =~ /^\w+$/) {
@@ -805,9 +813,8 @@
         @Config{'ccsymbols', 'cppsymbols', 'cppccsymbols'};

     # Split compiler pre-definitions into `key=value' pairs:
-    foreach (split /\s+/, $allsymbols) {
-        /(.+?)=(.+)/ and $define{$1} = $2;
-
+    while( $allsymbols=~/([^\s]+)=((\\\s|[^\s])+)/g ) {
+        $define{$1} = $2;
         if ($opt_D) {
             print STDERR "$_:  $1 -> $2\n";
         }
___ END PATCH ___
</pre>

Please consider fixing this issue in the upcoming 5.8.8 / 5.9.3 releases,
as many header files are made unusable by this problem .

Thanks & Regards,
Jason Vas Dias<jvdias@xxxxxxxxxx>
perl package maintainer
Red Hat, Inc.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
This perlbug was built using Perl v5.8.8 in the Red Hat build system.
It is being executed now by  Perl v5.8.8 - Fri Jan 20 16:43:53 EST 2006.

Site configuration information for perl v5.8.8:

Configured by Red Hat, Inc. at Fri Jan 20 16:43:53 EST 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.15-1.1863_fc5, archname=i386-linux-thread-multi
    uname='linux jvdias 2.6.15-1.1863_fc5 #1 thu jan 19 19:17:58 est 2006 i686 i686 i386 gnulinux '
    config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -Dversion=5.8.8 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dinc_version_list=5.8.7 5.8.6 5.8.5 5.8.4 5.8.3 -Dscriptdir=/usr/bin'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='4.1.0 20060117 (Red Hat 4.1.0-0.15)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.3.90.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.3.90'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    RC1

---
@INC for perl v5.8.8:
    /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl/5.8.7
    /usr/lib/perl5/site_perl/5.8.6
    /usr/lib/perl5/site_perl/5.8.5
    /usr/lib/perl5/site_perl/5.8.4
    /usr/lib/perl5/site_perl/5.8.3
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl/5.8.7
    /usr/lib/perl5/vendor_perl/5.8.6
    /usr/lib/perl5/vendor_perl/5.8.5
    /usr/lib/perl5/vendor_perl/5.8.4
    /usr/lib/perl5/vendor_perl/5.8.3
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/5.8.8
    .

---
Environment for perl v5.8.8:
    HOME=/home/boston/jvdias
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/kerberos/bin:/usr/bin:/bin:/usr/bin:/usr/games:/usr/X11R6/bin:/home/boston/jvdias/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Legacy Announce]     [Fedora PHP Devel]     [Kernel Devel]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Big List of Linux Books]     [Gimp]     [Yosemite Information]
  Powered by Linux