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

pkg-config: do not ever successfully detect Strawberry Perl. #9384

Conversation

eli-schwartz
Copy link
Member

@eli-schwartz eli-schwartz commented Oct 10, 2021

This is broken and terrible and thus completely unusable. Don't torture users by finding pkg-config on Windows, thus permitting the pkg-config lookup of several dependencies that do not actually work -- which then fails at build time.

This also breaks CI for the wrapdb, because Strawberry Perl is provided as part of the base image for the OS (yes, even though it is terribly broken!!!) and anything that depends on e.g. zlib will "find" zlib because of this broken disaster, even though it should use the wrapdb subproject of zlib.

It is assumed no one actually wants to mix Strawberry Perl and meson. In fact, some projects, such as gst-build, already unconditionally error out if Strawberry Perl is detected in PATH:

error('You have Strawberry Perl in PATH which is known to cause build issues with gst-build. Please remove it from PATH or uninstall it.')

Other projects (postgresql) actually do want to build perl extensions, and link to the perl dlls, but absolutely under no circumstances ever want to use its pkg-config implementation. ;)

Let's solve this problem by just considering this to not be a valid pkg-config, let the user find another or not have one at all.

This change "solves" StrawberryPerl/Perl-Dist-Strawberry#11

@eli-schwartz eli-schwartz force-pushed the strawberry-perl-has-a-broken-pkg-config branch 2 times, most recently from 6489bbc to 4b9fa3a Compare October 10, 2021 21:42
@codecov
Copy link

codecov bot commented Oct 10, 2021

Codecov Report

Merging #9384 (88d9646) into master (4d9cc9c) will increase coverage by 0.75%.
The diff coverage is 47.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9384      +/-   ##
==========================================
+ Coverage   66.53%   67.28%   +0.75%     
==========================================
  Files         394      396       +2     
  Lines       85336    85410      +74     
  Branches    17457    17481      +24     
==========================================
+ Hits        56776    57470     +694     
+ Misses      23877    23250     -627     
- Partials     4683     4690       +7     
Impacted Files Coverage Δ
mesonbuild/arglist.py 90.18% <0.00%> (ø)
mesonbuild/backend/vs2010backend.py 0.00% <ø> (ø)
mesonbuild/cmake/interpreter.py 82.09% <ø> (+0.32%) ⬆️
mesonbuild/compilers/compilers.py 84.82% <ø> (+0.15%) ⬆️
mesonbuild/compilers/cpp.py 46.22% <ø> (+2.05%) ⬆️
mesonbuild/compilers/cuda.py 64.52% <ø> (ø)
mesonbuild/compilers/d.py 62.06% <ø> (+2.39%) ⬆️
mesonbuild/compilers/fortran.py 52.72% <ø> (ø)
mesonbuild/compilers/mixins/clang.py 83.33% <ø> (ø)
mesonbuild/compilers/mixins/visualstudio.py 27.09% <ø> (ø)
... and 100 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 437745b...88d9646. Read the comment docs.

…string

There are a bunch of cases in a single function where we would want to
log the detected path of pkg-config. Formatting this is awkward. Define
it once, then use f-strings everywhere. :D
@eli-schwartz eli-schwartz force-pushed the strawberry-perl-has-a-broken-pkg-config branch from 4b9fa3a to ac83835 Compare October 10, 2021 22:21
@anarazel
Copy link
Contributor

Checking for "Strawberry/" in the path doesn't strike me as particularly reliable - yes, that's the default, but e.g. I installed it under c:/perl/version.of.perl/ because I need to switch between multiple versions.

A bit more complicated approach would be to check if (dirname pkg-config.bat)/../../DISTRIBUTIONS.txt starts with "Strawberry Perl". But maybe that's too complicated...

@@ -423,18 +423,20 @@ def check_pkgconfig(self, pkgbin: ExternalProgram) -> T.Optional[str]:
if not pkgbin.found():
mlog.log(f'Did not find pkg-config by name {pkgbin.name!r}')
return None
command_as_string = ' '.join(pkgbin.get_command())
if r'Strawberry\perl\bin' in pkgbin.get_path():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly worried that this check is too strict. Like get_path() could return POSIX path, or it could be in another subdir. I would rather go with 'strawberry' in pkgbin.get_path().lower(). But in any case, yes we should black list that crap, and probably do that for any binary such as gcc.exe, etc. I just now realise it's the cause of msvc env not being activated by default on GitHub Windows CI, meson find strawberry gcc...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strawberry GCC!!!

Oh dear, the rabbit hole just goes deeper.

Should we encode this test in mesonbuild.programs.ExternalProgram then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if seems_to_be_strawberry and self.name != 'perl':
    return [None]

dies

Because we do of course want to make sure that actual perl.exe is detected, people might want to actually use that. As a script interpreter at the very least.

@anarazel
Copy link
Contributor

anarazel commented Oct 10, 2021 via email

@xclaesse
Copy link
Member

A bit more complicated approach would be to check if (dirname pkg-config.bat)/../../DISTRIBUTIONS.txt starts with "Strawberry Perl". But maybe that's too complicated...

I think that's the most reliable way indeed.

FWIW I compiled a bunch of things successfully with strawberry perl's gcc. And used several binaries from it. Mostly because it made the CI process faster. So refusing anything from strawberry seems like a good of overkill?

I agree, let's blacklist only pkg-config for now because that one cannot be useful in any possible way.

@xclaesse
Copy link
Member

oh wait, there is a better way:

pkg-config --help
Name:
    PkgConfig - Pure-Perl Core-Only replacement for pkg-config

This is broken and terrible and thus completely unusable. Don't torture
users by finding pkg-config on Windows, thus permitting the pkg-config
lookup of several dependencies that do not actually work -- which then
fails at build time.

This also breaks CI for the wrapdb, because Strawberry Perl is provided
as part of the base image for the OS (yes, even though it is terribly
broken!!!) and anything that depends on e.g. zlib will "find" zlib
because of this broken disaster, even though it should use the wrapdb
subproject of zlib.

It is assumed no one actually wants to mix Strawberry Perl and meson. In
fact, some projects, such as gst-build, already unconditionally error
out if Strawberry Perl is detected in PATH:

    error('You have Strawberry Perl in PATH which is known to cause build issues with gst-build. Please remove it from PATH or uninstall it.')

Other projects (postgresql) actually do want to build perl extensions,
and link to the perl dlls, but absolutely under no circumstances ever
want to use its pkg-config implementation. ;)

Let's solve this problem by just considering this to not be a valid
pkg-config, let the user find another or not have one at all.

This change "solves"
StrawberryPerl/Perl-Dist-Strawberry#11
@eli-schwartz eli-schwartz force-pushed the strawberry-perl-has-a-broken-pkg-config branch from ac83835 to 88d9646 Compare October 11, 2021 00:50
@xclaesse
Copy link
Member

LGTM, thanks!

@xclaesse xclaesse added this to the 0.60.0 milestone Oct 11, 2021
@eli-schwartz eli-schwartz merged commit 88d9646 into mesonbuild:master Oct 11, 2021
@eli-schwartz eli-schwartz deleted the strawberry-perl-has-a-broken-pkg-config branch October 11, 2021 02:13
@bredelings
Copy link
Contributor

Should the test for "help message indicates strawberry perl" should come after the check that "pkg-config runs"? Perhaps the only difference is that if pkg-config is can't run, then testing for strawberry perl will mean that it is run twice.

zmughal added a commit to perlrdf/Alien-Sord that referenced this pull request Nov 12, 2023
This is needed because Meson skips the Pure Perl `pkg-config.bat`
provided by Strawberry Perl.

Connects with:
  - <mesonbuild/meson#9384>
  - <PerlAlien/Alien-Build#227>
nirbheek added a commit to nirbheek/pkg-config-rs that referenced this pull request Apr 6, 2024
Strawberry Perl places a `pkg-config.bat` into PATH that is written in
Perl and is not intended to be used by third parties as a MinGW
distribution. This wouldn't matter, except that Strawberry Perl is
also included in Github CI images out of the box, in `PATH`, and it
breaks everyone's CI jobs.

This is already done by Meson and CMake:

mesonbuild/meson#9384

https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9375

Fixes rust-lang#164
nirbheek added a commit to nirbheek/pkg-config-rs that referenced this pull request Apr 7, 2024
Strawberry Perl places a `pkg-config.bat` into PATH that is written in
Perl and is not intended to be used by third parties as a MinGW
distribution. This wouldn't matter, except that Strawberry Perl is
also included in Github CI images out of the box, in `PATH`, and it
breaks everyone's CI jobs.

This is already done by Meson and CMake:

mesonbuild/meson#9384

https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9375

Fixes rust-lang#164
nirbheek added a commit to nirbheek/pkg-config-rs that referenced this pull request Apr 7, 2024
Strawberry Perl places a `pkg-config.bat` into PATH that is written in
Perl and is not intended to be used by third parties as a MinGW
distribution. This wouldn't matter, except that Strawberry Perl is
also included in Github CI images out of the box, in `PATH`, and it
breaks everyone's CI jobs.

This is already done by Meson and CMake:

mesonbuild/meson#9384

https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9375

Fixes rust-lang#164
nirbheek added a commit to nirbheek/pkg-config-rs that referenced this pull request Apr 7, 2024
Strawberry Perl places a `pkg-config.bat` into PATH that is written in
Perl and is not intended to be used by third parties as a MinGW
distribution. This wouldn't matter, except that Strawberry Perl is
also included in Github CI images out of the box, in `PATH`, and it
breaks everyone's CI jobs.

This is already done by Meson and CMake:

mesonbuild/meson#9384

https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9375

Fixes rust-lang#164
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

Successfully merging this pull request may close these issues.

4 participants