-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
meson fails to locate libraries on macOS #10516
Comments
Note I explicitly make cmake not available when building with meson because it cause additional problems, such as pulling in content from the SDK that was used to build cmake even when I'm not using that SDK to build the current project. |
Based on the documentation, I'd expect to be able to use the 'system' method here with something like:
But that's not working, and there's nothing useful in meson-log.txt to explain what the 'system' method is doing in order to debug why it's failing... |
It looks like I can use this as a solution...
But that's overly convoluted. meson should be able to do that by default... |
This is just how dependencies work. A dependency can be called anything, unrelated to the name of the library, and possess arbitrary, or arbitrarily complex, compile / link args in addition to the library. This information is read from an interface file, which can be pkg-config or cmake or sometimes the output of a "config-tool" program. As described in https://mesonbuild.com/Dependencies.html#system a "system" type dependency is when the dependency description is in the meson source code as It is indeed correct to use cc.find_library yourself for this, if the Apple SDK is broken and malformed and lacks the pkg-config files which upstream expat provides. |
The macOS SDK is not malformed. It is designed to not need pkg-config files. Everything "just works" with -isysroot. This particular issue makes transitioning from autotools based builds to meson based builds overly complex, and it seems that meson should be able to handle this with a bit of extension.
If this is only supported for some cases (like zlib), those cases should be documented.
If all of those improvements were done, the above could be simplified as:
or if we want to have find_library assume the dependency name is the library_name (which seems reasonable to me):
and if we want to just include "find_library" in auto by default (like we do for "extraframework" on macOS):
Doing this will make using meson much easier and make it easier to write more poratble builds. |
Neither Meson Invoking the compiler with -lexpat and assuming it works, does work.
From this statement of yours, I assume you were NOT using autotools
It's entirely possible the documentation can be improved. Nevertheless, my interpretation of that page followed this section:
This clearly states that any other detection method is the domain of "specific detection logic", a.k.a. "dependencies with custom lookup functionality", which must be listed on that page. Which expat is not.
This could indeed be done. zlib is an example of a dependency that is often provided by a base OS, but not all of them actually install all parts of upstream zlib. macOS is one of those systems, but so are the BSDs. zlib was implemented... by request. In #2654 -- which includes mention of:
Leading to #6421 which mentions:
Personally, I'm okay with adding stuff that might be shipped as part of a base OS without pkg-config files, though I would not be fine with adding "every software out there". We want to encourage projects to use pkg-config, after all. But fighting with Apple is probably fruitless.
I assume you mean a dependency method. This is not robust, since library names may differ from package names and simply checking linkability does not tell you whether the development headers are installed. The generic tracking issue for this is in #2945, and a WIP attempt to implement it is in #8699. Some parts of it have landed as part of incremental PRs, for example since 0.60.0 you can now do In general, we want this functionality. It's just not there yet.
auto means try all methods, so your proposed use of an array would feel a bit strange. That being said, there may indeed be a use case for trying multiple methods, but not all methods. I haven't thought deeply on the topic. |
If you are interested in implementing any new features yourself, but I'm particularly thinking of adding an "expat" custom dependency lookup, I am happy to provide help and guidance. Also if you have proposed tweaks to the documentation to clarify things, I am happy to review those proposals, but it seems clear enough to me that I'm probably not the best judge of how to improve that. If not, I can probably find time to add an expat system dependency myself. |
historically, I actually looked for the issues after I wrote the zlib system dep because I saw everyone writing the dependency to find library dance separately but wanted to be a good issue’s citizen :) I’m happy to help with the other deps that help xorg/fro related projects @jeremyhu if you let me know which ones make sense and can help test on macOS. |
Thanks folks. I just got done updating my build scripts for XQuartz to use meson for the fdo projects that support it, and expat was the only dependency in this boat (for cairo and fontconfig). I'll look into wording changes that would have helped me out (now that I understand what "system" is). |
Seen with meson 0.62.1
The default methods for resolving a dependency() should include a trivial build test with -l.
For example, cairo and fontconfig attempt to locate expat with:
On macOS, this fails. libexpat is part of the system. There are no pkg-config files. It is trivially usable:
This results in us trying to download libexpat rather than using the system libexpat (which just requires "-lexpat"):
Before resorting to downloading and building the dependency, meson should first check if it's available as "-lexpat" (eg: build test, or look for it in $SDKROOT/usr/lib/libexpat.tbd)
The text was updated successfully, but these errors were encountered: