Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp wrapper detection imperfect #9697

Closed
p5pRT opened this issue Mar 31, 2009 · 6 comments
Closed

cpp wrapper detection imperfect #9697

p5pRT opened this issue Mar 31, 2009 · 6 comments
Assignees
Labels
Closable? We might be able to close this ticket, but we need to check with the reporter distro-Linux type-core

Comments

@p5pRT
Copy link

p5pRT commented Mar 31, 2009

Migrated from rt.perl.org#64318 (status was 'open')

Searchable as RT64318$

@p5pRT
Copy link
Author

p5pRT commented Mar 31, 2009

From @nwc10

Created by @nwc10

I've been playing with clang, and found a bug in it which prevents building
Errno​: http​://llvm.org/bugs/show_bug.cgi?id=3915

Specifically, clang -E foo.c works, but clang -E foo.h doesn't.
clang -E - <foo.h works too, which would mean that a cpp wrapper would work...

Now, whilst this is a bug in clang, we, in theory, probe for and work around
around buggy C pre-processors, we don't spot this one, because all the tests
in Configure are for testcpp.c

Ideally, to have trapped this, we'd try for testcpp.c and testcpp.h, and if
either fails, deem that approach bad, and try the next. Problem is, that
"next" looks like this​:

if $ok; then
  : nothing
elif echo 'Maybe "'"$cc"' -E" will work...'; \
  $cc -E <testcpp.c >testcpp.out 2>&1; \
  $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  echo "Yup, it does."
  x_cpp="$cc -E"
  x_minus='';
elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
  $cc -E - <testcpp.c >testcpp.out 2>&1; \
  $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  echo "Yup, it does."
  x_cpp="$cc -E"
  x_minus='-';
elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
  $cc -P <testcpp.c >testcpp.out 2>&1; \
  $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  echo "Yipee, that works!"
  x_cpp="$cc -P"
  x_minus='';
elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
  $cc -P - <testcpp.c >testcpp.out 2>&1; \
  $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  echo "At long last!"
  x_cpp="$cc -P"
  x_minus='-';
elif echo 'No such luck, maybe "'$cpp'" will work...'; \
  $cpp <testcpp.c >testcpp.out 2>&1; \
  $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  echo "It works!"
  x_cpp="$cpp"
  x_minus='';
elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
  $cpp - <testcpp.c >testcpp.out 2>&1; \
  $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  echo "Hooray, it works! I was beginning to wonder."
  x_cpp="$cpp"
  x_minus='-';
elif echo 'Uh-uh. Time to get fancy. Trying a wrapper...'; \
  $wrapper <testcpp.c >testcpp.out 2>&1; \
  $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  x_cpp="$wrapper"
  x_minus=''
  echo "Eureka!"
else
  dflt=''
  rp="No dice. I can't find a C preprocessor. Name one​:"
  . ./myread
  x_cpp="$ans"
  x_minus=''
  $x_cpp <testcpp.c >testcpp.out 2>&1
  if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  echo "OK, that will do." >&4
  else
echo "Sorry, I can't get that to work. Go find one and rerun Configure." >&4
  exit 1
  fi
fi

Is there a clean way to adapt all of that to loop for both file names?
Is there a better approach?

Nicholas Clark

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.11.0:

Configured by nclark at Tue Mar 31 15:39:45 BST 2009.

Summary of my perl5 (revision 5 version 11 subversion 0) configuration:
  Commit id: cedab142c3511603d566403c134158cf036c418d
  Platform:
    osname=linux, osvers=2.6.24-23-generic, archname=i686-linux
    uname='linux vun---ha-ha-ha.cambridge.moo 2.6.24-23-generic #1 smp mon jan 26 00:13:11 utc 2009 i686 gnulinux '
    config_args='-Dusedevel=y -Dcc=/home/nclark/build/llvm/Debug/bin/clang -Dld=ccache /home/nclark/build/llvm/Debug/bin/clang -Ubincompat5005 -Uinstallusrbinperl -Dcf_email=nick@ccl4.org -Dperladmin=nick@ccl4.org -Dinc_version_list=  -Dinc_version_list_init=0 -Doptimize=-Os -Uusethreads -Uuse64bitint -Accflags=-DNO_MATHOMS -Uusemymalloc -Duseperlio -Dprefix=~/Sandpit/snap5.9.x-GitLive-blead-882-gcedab14 -Dinstallman1dir=none -Dinstallman3dir=none -Uuserelocatableinc -de'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='/home/nclark/build/llvm/Debug/bin/clang', ccflags ='-DNO_MATHOMS -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-Os',
    cppflags='-DNO_MATHOMS -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 Compatible Clang Compiler', 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='ccache /home/nclark/build/llvm/Debug/bin/clang', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.7'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -Os -L/usr/local/lib -fstack-protector'

Locally applied patches:
    PERL_GIT_UNPUSHED_COMMITS    	/* do not remove this line */
    PERL_GIT_UNCOMMITTED_CHANGES	/* do not remove this line */


@INC for perl 5.11.0:
    lib
    /home/nclark/Sandpit/snap5.9.x-GitLive-blead-882-gcedab14/lib/perl5/site_perl/5.11.0/i686-linux
    /home/nclark/Sandpit/snap5.9.x-GitLive-blead-882-gcedab14/lib/perl5/site_perl/5.11.0
    /home/nclark/Sandpit/snap5.9.x-GitLive-blead-882-gcedab14/lib/perl5/5.11.0/i686-linux
    /home/nclark/Sandpit/snap5.9.x-GitLive-blead-882-gcedab14/lib/perl5/5.11.0
    .


Environment for perl 5.11.0:
    HOME=/home/nclark
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/nclark/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/sbin:/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Apr 3, 2009

From @doughera88

On Tue, 31 Mar 2009, Nicholas Clark wrote​:

I've been playing with clang, and found a bug in it which prevents building
Errno​: http​://llvm.org/bugs/show_bug.cgi?id=3915

Specifically, clang -E foo.c works, but clang -E foo.h doesn't.
clang -E - <foo.h works too, which would mean that a cpp wrapper would work...

Now, whilst this is a bug in clang, we, in theory, probe for and work around
around buggy C pre-processors, we don't spot this one, because all the tests
in Configure are for testcpp.c

It's not the .c vs. .h issue per se. It's that all the tests
are piped from stdin. (This is the probe for $cppstdin, after all.)
The tests all look something like​:

  $cc -E <testcpp.c >testcpp.out 2>&1

The .c vs. .h distinction is irrelevant here.

I gather Errno is trying to do something subtly different, and not just
reading from stdin. Do you know where, specifically, in Errno the problem
is arising, or shall I go spelunking?

--
  Andy Dougherty doughera@​lafayette.edu

@p5pRT
Copy link
Author

p5pRT commented Apr 3, 2009

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Apr 3, 2009

From @nwc10

On Fri, Apr 03, 2009 at 08​:53​:16AM -0400, Andy Dougherty wrote​:

It's not the .c vs. .h issue per se. It's that all the tests
are piped from stdin. (This is the probe for $cppstdin, after all.)
The tests all look something like​:

 $cc \-E \<testcpp\.c >testcpp\.out 2>&1

The .c vs. .h distinction is irrelevant here.

I gather Errno is trying to do something subtly different, and not just
reading from stdin. Do you know where, specifically, in Errno the problem
is arising, or shall I go spelunking?

ext/Errro/Errno_pm.PL, here​:

  # With the -dM option, gcc outputs every #define it finds
  unless(open(FH,"$Config{cc} -E -dM $Config{cppflags} $file |")) {
  warn "Cannot open '$file'";
  return;
  }

And yes, I realised soon after I sent the bug report that the wrapper would
have made no difference.

Nicholas Clark

@toddr toddr added the Closable? We might be able to close this ticket, but we need to check with the reporter label Feb 4, 2020
@jkeenan
Copy link
Contributor

jkeenan commented Feb 10, 2020

The clang bug to which Nick linked was fixed in 2009. perl builds and tests fine with clang, including tests for Errno.

I am taking it for the purpose of closing it in 7 days unless someone seriously objects.

@nwc10

Thank you very much.
Jim Keenan

@jkeenan jkeenan self-assigned this Feb 10, 2020
@jkeenan
Copy link
Contributor

jkeenan commented Feb 16, 2020

The clang bug to which Nick linked was fixed in 2009. perl builds and tests fine with clang, including tests for Errno.

I am taking it for the purpose of closing it in 7 days unless someone seriously objects.

@nwc10

Thank you very much.
Jim Keenan

Closing as per schedule.

@jkeenan jkeenan closed this as completed Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closable? We might be able to close this ticket, but we need to check with the reporter distro-Linux type-core
Projects
None yet
Development

No branches or pull requests

3 participants