Skip to content

Makefile.PL: set include paths correctly#213

Open
marc-vanderwal wants to merge 5 commits into
zonemaster:developfrom
marc-vanderwal:bugfix/#129-part-3
Open

Makefile.PL: set include paths correctly#213
marc-vanderwal wants to merge 5 commits into
zonemaster:developfrom
marc-vanderwal:bugfix/#129-part-3

Conversation

@marc-vanderwal

Copy link
Copy Markdown
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.

@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

matsduf commented Nov 25, 2024

Copy link
Copy Markdown
Contributor

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

@marc-vanderwal

Copy link
Copy Markdown
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

matsduf commented Nov 25, 2024

Copy link
Copy Markdown
Contributor

I have built and installed on FreeBSD without any issues.

@ondohotola

Copy link
Copy Markdown

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

@marc-vanderwal

Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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.

@marc-vanderwal

Copy link
Copy Markdown
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

ondohotola commented Nov 26, 2024

Copy link
Copy Markdown

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
Copy Markdown
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
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.
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.
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.
The previous commits were close, but no cigar. This time, we should be
able to find openssl’s libraries if they are installed in a custom
location (e.g. via brew on macOS).
LDNS needs OpenSSL to work, so when we use cc_assert_lib for ldns, we
should import the incpath and libpath options for openssl and ldns
together, otherwise it might not work.
@marc-vanderwal

marc-vanderwal commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

I was able to make some progress getting Zonemaster-LDNS to compile on macOS/arm64 with these changes. But for some reason, perl segfaults whenever I try to use anything that requires the LDNS library.

In their infinite wisdom, Apple have decided that I cannot attach a debugger to the perl binary, so I’m at a loss here.

@marc-vanderwal

Copy link
Copy Markdown
Contributor Author

Oh well; even though we don’t officially support macOS as a platform, at least this change can benefit unusual configurations where libraries like LDNS and OpenSSL are installed in unusual places.

@marc-vanderwal marc-vanderwal marked this pull request as ready for review April 8, 2026 14:23
@ondohotola

Copy link
Copy Markdown

If it doesn't work, enter the the build directory and turn Claude Code lose

@tgreenx tgreenx modified the milestones: v2026.1, v2026.2 Jun 9, 2026
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

4 participants