Dual-Life / Devel-PPPort

Perl/Pollution/Portability
9 stars 28 forks source link

Devel::PPPort 3.67 (and 3.65?) breaks Compiler-Lexer-0.23 #222

Closed eserte closed 2 years ago

eserte commented 2 years ago

For some perl versions (< 5.30.0?) the compilation of Compiler-Lexer-0.23 started to fail like this:

...
cc -Isrc -I/opt/perl-5.28.2/lib/5.28.2/x86_64-linux/CORE -DVERSION="0.23" -DXS_VERSION="0.23" -fPIC -Iinclude -Wno-missing-field-initializers -g3 -xc++ -D_FILE_OFFSET_BITS=64 -c -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -o lib/Compiler/Lexer.o lib/Compiler/Lexer.c
In file included from lib/Compiler/Lexer.xs:10:
include/ppport.h: In function ‘SV* D_PPP_newSVsv_flags(SV*, I32)’:
include/ppport.h:16004:17: error: expected unqualified-id before ‘new’
16004 |             SV *new = newSV(0);
      |                 ^~~
In file included from /opt/perl-5.28.2/lib/5.28.2/x86_64-linux/CORE/perl.h:5310,
                 from lib/Compiler/Lexer.xs:7:
/opt/perl-5.28.2/lib/5.28.2/x86_64-linux/CORE/embed.h:834:60: error: expected type-specifier before ‘,’ token
  834 | #define sv_setsv_flags(a,b,c)   Perl_sv_setsv_flags(aTHX_ a,b,c)
      |                                                            ^
include/ppport.h:16005:13: note: in expansion of macro ‘sv_setsv_flags’
16005 |             sv_setsv_flags(new, old, flags);
      |             ^~~~~~~~~~~~~~
In file included from lib/Compiler/Lexer.xs:10:
include/ppport.h:16006:23: error: expected type-specifier before ‘;’ token
16006 |             return new;
      |                       ^
error building lib/Compiler/Lexer.o from 'lib/Compiler/Lexer.c' at /opt/perl-5.28.2/lib/site_perl/5.28.2/ExtUtils/CBuilder/Base.pm line 186.

Just a guess: maybe the variable shouldn't be named new as this possibly clashes with a C++ keyword?

khwilliamson commented 2 years ago

On 3/12/22 00:03, Slaven Rezić wrote:

Just a guess: maybe the variable shouldn't be named |new| as this possibly clashes with a C++ keyword?

That sounds fairly likely. Is it easy for you to try your hypothesis out?

In any event, 'new' was a poor choice of variable name and should be changed, but it would be nice to know if that is what is causing this problem before we release a new version

eserte commented 2 years ago

Tried the following diff:

diff --git i/PPPort.pm w/PPPort.pm
index a5fb62b..b1feae6 100644
--- i/PPPort.pm
+++ w/PPPort.pm
@@ -20008,17 +20008,17 @@ DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...)
 #  if defined(PERL_USE_GCC_BRACE_GROUPS)
 #    define  newSVsv_flags(sv, flags)                       \
         ({                                                  \
-            SV *new = newSV(0);                             \
-            sv_setsv_flags(new, (sv), (flags));             \
-            new;                                            \
+            SV *n = newSV(0);                               \
+            sv_setsv_flags(n, (sv), (flags));               \
+            n;                                              \
         })
 #  else
     PERL_STATIC_INLINE SV* D_PPP_newSVsv_flags(SV *const old, I32 flags)
         {
             dTHX;
-            SV *new = newSV(0);
-            sv_setsv_flags(new, old, flags);
-            return new;
+            SV *n = newSV(0);
+            sv_setsv_flags(n, old, flags);
+            return n;
         }
 #    define  newSVsv_flags(sv, flags) D_PPP_newSVsv_flags(sv, flags)
 #  endif

Compiler-Lexer compilation was then successful with perl 5.28.0.