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

Test for LIBS -l flags fails on OS X 11 #381

Closed
dmacks opened this issue Nov 23, 2020 · 8 comments
Closed

Test for LIBS -l flags fails on OS X 11 #381

dmacks opened this issue Nov 23, 2020 · 8 comments

Comments

@dmacks
Copy link

dmacks commented Nov 23, 2020

Apple's dynamic linker now has a cache of system libraries, and the actual files no longer exist. (macOS Big Sur 11.0.1 Release Notes):

New in macOS Big Sur 11.0.1, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to dlopen() the path, which will correctly check for the library in the cache. (62986286)

That breaks how WriteMakefile processes its LIBS parameter, where for example, "-lz" is valid and leads to correct symbol resolution of what would be in libz, but there is no libz.dylib. But EU::MM reports "Warning (mostly harmless): No library found for -lz" and does not pass the flag. As a result, an XS module does not get linked against the dependent library.

Seems like there should be a fallback (or preliminary test even before bothering to search for the file?) of just trying the linker. More expensive than file searching, but also actually tests for what is actually going to happen rather than a suddenly fragile heuristic.

See fink/fink-distributions/issues/689

@Leont
Copy link
Member

Leont commented Nov 23, 2020

All of this logic is rather unfortunate if you ask me, but it is what it is :-/

Instead, check for library presence by attempting to dlopen() the path, which will correctly check for the library in the cache.

That does sound possible using DynaLoader

@mitchblank
Copy link

Yeah, just tripped over this after spending hours debugging a compile failure on OS/X 11.

Easy repro: on OS/X 10.15

$ perl -e 'require ExtUtils::Liblist; use Data::Dumper; print Dumper(ExtUtils::Liblist->ext("-lcurses"))'

$VAR1 = '-lcurses';
$VAR2 = '';
$VAR3 = '-lcurses';
$VAR4 = '/usr/lib';

...but on OS/X 11:

$ perl -e 'require ExtUtils::Liblist; use Data::Dumper; print Dumper(ExtUtils::Liblist->ext("-lcurses"))'
Warning (mostly harmless): No library found for -lcurses
$VAR1 = '';
$VAR2 = '';
$VAR3 = '';
$VAR4 = '';

There is some more discussion about the basic issue with OS/X 11 libraries here https://news.ycombinator.com/item?id=23612772 but the basic upshot is what @dmacks said -- the libraries exist in some real sense, you can even dlopen() them by their supposed pathname, but they don't actually exist as files on the filesystem. Great fun.

@mitchblank
Copy link

And, yes, DynaLoader does seem capable of probing for these faux library files:

$ perl -e 'require Dynaloader; use Data::Dumper; print Dumper(DynaLoader::dl_load_file("x"))'
$VAR1 = undef;
$ perl -e 'require Dynaloader; use Data::Dumper; print Dumper(DynaLoader::dl_load_file("/usr/lib/libcurses.dylib"))'
$VAR1 = '4397946183680';
$ ls -l /usr/lib/libcurses.dylib
ls: /usr/lib/libcurses.dylib: No such file or directory

@dmacks
Copy link
Author

dmacks commented Dec 7, 2020

Good find! Just to verify, is this with Apple's perl (/usr/bin/perl5.whatever that sees various Library/Perl modules) or a built-from-source that does not see any of Apple's possible custom patching to anything?

@mitchblank
Copy link

This is just /usr/bin/perl on both machines. I suspect there isn't any perl patching involved though since the filesystem emulation happens inside of dlopen() itself.

mitchblank added a commit to mitchblank/homebrew-core that referenced this issue Dec 8, 2020
The problem wasn't with asciiquarium itself, but with building
the Curses perl resource.  In turn, this is due to an issue
with the Apple-provided perl MakeMaker as described here:
  Perl-Toolchain-Gang/ExtUtils-MakeMaker#381

Because of the complicated symbol detection inside the Curses
resource working around this issue is a bit messy.

While working on it I updated the Curses resource to the latest
upstream version and thus had to bump the formula revision.
@mohawk2
Copy link
Member

mohawk2 commented Dec 23, 2020

Is this now fixed?

@Leont
Copy link
Member

Leont commented Dec 23, 2020

Yes, this is fixed in 7.58

@Leont Leont closed this as completed Dec 23, 2020
jwilk pushed a commit to jwilk-mirrors/perl-term-readline-gnu that referenced this issue Feb 13, 2021
- require ExtUtils::MakeMaker 7.58 or later on macOS Big Sur or later.
  See Perl-Toolchain-Gang/ExtUtils-MakeMaker#381
  for details.
- can specify multiple directories on --prefix, --libdir, and
  --includedir options by separating them with colons (for Homebrew
  on macOS).


git-svn-id: https://svn.code.sf.net/p/perl-trg/code/trunk@578 75bfd316-ca9c-4271-b570-2f09a026c862
hirooih pushed a commit to hirooih/perl-trg that referenced this issue Feb 22, 2021
- require ExtUtils::MakeMaker 7.58 or later on macOS Big Sur or later.
  See Perl-Toolchain-Gang/ExtUtils-MakeMaker#381
  for details.
- can specify multiple directories on --prefix, --libdir, and
  --includedir options by separating them with colons (for Homebrew
  on macOS).
hirooih pushed a commit to hirooih/perl-trg that referenced this issue Feb 22, 2021
- require ExtUtils::MakeMaker 7.58 or later on macOS Big Sur or later.
  See Perl-Toolchain-Gang/ExtUtils-MakeMaker#381
  for details.
- can specify multiple directories on --prefix, --libdir, and
  --includedir options by separating them with colons (for Homebrew
  on macOS).
hirooih added a commit to hirooih/perl-trg that referenced this issue Feb 22, 2021
- require ExtUtils::MakeMaker 7.58 or later on macOS Big Sur or later.
  See Perl-Toolchain-Gang/ExtUtils-MakeMaker#381
  for details.
- can specify multiple directories on --prefix, --libdir, and
  --includedir options by separating them with colons (for Homebrew
  on macOS).
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Apr 26, 2021
1.40  2021-02-23
        - Migrate the repository and the bug tracker to GitHub

1.39  2021-02-22
        - Makefile.PL
            - some more fix for Homebrew on macOS [rt.cpan.org #133846]

1.38  2021-02-22
        - Makefile.PL
            - run 'brew --prefix ncurses' internally to detect ncurses installed
              by Homebrew on macOS [rt.cpan.org #133846]
            - utilize ExtUtils::Liblist::ext() [rt.cpan.org #134408]
              On macOS Big Sur or later 'perl Makefile.PL' may warn as
                "Could not find neither libtermcap, libtinfo, libncurses, or libcurses."
              You should be able to ignore this warning if you have Xcode installed. See
                Perl-Toolchain-Gang/ExtUtils-MakeMaker#381
              for details. To suppress this message, use ExtUtils::MakeMaker 7.58 or later.
            - can specify multiple directories on --prefix, --libdir, and
              --includedir options by separating them with colons
        - INSTALL
            - update for changes above and so on.

1.37  2020-12-27
	- readline-8.1 support
	    new function
		rl_activate_mark
		rl_deactivate_mark
		rl_keep_mark_active
		rl_mark_active_p
	    use native operate_and_get_next on GNU ReadLine 8.1 and later.
	- Gnu.xs: warns if attempted completion function returns undef in pos 0.
	  [rt.cpan.org #132384]
	- ppport.h: update from version 3.31 to version 3.52.
	- fixes to be more CPAN Testers friendly
	  - Makefile.PL exits 0 when $TERM is not set properly. [rt.cpan.org #128806]
        - update URLs of the GNU Readline Library manual website. [rt.cpan.org #131362]
        - update URLs of soundgrab.
@karenetheridge
Copy link
Member

I just ran into this today building 5.32.1 on OSX 11.3 (Big Sur). I wonder if it's worthwhile pushing forward on 5.32.2 in order to bundle this fix.

Or could this be eligible for putting in Devel::PatchPerl?

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

5 participants