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

Add support for Perl built with C++ #1294

Open
pmqs opened this issue Oct 16, 2022 · 7 comments
Open

Add support for Perl built with C++ #1294

pmqs opened this issue Oct 16, 2022 · 7 comments

Comments

@pmqs
Copy link

pmqs commented Oct 16, 2022

For Perl XS modules, particularly those in the core, you need your module to support being build with a Perl binary created with a C++ compiler.

I'm just updating Compress-Raw-Zlib with a C- related change that gets stung with this use-case more often that I'd like. The typical workflow goes like tis

  • I update the module, forgetting to test the C++ use case
  • code gets uploaded to CPAN
  • the smokes run but they fail with the C++ builds
  • I scramble to fix the issue & upload a to CPAN

I have all of the use-cases I need cooked into my GitHub actions, but this one is missing. Any chance of adding C++ support?

@shogo82148
Copy link
Owner

I have never built Perl with C++.
How do I do that?

@pmqs
Copy link
Author

pmqs commented Oct 17, 2022

At the configure stage just use Dcc to use a C++ compiler rather that the default C compiler.

configure -Dcc=g++ ...

or this for clang

configure -Dcc=clang++ ...

@shogo82148
Copy link
Owner

I did.
However, I don't want to add more variant of perl binaries.

@tonycoz
Copy link

tonycoz commented Jun 14, 2024

@pmqs you should be able to test C++ builds sufficient for updating your modules in core by replacing:

perl Makefile.PL

line in your workflow file with:

perl Makefile.PL CC=g++

@pmqs
Copy link
Author

pmqs commented Jun 15, 2024

@pmqs you should be able to test C++ builds sufficient for updating your modules in core by replacing:

perl Makefile.PL

line in your workflow file with:

perl Makefile.PL CC=g++

Thanks @tonycoz

Part of the reason for wanting the C++ mode is to trap compiler errors & warnings in a build that I always forget to do when I'm getting a release together. The CC=g++ change works fine with the Linux gcc workflow, but the Mac workflow triggers a clang built Perl, so the CC=clang++ build that also include -Werror triggers this

clang: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]

That feels like a wider issue with building Perl with C++ in general that is going to cause problems when clang drop building C code with their C++ compiler.

@tonycoz
Copy link

tonycoz commented Jun 16, 2024

For your purposes you can probably do:

perl Makefile.PL CC="clang++ -xc++"

unfortunately that doesn't work when building perl itself (which I tried to fix in Perl/perl5@07e3b5c but had to revert in Perl/perl5@0c77b72)

@pmqs
Copy link
Author

pmqs commented Jun 17, 2024

For your purposes you can probably do:

perl Makefile.PL CC="clang++ -xc++"

unfortunately that doesn't work when building perl itself (which I tried to fix in Perl/perl5@07e3b5c but had to revert in Perl/perl5@0c77b72)

That's a good option. Didn't see that one in the clang docs. Another option I investigated was -Wno-error=deprecated but that doesn't silence the warning, plus it hides other possible deprecations.

Another option I use with C builds is -Wc++-compat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants