develooper Front page | perl.perl5.porters | Postings from March 2018

[perl #132955] USE_CPLUSPLUS build broken in 5.27 blead and all 5.26stables

Thread Previous | Thread Next
From:
bulk88
Date:
March 8, 2018 15:57
Subject:
[perl #132955] USE_CPLUSPLUS build broken in 5.27 blead and all 5.26stables
Message ID:
rt-4.0.24-30499-1520524631-819.132955-75-0@perl.org
# New Ticket Created by  bulk88 
# Please include the string:  [perl #132955]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=132955 >


This is a bug report for perl from bulk88@hotmail.com,
generated with the help of perlbug 1.41 running under perl 5.27.9.


-----------------------------------------------------------------
[Please describe your issue here]

5.26 (maint-5.26) and 5.27 blead both fail with Win32 VC perl compiled 
with USE_CPLUSPLUS=define build option. Solution need backporting to 5.26.

--------------------------------------
cl -c           -nologo -GF -W3 -TP -EHsc -O1 -MD -Zi -DNDEBUG -GL 
-DWIN32 -D_CO
NSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT 
-DPERL_IMPLICI
T_SYS -DWIN32_NO_REGISTRY -D_USE_32BIT_TIME_T -O1 -MD -Zi -DNDEBUG -GL 
   -DVERS
ION=\"1.76\"    -DXS_VERSION=\"1.76\"  "-I..\..\lib\CORE"   POSIX.c
POSIX.c
"..\..\miniperl.exe" "-I..\..\lib" -MExtUtils::Mksymlists \
      -e "Mksymlists('NAME'=>\"POSIX\", 'DLBASE' => 'POSIX', 'DL_FUNCS' 
=> {  },
'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
link -out:..\..\lib\auto\POSIX\POSIX.dll -dll -nologo -nodefaultlib 
-debug -opt:
ref,icf -ltcg           -libpath:"c:\perl\lib\CORE" 
-machine:x86 POS
IX.obj   "..\..\lib\CORE\perl526.lib" oldnames.lib kernel32.lib 
user32.lib gdi32
.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib n
etapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib 
odbccp3
2.lib comctl32.lib msvcrt.lib -def:POSIX.def
    Creating library ..\..\lib\auto\POSIX\POSIX.lib and object 
..\..\lib\auto\POS
IX\POSIX.exp
POSIX.obj : error LNK2001: unresolved external symbol _PL_nan
..\..\lib\auto\POSIX\POSIX.dll : fatal error LNK1120: 1 unresolved externals
dmake:  Error code 224, while making '..\..\lib\auto\POSIX\POSIX.dll'
---------------------------------------------

I traced the failure to 
https://perl5.git.perl.org/perl.git/commitdiff/0879cd66ef3f00918ae26d9bb7ac555d3911c548 


plain C (works) vs C++ (broken) POSIX.i diff
---------------------------------------------
--- C:\perl521\src\ext\POSIX\POSIX.c.i
+++ C:\perl521\src\ext\POSIX\POSIX.p.i
@@ -250844,8 +250844,8 @@



-extern __declspec(dllimport) const union { NV nv; U8 u8[8]; } PL_inf;
-extern __declspec(dllimport) const union { NV nv; U8 u8[8]; } PL_nan;
+extern "C" const union { NV nv; U8 u8[8]; } PL_inf;
+extern "C" const union { NV nv; U8 u8[8]; } PL_nan;

  #line 6766 "..\\..\\lib\\CORE\\perl.h"

---------------------------------------------
orig code
---------------------------------------------
5720 /* In C99 we could use designated (named field) union initializers.
5721  * In C89 we need to initialize the member declared first.
5722  * In C++ we need extern C initializers.
5723  *
5724  * With the U8_NV version you will want to have inner braces,
5725  * while with the NV_U8 use just the NV. */
5726
5727 #ifdef __cplusplus
5728 #define INFNAN_U8_NV_DECL EXTERN_C const union { U8 u8[NVSIZE]; NV 
nv; }
5729 #define INFNAN_NV_U8_DECL EXTERN_C const union { NV nv; U8 
u8[NVSIZE]; }
5730 #else
5731 #define INFNAN_U8_NV_DECL EXTCONST union { U8 u8[NVSIZE]; NV nv; }
5732 #define INFNAN_NV_U8_DECL EXTCONST union { NV nv; U8 u8[NVSIZE]; }
5733 #endif
-------------------------------------------

So the var isn't declared as crossing DLL boundaries. So it doesnt, and 
therefore the Windows POSIX.xs wont link. EXTERN_C vs EXTCONST.

https://perl5.git.perl.org/perl.git/commitdiff/0879cd66ef3f00918ae26d9bb7ac555d3911c548 
that commit didnt explain why exactly by its author the exact linker 
problem in the first place he was having or what the error coming out of 
the CC/LD was. Reverting that commit fixes the Win32 C++ perl build.

The 5.26 Win32 binary (perl526.dll) DOES export PL_nan and PL_inf 
symbols. It is a header problem.

A 2nd less correct way of fixing it, is eliminating the use of global 
PL_nan on Win32 and using platform specific constant I put in win32.h a 
long time ago.

---------------------------------
extern const __declspec(selectany) union { unsigned __int64 __q; double 
__d; }
__PL_nan_u = { 0x7FF8000000000000UI64 };
#define NV_NAN ((NV)__PL_nan_u.__d)
---------------------------------

A secondary reason why POSIX.xs fails is this macro

https://perl5.git.perl.org/perl.git/blob/ecad93809368755639b71856840a4d6e6d599ade:/perl.h#l6960

6960 #define NV_NAN_QS_QUIET \
6961     ((NV_NAN_QS_BYTE(PL_nan.u8) & NV_NAN_QS_BIT) == NV_NAN_QS_BIT)

which uses PL_nan directly without the "platform specific" NV_NAN 
constant/maybe-not-a-constant identifier. But NV_NAN_QS_QUIET is from 
5.23.0, much older than 5.26. It was the declaration of PL_nan that 
broke things in 5.26, not the accidental use of the not platform 
specific NAN PL_nan.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
          category=core
          severity=low
---
Site configuration information for perl 5.27.9:

Configured by Administrator at Tue Jan 30 20:34:30 2018.

Summary of my perl5 (revision 5 version 27 subversion 9) configuration:

        Platform:
          osname=MSWin32
          osvers=5.2.3790
          archname=MSWin32-x86-multi-thread
          uname=''
          config_args='undef'
          hint=recommended
          useposix=true
          d_sigaction=undef
          useithreads=define
          usemultiplicity=define
          use64bitint=undef
          use64bitall=undef
          uselongdouble=undef
          usemymalloc=n
          default_inc_excludes_dot=define
          bincompat5005=undef
        Compiler:
          cc='cl'
          ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -DWIN32
-D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE  -DPERL_TEXTMODE_SCRIPTS
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DWIN32_NO_REGISTRY'
          optimize='-O1 -MD -Zi -DNDEBUG -GL'
          cppflags='-DWIN32'
          ccversion='15.00.30729.01'
          gccversion=''
          gccosandvers=''
          intsize=4
          longsize=4
          ptrsize=4
          doublesize=8
          byteorder=1234
          doublekind=3
          d_longlong=undef
          longlongsize=8
          d_longdbl=define
          longdblsize=8
          longdblkind=0
          ivtype='long'
          ivsize=4
          nvtype='double'
          nvsize=8
          Off_t='__int64'
          lseeksize=8
          alignbytes=8
          prototype=define
        Linker and Libraries:
          ld='link'
          ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -ltcg
-libpath:"c:\perl\lib\CORE"        -machine:x86'
          libpth="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib"
          libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
          perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
          libc=msvcrt.lib
          so=dll
          useshrplib=true
          libperl=perl527.lib
          gnulibc_version=''
        Dynamic Linking:
          dlsrc=dl_win32.xs
          dlext=dll
          d_dlsymun=undef
          ccdlflags=' '
          cccdlflags=' '
          lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -ltcg
          -libpath:"c:\perl\lib\CORE"        -machine:x86'


---
@INC for perl 5.27.9:
          lib
          C:/p527/srcnew/lib

---
Environment for perl 5.27.9:
          CYGWIN=tty
          HOME (unset)
          LANG (unset)
          LANGUAGE (unset)
          LD_LIBRARY_PATH=/usr/lib/x86:/usr/X11R6/lib
          LOGDIR (unset)
          PATH=C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft Visual
Studio 9.0\VC\BIN;C:\Program Files\Microsoft
SDKs\Windows\v6.0A\bin;C:\Perl\bin;C:\WINDOWS;C:\Program Files
(x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files
(x86)\Git\bin;C:\sp3220\c\bin;
          PERL_BADLANG (unset)
          SHELL (unset)


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About