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

Re: [perl #132955] USE_CPLUSPLUS build broken in 5.27 blead and all5.26 stables

Thread Previous | Thread Next
From:
Steve Hay via perl5-porters
Date:
April 27, 2018 17:28
Subject:
Re: [perl #132955] USE_CPLUSPLUS build broken in 5.27 blead and all5.26 stables
Message ID:
CADED=K4Xjz6WjNXHm92eULhRxkTJZH8UmBFvsXjApwHwaocRrg@mail.gmail.com
On 27 April 2018 at 14:56, Leon Timmermans <fawaka@gmail.com> wrote:
> On Tue, Apr 24, 2018 at 6:23 PM, Steve Hay <steve.m.hay@googlemail.com> wrote:
>> On 24 April 2018 at 15:49, Dave Mitchell <davem@iabyn.com> wrote:
>>> On Tue, Apr 24, 2018 at 02:56:00PM +0200, Leon Timmermans wrote:
>>>
>>>> I would guess that making them EXTCONST again, but putting them inside
>>>> a START_EXTERN_C/END_EXTERN_C block would fix this.
>>>
>>> That seems to work under linux.
>>> This branch I've just pushed, smoke-me/davem/nan_cpp,
>>> builds ok with gcc, g++ and clang on Linux.
>>>
>>> Does someone want to try it on Windows?
>>>
>>
>> That fixes the problem for me.
>>
>> But I spoke to soon in claiming that the build otherwise worked with
>> VS2017. There is still one more problem:
>>
>> Socket.xs(804): error C2132: syntax error: unexpected identifier
>> Socket.xs(808): error C2132: syntax error: unexpected identifier
>>
>> I don't understand this one either. Line 804 is:
>>
>> if (sockaddr_len < STRUCT_OFFSET(struct sockaddr, sa_data))
>>
>> which pre-processes to:
>>
>> if (sockaddr_len < __builtin_offsetof(struct sockaddr,sa_data))
>>
>> Similar pre-processing happens in many other files and they compile
>> without trouble, e.g. in B.xs we have:
>>
>> { STR_WITH_LEN("next"),    OPp,    STRUCT_OFFSET(struct op, op_next),     },
>>
>> which becomes:
>>
>> { ("" "next" ""), (sizeof("next")-1),    0x3,
>> __builtin_offsetof(struct op,op_next),     },
>>
>> and causes no problem.
>>
>> I can't see why Socket is any different. However, It does contain this:
>>
>> /* STRUCT_OFFSET should have come from from perl.h, but if not,
>>  * roll our own (not using offsetof() since that is C99). */
>> #ifndef STRUCT_OFFSET
>> #  define STRUCT_OFFSET(s,m)  (Size_t)(&(((s *)0)->m))
>> #endif
>>
>> and if I insert "#undef STRUCT_OFFSET" before that (to get rid of the
>> definition from perl.h and use the above instead) then it fixes it.
>> That can't be the right solution, though.
>>
>> *That* really is the last problem. With that hack in place the build
>> now succeeds.
>
> Which version of VC++ is that? The visual studio forum seems to
> suggest there have been some issues in VS2017 but that they're
> resolved in the later releases. Does upgrading to the latest help?
>
> Leon

That was VS2017 v15.4.2, cl.exe version 19.11.25547.

I've now upgraded to VS2017 v15.6.7, cl.exe version 19.11.26132 and
the errors are now more verbose :-)

Socket.xs(804): error C2132: syntax error: unexpected identifier
Socket.xs(804): note: offsetof has a builtin meaning; use
/Zc:offsetof- to revert to old, non-conforming definition
Socket.xs(808): error C2132: syntax error: unexpected identifier
Socket.xs(808): note: offsetof has a builtin meaning; use
/Zc:offsetof- to revert to old, non-conforming definition

So now I see there is an obvious solution that I could employ (add
/Zc:offsetof- to the compiler flags for this & later compilers), but
I'm still puzzled exactly what the problem is and why it only affects
Socket when there are so many other uses of STRUCT_OFFSET around the
code.

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