ingydotnet / inline-c-pm

10 stars 19 forks source link

t/27inline_maker.t fails with gcc 5.4.0 #91

Closed kevinxie4c closed 5 years ago

kevinxie4c commented 5 years ago

Hi, t/27inline_maker.t fails here:

# cc -c  -iquote"/home/kevinxie/.cpan/build/Inline-C-0.80-kACwGu/_Inline_27inline_maker.133011/src dir" -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/no-such-path/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"1.23\" -DXS_VERSION=\"1.23\" -fPIC "-I/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/5.22.2/x86_64-linux-thread-multi/CORE"   Simple.c
# gcc: error: dir: No such file or directory

Changing

my $src_dir = File::Spec->catdir($base_dir, 'src dir');
my $inst_dir = File::Spec->catdir($base_dir, 'inst dir');

to

my $src_dir = File::Spec->catdir($base_dir, 'src_dir');
my $inst_dir = File::Spec->catdir($base_dir, 'inst_dir');

solves this problem.

mohawk2 commented 5 years ago

Unfortunately, the purpose of the test is to highlight exactly whether the code works with directories with spaces in. Therefore, changing the test to not have spaces in is counter-productive.

Are you able to try different versions to confirm for sure it is only gcc 5.4.0 that has the problem?

Also, can you give your perl -V output?

kevinxie4c commented 5 years ago

I don't have a chance to try that because I don't have the root privilege to install newer version. But maybe I can build GCC from source... Here is my perl -V output:

Summary of my perl5 (revision 5 version 22 subversion 2) configuration:

  Platform:
    osname=linux, osvers=3.10.0-693.21.1.el7.x86_64, archname=x86_64-linux-thread-multi
    uname='linux localhost 3.10.0-693.21.1.el7.x86_64 #1 smp wed mar 7 19:03:37 utc 2018 x86_64 gnulinux '
    config_args='-de -Dcc=cc -Uinstallusrbinperl -Dinstallstyle=lib/perl5 -Duseshrplib -Dlocincpth=/no-such-path/include -Dloclibpth=/cvmfs/soft.computecanada.ca/nix/store/63pk88rnmkzjblpxydvrmskkc8ci7cx6-glibc-2.24/lib -Dusethreads -Dprefix=/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2 -Dman1dir=/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/share/man/man1 -Dman3dir=/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/share/man/man3'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/no-such-path/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/no-such-path/include'
    ccversion='', gccversion='5.4.0', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector-strong -L/cvmfs/soft.computecanada.ca/nix/store/63pk88rnmkzjblpxydvrmskkc8ci7cx6-glibc-2.24/lib'
    libpth=
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.24'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/5.22.2/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/cvmfs/soft.computecanada.ca/nix/store/63pk88rnmkzjblpxydvrmskkc8ci7cx6-glibc-2.24/lib -fstack-protector-strong'

Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS
                        USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE
                        USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME
                        USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API
  Built under linux
  Compiled at Apr 29 2016 20:14:57
  %ENV:
    PERL5LIB="/home/kevinxie/perl5/lib/perl5:/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5:/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl"
    PERL5OPT="-I/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5 -I/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl"
    PERLBREW_HOME="/home/kevinxie/.perlbrew"
    PERLBREW_ROOT="/home/kevinxie/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.84"
    PERL_LOCAL_LIB_ROOT="/home/kevinxie/perl5"
    PERL_MB_OPT="--install_base "/home/kevinxie/perl5""
    PERL_MM_OPT="INSTALL_BASE=/home/kevinxie/perl5"
  @INC:
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl/5.22.2/x86_64-linux-thread-multi
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl/5.22.2
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/5.22.2/x86_64-linux-thread-multi
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/5.22.2
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5
    /home/kevinxie/perl5/lib/perl5/5.22.2/x86_64-linux-thread-multi
    /home/kevinxie/perl5/lib/perl5/5.22.2
    /home/kevinxie/perl5/lib/perl5/x86_64-linux-thread-multi
    /home/kevinxie/perl5/lib/perl5
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/5.22.2/x86_64-linux-thread-multi
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/5.22.2
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl/5.22.2/x86_64-linux-thread-multi
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl/5.22.2
    /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl
    /cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/site_perl/5.22.2/x86_64-linux-thread-multi
    /cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/site_perl/5.22.2
    /cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/5.22.2/x86_64-linux-thread-multi
    /cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/5.22.2
sisyphus commented 5 years ago

Looks to me that the quotes are getting lost, thereby making "dir" the name of an input file. (That may well have been obvious to others, but it took me a few minutes to realize.)

$ cc -c -iquote"/src dir" try.c $ cc -c -iquote/src dir try.c cc: error: dir: No such file or directory $

That's exactly the same error, except that, for me, "cc" shows up as "cc" instead of "gcc". I don't know what, if any, is the significance of that difference.

Cheers, Rob

On Mon, May 6, 2019 at 9:51 AM kevinxie4c notifications@github.com wrote:

I don't have a chance to try that because I don't have the root privilege to install newer version. But maybe I can build GCC from source... Here is my perl -V output:

Summary of my perl5 (revision 5 version 22 subversion 2) configuration:

Platform: osname=linux, osvers=3.10.0-693.21.1.el7.x86_64, archname=x86_64-linux-thread-multi uname='linux localhost 3.10.0-693.21.1.el7.x86_64 #1 smp wed mar 7 19:03:37 utc 2018 x86_64 gnulinux ' config_args='-de -Dcc=cc -Uinstallusrbinperl -Dinstallstyle=lib/perl5 -Duseshrplib -Dlocincpth=/no-such-path/include -Dloclibpth=/cvmfs/soft.computecanada.ca/nix/store/63pk88rnmkzjblpxydvrmskkc8ci7cx6-glibc-2.24/lib -Dusethreads -Dprefix=/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2 -Dman1dir=/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/share/man/man1 -Dman3dir=/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/share/man/man3' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/no-such-path/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/no-such-path/include' ccversion='', gccversion='5.4.0', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector-strong -L/cvmfs/soft.computecanada.ca/nix/store/63pk88rnmkzjblpxydvrmskkc8ci7cx6-glibc-2.24/lib' libpth= libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.24' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/5.22.2/x86_64-linux-thread-multi/CORE' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/cvmfs/soft.computecanada.ca/nix/store/63pk88rnmkzjblpxydvrmskkc8ci7cx6-glibc-2.24/lib -fstack-protector-strong'

Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Built under linux Compiled at Apr 29 2016 20:14:57 %ENV: PERL5LIB="/home/kevinxie/perl5/lib/perl5:/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5:/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl" PERL5OPT="-I/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5 -I/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl" PERLBREW_HOME="/home/kevinxie/.perlbrew" PERLBREW_ROOT="/home/kevinxie/perl5/perlbrew" PERLBREW_SHELLRC_VERSION="0.84" PERL_LOCAL_LIB_ROOT="/home/kevinxie/perl5" PERL_MB_OPT="--install_base "/home/kevinxie/perl5"" PERL_MM_OPT="INSTALL_BASE=/home/kevinxie/perl5" @INC: /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl/5.22.2/x86_64-linux-thread-multi /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl/5.22.2 /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/5.22.2/x86_64-linux-thread-multi /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/5.22.2 /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5 /home/kevinxie/perl5/lib/perl5/5.22.2/x86_64-linux-thread-multi /home/kevinxie/perl5/lib/perl5/5.22.2 /home/kevinxie/perl5/lib/perl5/x86_64-linux-thread-multi /home/kevinxie/perl5/lib/perl5 /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/5.22.2/x86_64-linux-thread-multi /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/5.22.2 /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5 /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl/5.22.2/x86_64-linux-thread-multi /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl/5.22.2 /cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/lib/perl5/site_perl /cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/site_perl/5.22.2/x86_64-linux-thread-multi /cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/site_perl/5.22.2 /cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/5.22.2/x86_64-linux-thread-multi /cvmfs/soft.computecanada.ca/nix/store/irw3ff3794iw77z72n7z0cdmzcy795fk-perl-5.22.2/lib/perl5/5.22.2

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ingydotnet/inline-c-pm/issues/91#issuecomment-489474246, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAR3PFZFNGRMACHDZUXL4LPT5XILANCNFSM4HK4JD2Q .

mohawk2 commented 5 years ago

@sisyphus Excellent spot! Not obvious to me at all. I wonder if there's a buggy shell script that's interpreting the -iquote argument?

mohawk2 commented 5 years ago

Or, I wonder if, given iquote isn't a single letter, there's some arg-parsing thing that goes wrong? Either way, I would predict that if we switch to -iquote "$arg" (with a space first), that would improve it.

@kevinxie4c Do you feel like finding the place where iquote is added, and changing it as above?

kevinxie4c commented 5 years ago

@mohawk2 Adding a space gave me the same error. But I think you are right. Maybe the wrong arg-parsing caused this error.

sisyphus commented 5 years ago

Along the same lines of thought I wonder how "-iquote $arg" and "-iquote$arg" would fare. That is, move the opening double-quote so that it immediately precedes the -iquote.

I would have expected, however, that if the original argument was being parsed incorrectly there would also have been an "unrecognized command line option" error.

Cheers, Rob

On Mon, May 6, 2019 at 3:03 PM kevinxie4c notifications@github.com wrote:

@mohawk2 https://github.com/mohawk2 Adding a space gave me the same error. But I think you are right. Maybe the wrong arg-parsing caused this error.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ingydotnet/inline-c-pm/issues/91#issuecomment-489501422, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAR3PEHFEVZ7FLBMSYDJ4DPT63ZBANCNFSM4HK4JD2Q .

kevinxie4c commented 5 years ago

@sisyphus Thanks for your thought. Is there a bug in GCC?

sisyphus commented 5 years ago

I don't know of any bug in gcc that would cause this problem.

Assuming that (as is the case for me) neither the "./not here" directory nor the missing.c file exist, what do you get when you run the command:

gcc -c -iquote"./not here" missing.c

I get:

$ gcc -c -iquote"./not here" missing.c gcc: error: missing.c: No such file or directory gcc: fatal error: no input files

That looks to be correct behaviour to me, but I'm thinking you might get the following, which contains an additional error message:

gcc: error: here: No such file or directory gcc: error: missing.c: No such file or directory gcc: fatal error: no input files

If that's what you get, then I think there's a bug in your shell or in your C toolset.

But if you get the same as I got, then I think the bug is in Inline::C or in perl itself.

As a double check, could you also verify that your output remains unchanged when you run each of the following commands:

gcc -c -iquote "./not here" missing.c cc -c -iquote "./not here" missing.c cc -c -iquote"./not here" missing.c

Cheers, Rob

On Mon, May 6, 2019 at 3:38 PM kevinxie4c notifications@github.com wrote:

@sisyphus https://github.com/sisyphus Thanks for your thought. Is there a bug in GCC?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ingydotnet/inline-c-pm/issues/91#issuecomment-489505442, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAR3PH2C3T3Z5JRW3BESBTPT676HANCNFSM4HK4JD2Q .

mohawk2 commented 5 years ago

Does gcc check its -I / -iquote args for existence? What if you do it with a non-missing C file?

kevinxie4c commented 5 years ago

It turns out that my cc is a bash script:

#!/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/bin/sh
exec gcc ${1+$@}

So cc -c iquote "./not here" missing.c becomes:

exec gcc -c iquote./not here missing.c

I am not an expert in bash script, but I think this causes the error. Thanks a lot!

perlpunk commented 5 years ago

@kevinxie4c hah, shell quoting! :)

This should work:

exec gcc "${1+$@}"
mohawk2 commented 5 years ago

I'm claiming that one with:

I wonder if there's a buggy shell script that's interpreting the -iquote argument?

But @perlpunk's is the correct solution. @kevinxie4c I suggest you:

kevinxie4c commented 5 years ago

Sure. Thank you all!