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

XS compiler generates C #line comments for INCLUDE_COMMAND that Visual Studio compiler does not understand #15540

Open
p5pRT opened this issue Aug 21, 2016 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 21, 2016

Migrated from rt.perl.org#129035 (status was 'open')

Searchable as RT129035$

@p5pRT
Copy link
Author

p5pRT commented Aug 21, 2016

From bubnikv@gmail.com

Hello.

I am trying to set up a development perl environment compiled from scratch
with Visual Studio 2013 free C/C++ compiler. I stumbled over a following
problem​:

If the XS file contains an INCLUDE_COMMAND call, this line is later stored
as a comment into the generated XS.c file in a form of #line NUMBER
"filepath". Here the "filepath" will be the complete parameter of
INCLUDE_COMMAND. If the parameter contains escaped quotes, this breaks the
__FILE__ substitution in the visual studio C++ compiler.

Here is an example of a #line inserted into XS.c, which the Visual Studio
C++ has a problem with​:

#line 112 "c​:\\\\wperl64d\\\\bin\\\\perl.exe -MExtUtils​::XSpp​::Cmd -e xspp
-- -t \"D​:/src-perl/Slic3r/xs/xsp/typemap.xspt\"
\"D​:/src-perl/Slic3r/xs/xsp/Print.xsp\""

If I remove the quotes from the INCLUDE_COMMAND call, the resulting form is
swallowed by the Visual Studio compiler without any problem.

#line 112 "c​:\\\\wperl64d\\\\bin\\\\perl.exe -MExtUtils​::XSpp​::Cmd -e xspp
-- -t D​:/src-perl/Slic3r/xs/xsp/typemap.xspt
D​:/src-perl/Slic3r/xs/xsp/Print.xsp"

I see the following ways to fix this problem​:

1) The XS generator would remove the inner quotes from the #line comments
when targeting the Visual Studio compiler

2) The XS generator would save the intermediate file generated by the
script in INCLUDE_COMMAND, and reference it in XS.c

Thanks for consideration,
Vojtech

@p5pRT
Copy link
Author

p5pRT commented Aug 21, 2016

From @cpansprout

On Sun Aug 21 09​:48​:30 2016, bubnikv@​gmail.com wrote​:

Hello.

I am trying to set up a development perl environment compiled from scratch
with Visual Studio 2013 free C/C++ compiler. I stumbled over a following
problem​:

If the XS file contains an INCLUDE_COMMAND call, this line is later stored
as a comment into the generated XS.c file in a form of #line NUMBER
"filepath". Here the "filepath" will be the complete parameter of
INCLUDE_COMMAND. If the parameter contains escaped quotes, this breaks the
__FILE__ substitution in the visual studio C++ compiler.

Here is an example of a #line inserted into XS.c, which the Visual Studio
C++ has a problem with​:

#line 112 "c​:\\\\wperl64d\\\\bin\\\\perl.exe -MExtUtils​::XSpp​::Cmd -e xspp
-- -t \"D​:/src-perl/Slic3r/xs/xsp/typemap.xspt\"
\"D​:/src-perl/Slic3r/xs/xsp/Print.xsp\""

If I remove the quotes from the INCLUDE_COMMAND call, the resulting form is
swallowed by the Visual Studio compiler without any problem.

How exactly does it fail? What error message does it produce?

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Aug 21, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 21, 2016

From bubnikv@gmail.com

How exactly does it fail? What error message does it produce?

What fails is the substitution of the __FUNCTION__ macro, which is
Microsoft's non-standard variant of the __func__ macro defined by the C99
standard I believe. Visual Studio will fail to compile various asserts,
which unfold the __FUNCTION__ macro. I think what happens is the Visual
Studio compiler somehow incorrectly interprets the quoting. The error
message given by the compiler is confusing at least and it was quite hard
to pinpoint it to the quotes in the #line.

On Sun, Aug 21, 2016 at 7​:35 PM, Father Chrysostomos via RT <
perlbug-followup@​perl.org> wrote​:

On Sun Aug 21 09​:48​:30 2016, bubnikv@​gmail.com wrote​:

Hello.

I am trying to set up a development perl environment compiled from
scratch
with Visual Studio 2013 free C/C++ compiler. I stumbled over a following
problem​:

If the XS file contains an INCLUDE_COMMAND call, this line is later
stored
as a comment into the generated XS.c file in a form of #line NUMBER
"filepath". Here the "filepath" will be the complete parameter of
INCLUDE_COMMAND. If the parameter contains escaped quotes, this breaks
the
__FILE__ substitution in the visual studio C++ compiler.

Here is an example of a #line inserted into XS.c, which the Visual Studio
C++ has a problem with​:

#line 112 "c​:\\\\wperl64d\\\\bin\\\\perl.exe -MExtUtils​::XSpp​::Cmd -e
xspp
-- -t \"D​:/src-perl/Slic3r/xs/xsp/typemap.xspt\"
\"D​:/src-perl/Slic3r/xs/xsp/Print.xsp\""

If I remove the quotes from the INCLUDE_COMMAND call, the resulting form
is
swallowed by the Visual Studio compiler without any problem.

How exactly does it fail? What error message does it produce?

--

Father Chrysostomos

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

2 participants