threads.xs: "implicit declaration of function '_setjmpex'" using MinGW-w64
Description
I'am building Perl 5.37.2 on Windows 8.1 64 bit using MinGW-w64 (gcc (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 10.3.0). I am using gcc, which can be found at https://winlibs.com/ .
One of the build warnings is:
Generating a gmake-style Makefile
Writing Makefile for threads
gmake[1]: Entering directory 'C:/Perl64-gcc10/perl-5.37.2/dist/threads'
Running Mkbootstrap for threads ()
"C:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 644 "threads.bs"
"C:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_nonempty -- threads.bs ..\..\lib\auto\threads\threads.bs 644
"C:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" "C:\Perl64-gcc10\perl-5.37.2\dist\ExtUtils-ParseXS\lib\ExtUtils/xsubpp" -typemap C:\Perl64-gcc10\perl-5.37.2\lib\ExtUtils\typemap threads.xs > threads.xsc
"C:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- threads.xsc threads.c
gcc -c -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2 -DVERSION=\"2.28\" -DXS_VERSION=\"2.28\" "-I..\..\lib\CORE" threads.c
threads.xs: In function 'S_jmpenv_run':
threads.xs:18:23: warning: implicit declaration of function '_setjmpex'; did you mean '_setjmp3'? [-Wimplicit-function-declaration]
18 | # define setjmp(x) _setjmpex((x), mingw_getsp())
| ^~~~~~~~~
threads.xs:18:23: note: in definition of macro 'setjmp'
18 | # define setjmp(x) _setjmpex((x), mingw_getsp())
| ^~~~~~~~~
..\..\lib\CORE/iperlsys.h:1083:33: note: in expansion of macro 'Sigsetjmp'
1083 | # define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
| ^~~~~~~~~
..\..\lib\CORE/cop.h:122:26: note: in expansion of macro 'PerlProc_setjmp'
122 | cur_env.je_ret = PerlProc_setjmp(cur_env.je_buf, SCOPE_SAVES_SIGNAL_MASK); \
| ^~~~~~~~~~~~~~~
threads.xs:504:5: note: in expansion of macro 'JMPENV_PUSH'
504 | JMPENV_PUSH(jmp_rc);
| ^~~~~~~~~~~
"C:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
-e "Mksymlists('NAME'=>\"threads\", 'DLBASE' => 'threads', 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);"
g++ threads.def -o ..\..\lib\auto\threads\threads.dll -shared -s -L"c:\perl\lib\CORE" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\x86_64-w64-mingw32\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\lib\gcc\x86_64-w64-mingw32\10.3.0" threads.o "..\..\lib\CORE\libperl537.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:\Perl64-gcc10\perl-5.37.2\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 755 ..\..\lib\auto\threads\threads.dll
I can confirm that the above warning is also output in gcc-8.5.0, gcc-11.3.0 and gcc-12.1.0.
Steps to Reproduce
Download perl-5.37.2.tar.gz from metacpan. Extract from perl-5.37.2.tar.gz to C:\Perl64-gcc10.
On command promput: (Note: I use mingw32-make.exe as gmake.exe)
set PATH=C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0
set CCHOME=C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64
cd C:\Perl64-gcc10\perl-5.37.2\win32
gmake
Expected behavior
It is the suppression of warnings.
Perl configuration
C:\Perl64-gcc10\perl-5.37.2\win32>C:\Perl64-gcc10\perl-5.37.2\perl.exe -V
Summary of my perl5 (revision 5 version 37 subversion 2) configuration:
Platform:
osname=MSWin32
osvers=6.3.9600
archname=MSWin32-x64-multi-thread
uname=''
config_args='undef'
hint=recommended
useposix=true
d_sigaction=undef
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='gcc'
ccflags =' -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields'
optimize='-O2'
cppflags='-DWIN32'
ccversion=''
gccversion='10.3.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='long long'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='g++'
ldflags ='-s -L"c:\perl\lib\CORE" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\x86_64-w64-mingw32\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\lib\gcc\x86_64-w64-mingw32\10.3.0"'
libpth=C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\lib C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\x86_64-w64-mingw32\lib C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\lib\gcc\x86_64-w64-mingw32\10.3.0
libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
libc=
so=dll
useshrplib=true
libperl=libperl537.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs
dlext=dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags='-shared -s -L"c:\perl\lib\CORE" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\x86_64-w64-mingw32\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-10.3.0-llvm-12.0.0-mingw-w64-9.0.0-r2\mingw64\lib\gcc\x86_64-w64-mingw32\10.3.0"'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_TIMES
HAVE_INTERP_INTERN
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_SAFE_PUTENV
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
Built under MSWin32
Compiled at Aug 14 2022 18:00:48
@INC:
C:/Perl64-gcc10/perl-5.37.2/lib
C:\Perl64-gcc10\perl-5.37.2\win32>
This patch silences the warnings for me:
+++ threads.xs 2022-08-17 14:00:33 +1000
@@ -15,6 +15,7 @@
# define setjmp(x) _setjmp(x)
# endif
# if defined(__MINGW64__)
+# include <intrin.h>
# define setjmp(x) _setjmpex((x), mingw_getsp())
# endif
#endif
I think it's correct - but I haven't yet tested it as thoroughly as I would like. (Maybe later today.)
It's rather annoying that this dual-life module is at version 2.28 in the perl source, but if you want to get a standalone source of it, there's nothing later than version 2.21 on CPAN. I wonder if it should be moved from 'dist' to 'ext' in the perl source ?
Cheers, Rob
Thanks for the patch suggestion.
By the way, I will close this ticket once and open the same at "https://github.com/Dual-Life/threads/issues". I would be happy to communicate with you there.
Thank you,
No - I think I gave you misinformation and that it's better to discuss it here. I'm not sure. I'm seeking clarification from p5p - see https://www.nntp.perl.org/group/perl.perl5.porters/2022/08/msg264633.html. (No replies yet at time of writing).
Cheers, Rob
I wonder if it should be moved from 'dist' to 'ext' in the perl source ?
No, someone should just release this module to CPAN (the previous maintainer has resigned). I'm likely to do that for threads::shared as soon as I've fixed one more issue, I might also do threads.
Ok - thanks @Leont .
@twata1, I think the next thing to do is to create a new pull request for this at https://github.com/Perl/perl5/issues . If you would like to do that, then please proceed. Otherwise, I'm happy to do it.
Cheers, Rob
@sisyphus Thank you for your suggestion. It may take some time but I will give it a try.
@twata1, I think the next thing to do is to create a new pull request for this at https://github.com/Perl/perl5/issues . If you would like to do that, then please proceed.
I will now test using gcc-8.5.0, gcc-11.3.0 and gcc-12.1.0 to see if that warning in Perl 5.37.2 threads 2.28 is suppressed.
I am also considering the attached regarding the pull request text. PR-perl-threads-2.28.txt
If you could point out if I am going in any wrong direction, I would greatly appreciate it.
I could certainly confirm that the warning is suppressed.
Relavant part of the log for gmake with gcc-12.1.0
Generating a gmake-style Makefile
Writing Makefile for threads
gmake[1]: Entering directory 'C:/Perl64-gcc12/perl-5.37.2-threads-2.28-gh-20096/dist/threads'
Running Mkbootstrap for threads ()
"C:\Perl64-gcc12\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 644 "threads.bs"
"C:\Perl64-gcc12\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_nonempty -- threads.bs ..\..\lib\auto\threads\threads.bs 644
"C:\Perl64-gcc12\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" "C:\Perl64-gcc12\perl-5.37.2-threads-2.28-gh-20096\dist\ExtUtils-ParseXS\lib\ExtUtils/xsubpp" -typemap C:\Perl64-gcc12\perl-5.37.2-threads-2.28-gh-20096\lib\ExtUtils\typemap threads.xs > threads.xsc
"C:\Perl64-gcc12\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- threads.xsc threads.c
gcc -c -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2 -DVERSION=\"2.28\" -DXS_VERSION=\"2.28\" "-I..\..\lib\CORE" threads.c
"C:\Perl64-gcc12\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
-e "Mksymlists('NAME'=>\"threads\", 'DLBASE' => 'threads', 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);"
g++ threads.def -o ..\..\lib\auto\threads\threads.dll -shared -s -L"c:\perl\lib\CORE" -L"C:\winlibs-x86_64-posix-seh-gcc-12.1.0-llvm-14.0.6-mingw-w64msvcrt-10.0.0-r3\mingw64\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-12.1.0-llvm-14.0.6-mingw-w64msvcrt-10.0.0-r3\mingw64\x86_64-w64-mingw32\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-12.1.0-llvm-14.0.6-mingw-w64msvcrt-10.0.0-r3\mingw64\lib\gcc\x86_64-w64-mingw32\12.1.0" threads.o "..\..\lib\CORE\libperl537.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:\Perl64-gcc12\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 755 ..\..\lib\auto\threads\threads.dll
gmake[1]: Leaving directory 'C:/Perl64-gcc12/perl-5.37.2-threads-2.28-gh-20096/dist/threads'
Relavant part of the log for gmake with gcc-11.3.0
Generating a gmake-style Makefile
Writing Makefile for threads
gmake[1]: Entering directory 'C:/Perl64-gcc11/perl-5.37.2-threads-2.28-gh-20096/dist/threads'
Running Mkbootstrap for threads ()
"C:\Perl64-gcc11\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 644 "threads.bs"
"C:\Perl64-gcc11\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_nonempty -- threads.bs ..\..\lib\auto\threads\threads.bs 644
"C:\Perl64-gcc11\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" "C:\Perl64-gcc11\perl-5.37.2-threads-2.28-gh-20096\dist\ExtUtils-ParseXS\lib\ExtUtils/xsubpp" -typemap C:\Perl64-gcc11\perl-5.37.2-threads-2.28-gh-20096\lib\ExtUtils\typemap threads.xs > threads.xsc
"C:\Perl64-gcc11\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- threads.xsc threads.c
gcc -c -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2 -DVERSION=\"2.28\" -DXS_VERSION=\"2.28\" "-I..\..\lib\CORE" threads.c
"C:\Perl64-gcc11\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
-e "Mksymlists('NAME'=>\"threads\", 'DLBASE' => 'threads', 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);"
g++ threads.def -o ..\..\lib\auto\threads\threads.dll -shared -s -L"c:\perl\lib\CORE" -L"C:\winlibs-x86_64-posix-seh-gcc-11.3.0-llvm-14.0.3-mingw-w64msvcrt-10.0.0-r3\mingw64\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-11.3.0-llvm-14.0.3-mingw-w64msvcrt-10.0.0-r3\mingw64\x86_64-w64-mingw32\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-11.3.0-llvm-14.0.3-mingw-w64msvcrt-10.0.0-r3\mingw64\lib\gcc\x86_64-w64-mingw32\11.3.0" threads.o "..\..\lib\CORE\libperl537.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:\Perl64-gcc11\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 755 ..\..\lib\auto\threads\threads.dll
gmake[1]: Leaving directory 'C:/Perl64-gcc11/perl-5.37.2-threads-2.28-gh-20096/dist/threads'
Relavant part of the log for gmake with gcc-8.5.0
Generating a gmake-style Makefile
Writing Makefile for threads
gmake[1]: Entering directory 'C:/Perl64-gcc8.5/perl-5.37.2-threads-2.28-gh-20096/dist/threads'
Running Mkbootstrap for threads ()
"C:\Perl64-gcc8.5\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 644 "threads.bs"
"C:\Perl64-gcc8.5\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command::MM -e cp_nonempty -- threads.bs ..\..\lib\auto\threads\threads.bs 644
"C:\Perl64-gcc8.5\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" "C:\Perl64-gcc8.5\perl-5.37.2-threads-2.28-gh-20096\dist\ExtUtils-ParseXS\lib\ExtUtils/xsubpp" -typemap C:\Perl64-gcc8.5\perl-5.37.2-threads-2.28-gh-20096\lib\ExtUtils\typemap threads.xs > threads.xsc
"C:\Perl64-gcc8.5\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e mv -- threads.xsc threads.c
gcc -c -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -O2 -DVERSION=\"2.28\" -DXS_VERSION=\"2.28\" "-I..\..\lib\CORE" threads.c
"C:\Perl64-gcc8.5\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
-e "Mksymlists('NAME'=>\"threads\", 'DLBASE' => 'threads', 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);"
g++ threads.def -o ..\..\lib\auto\threads\threads.dll -shared -s -L"c:\perl\lib\CORE" -L"C:\winlibs-x86_64-posix-seh-gcc-8.5.0-mingw-w64-9.0.0-r1\mingw64\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-8.5.0-mingw-w64-9.0.0-r1\mingw64\x86_64-w64-mingw32\lib" -L"C:\winlibs-x86_64-posix-seh-gcc-8.5.0-mingw-w64-9.0.0-r1\mingw64\lib\gcc\x86_64-w64-mingw32\8.5.0" threads.o "..\..\lib\CORE\libperl537.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:\Perl64-gcc8.5\perl-5.37.2-threads-2.28-gh-20096\miniperl.exe" "-I..\..\lib" -MExtUtils::Command -e chmod -- 755 ..\..\lib\auto\threads\threads.dll
Full log (copy command results translated into English): gmake-2022-08-12-with-gcc12.log gmake-2022-08-18-with-gcc11.log gmake-2022-08-18-with-gcc8.5.log
As a next step I will be making a pull request at https://github.com/Perl/perl5/pulls .
Hello, there! Cc: @thesamesam
I would like some advice. What is the appropriate verb to describe resolving this issue? ("fix" or "suppress" or other words (e.g. "quell") or Any of these?)
Please also see comment https://github.com/Perl/perl5/pull/20116#issuecomment-1320680727.
Hi @twata1! I would say "fix", "solve", or maybe "appease" (but appease would be best only if you thought a warning was a bit silly/you're humouring it). To me, "suppress" suggests a false positive like we're quieting it.
Hi @thesamesam !
Thanks for the advice.
Certainly, I think this issue is not a false positive. I'm going to use the word "fix" which I often see here and there. This is the first time I've made a change within a pull request, so it might take a little longer by any chance.
Thank you,
Thank you! No problem at all! Let me know if you need any help.
Note: it is OK to force push to branches you used for a pull request.
I was having trouble with my github personal access token expiring. Now I have updated that pull request!