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

perl 5.36 cpan | Inline:C failures with 20230420 dev release when path is not C:\strawberry #95

Closed
shawnlaffan opened this issue Apr 22, 2023 · 14 comments

Comments

@shawnlaffan
Copy link
Contributor

shawnlaffan commented Apr 22, 2023

Inline::C is failing some tests. These seem not to occur when the distribution it is under c:\strawberry. (Edit - on my system but not others, see #39 (comment) )

The installation call is cpanm -v Inline::C.

@sisyphus - fyi

t/31include_dirs_angle_brackets.t .. Uncaught exception from user code:
        gmake[1]: Entering directory 'C:/user/git/STRAWB~1/SP536_~1/data/.cpanm/work/1682132243.19840/Inline-C-0.82/_Inline_31include_dirs_angle_brackets.2200/build/_31include_dirs_angle_brackets_t_8984'
        Running Mkbootstrap for _31include_dirs_angle_brackets_t_8984 ()
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "_31include_dirs_angle_brackets_t_8984.bs"
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- _31include_dirs_angle_brackets_t_8984.bs blib\arch\auto\_31include_dirs_angle_brackets_t_8984\_31include_dirs_angle_brackets_t_8984.bs 644
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" "C:\user\git\strawberry\sp536_202320a\perl\lib\ExtUtils/xsubpp"  -typemap "C:\user\git\strawberry\sp536_202320a\perl\lib\ExtUtils\typemap" -typemap "C:\user\git\STRAWB~1\SP536_~1\data\.cpanm\work\1682132243.19840\Inline-C-0.82\t\typemap"   _31include_dirs_angle_brackets_t_8984.xs > _31include_dirs_angle_brackets_t_8984.xsc
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" -MExtUtils::Command -e mv -- _31include_dirs_angle_brackets_t_8984.xsc _31include_dirs_angle_brackets_t_8984.c
        gcc -c  -iquote"C:/user/git/STRAWB~1/SP536_~1/data/.cpanm/work/1682132243.19840/Inline-C-0.82/t" -I"C:/user/git/STRAWB~1/SP536_~1/data/.cpanm/work/1682132243.19840/Inline-C-0.82/t/test_header" -DWIN32 -DWIN64 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -Os   -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\"  "-IC:\user\git\strawberry\sp536_202320a\perl\lib\CORE"   _31include_dirs_angle_brackets_t_8984.c
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" -MExtUtils::Mksymlists \
             -e "Mksymlists('NAME'=>\"_31include_dirs_angle_brackets_t_8984\", 'DLBASE' => '_31include_dirs_angle_brackets_t_8984', 'DL_FUNCS' => {  }, 'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
        g++.exe _31include_dirs_angle_brackets_t_8984.def -o blib\arch\auto\_31include_dirs_angle_brackets_t_8984\_31include_dirs_angle_brackets_t_8984.xs.dll -mdll -s -L"C:\user\git\strawberry\sp536_202320a\perl\lib\CORE" -L"C:\user\git\strawberry\sp536_202320a\c\lib" _31include_dirs_angle_brackets_t_8984.o   "C:\user\git\strawberry\sp536_202320a\perl\lib\CORE\libperl536.a" -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 -Wl,--enable-auto-image-base
        c:/user/git/strawberry/sp536_202320a/c/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file blib\arch\auto\_31include_dirs_angle_brackets_t_8984\_31include_dirs_angle_brackets_t_8984.xs.dll: No such file or directory
        collect2.exe: error: ld returned 1 exit status
        gmake[1]: *** [makefile:473: blib\arch\auto\_31include_dirs_angle_brackets_t_8984\_31include_dirs_angle_brackets_t_8984.xs.dll] Error 1
        gmake[1]: Leaving directory 'C:/user/git/STRAWB~1/SP536_~1/data/.cpanm/work/1682132243.19840/Inline-C-0.82/_Inline_31include_dirs_angle_brackets.2200/build/_31include_dirs_angle_brackets_t_8984'

        A problem was encountered while attempting to compile and install your Inline
        C code. The command that failed was:
          "gmake > out.make 2>&1" with error code 2

        The build directory was:
        C:\user\git\STRAWB~1\SP536_~1\data\.cpanm\work\1682132243.19840\Inline-C-0.82\_Inline_31include_dirs_angle_brackets.2200\build\_31include_dirs_angle_brackets_t_8984

        To debug the problem, cd to the build directory, and inspect the output files.

         at t/31include_dirs_angle_brackets.t line 18.
                ...propagated at C:\user\git\STRAWB~1\SP536_~1\data\.cpanm\work\1682132243.19840\Inline-C-0.82\blib\lib/Inline/C.pm line 888.
        BEGIN failed--compilation aborted at t/31include_dirs_angle_brackets.t line 18.
t/31include_dirs_angle_brackets.t .. Dubious, test returned 2 (wstat 512, 0x200)
Failed 1/1 subtests
t/32include_dirs_double_quotes.t ... Uncaught exception from user code:
        gmake[1]: Entering directory 'C:/user/git/STRAWB~1/SP536_~1/data/.cpanm/work/1682132243.19840/Inline-C-0.82/_Inline_32include_dirs_double_quotes.14568/build/_32include_dirs_double_quotes_t_058c'
        Running Mkbootstrap for _32include_dirs_double_quotes_t_058c ()
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "_32include_dirs_double_quotes_t_058c.bs"
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- _32include_dirs_double_quotes_t_058c.bs blib\arch\auto\_32include_dirs_double_quotes_t_058c\_32include_dirs_double_quotes_t_058c.bs 644
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" "C:\user\git\strawberry\sp536_202320a\perl\lib\ExtUtils/xsubpp"  -typemap "C:\user\git\strawberry\sp536_202320a\perl\lib\ExtUtils\typemap" -typemap "C:\user\git\STRAWB~1\SP536_~1\data\.cpanm\work\1682132243.19840\Inline-C-0.82\t\typemap"   _32include_dirs_double_quotes_t_058c.xs > _32include_dirs_double_quotes_t_058c.xsc
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" -MExtUtils::Command -e mv -- _32include_dirs_double_quotes_t_058c.xsc _32include_dirs_double_quotes_t_058c.c
        gcc -c  -iquote"C:/user/git/STRAWB~1/SP536_~1/data/.cpanm/work/1682132243.19840/Inline-C-0.82/t" -DWIN32 -DWIN64 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -Os   -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\"  "-IC:\user\git\strawberry\sp536_202320a\perl\lib\CORE"   _32include_dirs_double_quotes_t_058c.c
        "C:\user\git\strawberry\sp536_202320a\perl\bin\perl.exe" -MExtUtils::Mksymlists \
             -e "Mksymlists('NAME'=>\"_32include_dirs_double_quotes_t_058c\", 'DLBASE' => '_32include_dirs_double_quotes_t_058c', 'DL_FUNCS' => {  }, 'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
        g++.exe _32include_dirs_double_quotes_t_058c.def -o blib\arch\auto\_32include_dirs_double_quotes_t_058c\_32include_dirs_double_quotes_t_058c.xs.dll -mdll -s -L"C:\user\git\strawberry\sp536_202320a\perl\lib\CORE" -L"C:\user\git\strawberry\sp536_202320a\c\lib" _32include_dirs_double_quotes_t_058c.o   "C:\user\git\strawberry\sp536_202320a\perl\lib\CORE\libperl536.a" -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 -Wl,--enable-auto-image-base
        c:/user/git/strawberry/sp536_202320a/c/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file blib\arch\auto\_32include_dirs_double_quotes_t_058c\_32include_dirs_double_quotes_t_058c.xs.dll: No such file or directory
        collect2.exe: error: ld returned 1 exit status
        gmake[1]: *** [makefile:474: blib\arch\auto\_32include_dirs_double_quotes_t_058c\_32include_dirs_double_quotes_t_058c.xs.dll] Error 1
        gmake[1]: Leaving directory 'C:/user/git/STRAWB~1/SP536_~1/data/.cpanm/work/1682132243.19840/Inline-C-0.82/_Inline_32include_dirs_double_quotes.14568/build/_32include_dirs_double_quotes_t_058c'

        A problem was encountered while attempting to compile and install your Inline
        C code. The command that failed was:
          "gmake > out.make 2>&1" with error code 2

        The build directory was:
        C:\user\git\STRAWB~1\SP536_~1\data\.cpanm\work\1682132243.19840\Inline-C-0.82\_Inline_32include_dirs_double_quotes.14568\build\_32include_dirs_double_quotes_t_058c

        To debug the problem, cd to the build directory, and inspect the output files.

         at t/32include_dirs_double_quotes.t line 21.
                ...propagated at C:\user\git\STRAWB~1\SP536_~1\data\.cpanm\work\1682132243.19840\Inline-C-0.82\blib\lib/Inline/C.pm line 888.
        BEGIN failed--compilation aborted at t/32include_dirs_double_quotes.t line 21.
t/32include_dirs_double_quotes.t ... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
@sisyphus
Copy link

Weird ... if I, too, install into exactly the same place (C:\user\git\strawberry\sp536_202320a) , I get the very same error when I run cpanm -v Inline::C.

Yet, if I build Inline::C the ol' fashioned manual way then there's no issue.
Also, running cpan -i Inline::C works fine.

Seems that the issue doesn't appear if cpanm is not involved.

The reference to "ld.exe" in the failing case looks a bit suspicious to me. On gcc-built perls, $Config{ld} is set to "g++.exe".

I'll continue to poke at it as time permits.
@shawnlaffan I take it that you have verified that cpanm -v Inline::C works fine if perl is installed into C:\strawberry ?

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

Thanks @sisyphus

And yes, it does install cleanly via cpanm when perl is under c:\strawberry.

@shawnlaffan
Copy link
Contributor Author

shawnlaffan commented Apr 22, 2023

It could be a path length problem? The build installs under C:\user\sp536_20230420a but not C:\user\strawberry\sp536_20230420a.

What path does the cpan client use for its builds?

Edit - to answer my own question it is C:\Users\username\.cpan which is somewhat shorter than the failing builds.

@shawnlaffan
Copy link
Contributor Author

And FWIW, I get tar issues when trying the cpan shell. Not sure why it's looking for /usr/bin/tar but that probably also needs updating as part of the strawberry perl build.

cpan -i Inline::C
Loading internal logger. Log::Log4perl recommended for better logging
Reading '\c\Users\user\.cpan\Metadata'
  Database was generated on Sat, 22 Apr 2023 08:17:02 GMT
Running install for module 'Inline::C'
CPAN: Digest::SHA loaded ok (v6.04)
CPAN: Compress::Zlib loaded ok (v2.204)
Checksum for \c\Users\user\.cpan\sources\authors\id\E\ET\ETJ\Inline-C-0.82.tar.gz ok
The system cannot find the path specified.
Uncompressed \c\Users\user\.cpan\sources\authors\id\E\ET\ETJ\Inline-C-0.82.tar.gz successfully
Using Tar:/usr/bin/tar xf "Inline-C-0.82.tar":
The system cannot find the path specified.
Couldn't untar Inline-C-0.82.tar: child exited with value 1
CPAN: YAML loaded ok (v1.30)
  ETJ/Inline-C-0.82.tar.gz
  Had problems unarchiving. Please build manually

@shawnlaffan
Copy link
Contributor Author

This looks like it is an Inline::C issue. I've just replicated the failure using strawberry perl 5.28.2 under a deep path.

@xenu
Copy link

xenu commented Apr 22, 2023

Checksum for \c\Users\user.cpan\sources\authors\id\E\ET\ETJ\Inline-C-0.82.tar.gz ok

This is super odd. It looks like an MSYS path, but with slashes converted to backslashes.

Anyway, issues of this kind are usually caused by having MSYS or Cygwin in PATH and/or %USERPROFILE%\.cpan being polluted by them.

@sisyphus
Copy link

I don't think it's an Inline::C issue.
If that were the case then the "manual" build (perl Makefile.PL, gmake test, gmake install) would also be failing.
But that's working fine for me, irrespective of where SP is installed.

However, I think I'm going to struggle to understand what is going on unless I can coerce a "manual" build of Inline::C to throw the same "ld.exe" error.

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

It seems to be the location of the Inline::C build that's the issue.

I can replicate the failure with Strawberry Perl 5.28.2 when building from a manually downloaded and extracted Inline::C tarball in C:\user1\strawberry\level1\level2\level3\level4\a_long_name_inside_a_deep_path\Inline-C-0.82

@shawnlaffan
Copy link
Contributor Author

This is super odd. It looks like an MSYS path, but with slashes converted to backslashes.

Anyway, issues of this kind are usually caused by having MSYS or Cygwin in PATH and/or %USERPROFILE%\.cpan being polluted by them.

Thanks @xenu - I moved the %USERPROFILE%\.cpan dir out of the way and it all downloads and unpacks cleanly now.

The issue was probably a leftover from when I had MSYS2 in the path, quite some time ago. I almost always use cpanm which is why this had not surfaced before.

@sisyphus
Copy link

However, I think I'm going to struggle to understand what is going on unless I can coerce a "manual" build of Inline::C to throw the same "ld.exe" error.

That wasn't as difficult as I had thought it might be.
It's just a matter of running cpanm -v Inline::C in an SP that produces the error, then cd to the cpanm build directory and run:

gmake realclean
perl Makefile.PL
gmake test

And you'll get the same error.
I think it's probably a path-length problem (as @shawnlaffan previously suggested).
IIUC ld.exe is trying (and failing) to create something like:
D:\sp_64\perl-5.36.0-20230420\data.cpanm\work\1682209953.14052\Inline-C-0.82_Inline_31include_dirs_angle_brackets.4720\build_31include_dirs_angle_brackets_t_8984\blib\arch\auto_31include_dirs_angle_brackets_t_8984_31include_dirs_angle_brackets_t_8984.xs.dll

Renaming 31include_dirs_angle_brackets.t to 31.t seems to fix the problem.
Renaming 32_include_dirs_double_quotes.t to 32.t fixes the problem with it, too.

I guess Inline::C could partly be to blame because of the lengthy test script names that were chosen ?

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

Thanks Rob.

Shortening the test names is perhaps just delaying the problem as eventually someone will use a different long path that exceeds the limit.

Maybe the tests could check the path length of the .xs.dll file and warn that the test will probably fail if it exceeds 255 characters? Or maybe this needs to be in Inline::C where it generates the blib dirs?

That said, do the file names need to replicate the path to such a degree?

@sisyphus
Copy link

That said, do the file names need to replicate the path to such a degree?

Probably not, but that's the way it has always been done - the name of the file appended with the first 4 characters of the MD5 digest of the C code.
(At least, I think it's still done that way.)
I've used Inline::C fairly actively for many years, and can't recall this issue ever arising.
Of course, the cpanm build directory is buried pretty deep, so it should be no surprise that it's cpanm that has exposed this potential gotcha.

Cheers,
Rob

@shawnlaffan
Copy link
Contributor Author

Given this is not a Strawberry perl problem per se, and that I've opened ingydotnet/inline-c-pm#103, I will close this issue now.

@zmughal
Copy link

zmughal commented May 1, 2023

This is why I set set PERL_CPANM_HOME to a temporary directory as in here https://github.com/orbital-transfer-example/perl-gtk3-starter-basic/blob/v0.0.1/maint/helper.pl#L266-L271. I've similarly hit this problem before when dealing with Aliens that have long paths inside of their archives PerlAlien/Alien-Build#13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants