Skip to content

Conversation

@marc-vanderwal
Copy link
Contributor

Purpose

This PR addresses an oversight in #210 that causes Makefile.PL to fail when a library needs include paths (-I) specified on the compiler command line.

Context

See:

Changes

Filter the output of pkg-config to turn it into a list of raw paths, for consumption by cc_include_paths from Module::Install::XSUtil.

How to test this PR

Run Makefile.PL, ideally while having OpenSSL or LDNS installed in a custom location such as the user’s home directory.

It turns out that the cc_include_flags function, from
Module::Install::XSUtil, doesn’t like being given raw command-line
arguments (e.g. a string like "-I/path/to/thing -I/some/thing/else"). We
have to give it a list of strings without the prefixing "-I" (e.g.
"/path/to/thing", "/some/thing/else"). This commit takes care of that.
@marc-vanderwal marc-vanderwal added the T-Bug Type: Bug in software or error in test case description label Nov 25, 2024
@marc-vanderwal marc-vanderwal added this to the v2024.2 milestone Nov 25, 2024
@matsduf
Copy link
Contributor

matsduf commented Nov 25, 2024

@marc-vanderwal, this is a draft. Is it ready for review?

@marc-vanderwal
Copy link
Contributor Author

Not yet, I’d like to know if it works on someone else’s machine, for example @ondohotola’s setup.

@matsduf matsduf added the V-Patch Versioning: The change gives an update of patch in version. label Nov 25, 2024
@matsduf
Copy link
Contributor

matsduf commented Nov 25, 2024

I have built and installed on FreeBSD without any issues.

@ondohotola
Copy link

It builds on the Intel (15.1.1) without any issues.

On the Silicon (15.1.1) with Homebrew (including perl)

el@epi:~/Downloads/zonemaster-ldns-bugfix-129-part-3> perl Makefile.PL
include /Users/el/Downloads/zonemaster-ldns-bugfix-129-part-3/inc/Module/Install.pm
include inc/Module/Install/Metadata.pm
include inc/Module/Install/Base.pm
include inc/Module/Install/Makefile.pm
include inc/Module/Install/XSUtil.pm
include inc/Module/Install/Can.pm
Writing ppport.h
Adding include paths for OpenSSL using pkg-config: /opt/homebrew/Cellar/openssl@3/3.4.0/include
Adding library paths and names for OpenSSL using pkg-config: -L/opt/homebrew/Cellar/openssl@3/3.4.0/lib -lssl -lcrypto
Can't link/include C library 'openssl/crypto.h', 'crypto', aborting.

The following works:

perl Makefile.PL --prefix-openssl=$(pkg-config --variable=prefix openssl) \
   --libidn-inc=$(pkg-config --variable=includedir libidn2) \
   --libidn-lib=$(pkg-config --variable=libdir libidn2)

showing:

include /Users/el/Downloads/zonemaster-ldns-bugfix-129-part-3/inc/Module/Install.pm
include inc/Module/Install/Metadata.pm
include inc/Module/Install/Base.pm
include inc/Module/Install/Makefile.pm
include inc/Module/Install/XSUtil.pm
include inc/Module/Install/Can.pm
Writing ppport.h
Custom prefix for OpenSSL: /opt/homebrew/Cellar/openssl@3/3.4.0
Feature Ed25519 enabled
Feature internal ldns enabled
Feature NSID enabled
Feature idn enabled
Custom include directory for Libidn: /opt/homebrew/Cellar/libidn2/2.3.7/include
Custom library directory for Libidn: /opt/homebrew/Cellar/libidn2/2.3.7/lib
Feature randomized capitalization disabled
include inc/Module/Install/WriteAll.pm
include inc/Module/Install/Win32.pm
include inc/Module/Install/Fetch.pm
Generating a Unix-style Makefile
Writing Makefile for Zonemaster::LDNS
Writing MYMETA.yml and MYMETA.json
Writing META.yml

The cc_libs function in Module::Install::XSUtil expects a list of
strings, while we were passing it a single string containing
whitespace-delimited items. Split it, so that it hopefully works as
intended.
@marc-vanderwal
Copy link
Contributor Author

@ondohotola Thanks for the feedback! And it’s a good thing that passing --prefix-openssl works.

I’ve found a small mistake in my new code and pushed a fix. Does that work on ARM-based Macs too?

@ondohotola
Copy link

No, does not work on ARM:

include /Users/el/Downloads/zonemaster-ldns-bugfix-129-part-3/inc/Module/Install.pm
include inc/Module/Install/Metadata.pm
include inc/Module/Install/Base.pm
include inc/Module/Install/Makefile.pm
include inc/Module/Install/XSUtil.pm
include inc/Module/Install/Can.pm
Writing ppport.h
Adding include paths for OpenSSL using pkg-config: /opt/homebrew/Cellar/openssl@3/3.4.0/include
Adding library paths and names for OpenSSL using pkg-config: -L/opt/homebrew/Cellar/openssl@3/3.4.0/lib -lssl -lcrypto
Can't link/include C library 'openssl/crypto.h', 'crypto', aborting.

@ondohotola
Copy link

I just found out that

cpanm --configure-args="--prefix-openssl=$(pkg-config --variable=prefix openssl) \
   --libidn-inc=$(pkg-config --variable=includedir libidn2) \
   --libidn-lib=$(pkg-config --variable=libdir libidn2)" \
Zonemaster::LDNS

also works. Still not ideal, but one doesn't have to go into the build directory.

When pkg-config is used to discover the appropriate header and library
locations, the new code forgot to update a hash that is passed to the
cc_assert_lib function later on.

This means that on systems with non-traditional locations for openssl or
ldns libraries, the cc_assert_lib didn’t check the locations previously
discovered by pkg-config.

This commit should ensure that cc_assert_lib finds those libraries when
testing for their presence.
@marc-vanderwal
Copy link
Contributor Author

I agree that it isn’t ideal. Actually, I think I’ve found the problem: I forgot to update a data structure later passed on to functions in Devel::CheckLib with the information obtained from pkg-config. Can you test again, please?

@ondohotola
Copy link

ondohotola commented Nov 26, 2024

Same error on AMR, works on Intel

@marc-vanderwal marc-vanderwal modified the milestones: v2024.2, v2025.1 Nov 27, 2024
@tgreenx tgreenx linked an issue May 6, 2025 that may be closed by this pull request
@marc-vanderwal marc-vanderwal modified the milestones: v2025.1, v2025.2 Jun 4, 2025
@marc-vanderwal
Copy link
Contributor Author

I now have access to an ARM-based Mac, but haven’t had the time to continue investigating this problem. I’ll push the fix to the next release.

@matsduf matsduf added the RC-Fixes Release category: Fixes. label Aug 10, 2025
@matsduf matsduf modified the milestones: v2025.2, v2026.1 Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RC-Fixes Release category: Fixes. T-Bug Type: Bug in software or error in test case description V-Patch Versioning: The change gives an update of patch in version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libidn not found with Homebrew on Mac

3 participants