-
Notifications
You must be signed in to change notification settings - Fork 3k
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: need to handle linking to static libass #9478
Comments
The sad answer is that there is currently not a good way to do this. Adding The workaround I would go with in this case is passing an ugly |
My comment is not so much related to the discussion here as such - although it's cool that people pay more |
Nothing is stopping you from building it statically. It's just not as convenient as it should be. |
I have tested to add to meson so that if a library it looks up is detected to be static it will add the dependencies you get from pkg-config --static. This way you do not need to add static:true and you will not get warnings about not finding static extra libraries. |
I opened up a PR in meson that would solve this: mesonbuild/meson#9603. |
Another interesting solution would be libass/libass#330 :) You could then configure mpv to build a local static copy of libass, with free LTO thrown in (and it would work OOTB for people who don't have libass installed at all yet). A global meson option is a pain point which I'd be happy to see solved though, of course. |
The PR by @Dudemanguy is not exactly the way I thought here. So my solution is to have meson during pkg-config checking when it locates all libraries and it detects a library that need to be linked statically, it will call pkg-config with --static to add the libraries the static library depends on. |
FWIW That also fixes the mingw static problem (aside from the mpv.com getting linked in too). |
@DanOscarsson: I'm not sure I understand. The
Is this a bug in the meson build? I'm not exactly sure how this is supposed to work on Windows but looking at the .com, it doesn't look like it should be linked to anything but merely a separate executable. |
Idk, possibly? |
@Dudemanguy If I understand your prefer_static option, from the PR, you set it with the Also it looks like setting static: true on a dependency I would expect that to mean: use the static version of the dependency. But from the warnings meson gives it looks like it expects all libraries the static marked library depends on, to have a static version and be used. That is not what I would expect should happen if the default is to prefer shared. |
Okay yeah this sounds like a bug. I'm pretty sure waf doesn't do that.
I think should still work? Admittedly I didn't test it, but what should happen is that the |
If I understands correctly the prefer_static means to request static everywhere. That is what my small patch to meson fixes. |
Right, that's exactly what prefer_static would solve. Unless you have a bunch of random static libraries in your pkg-config path that are duplicates of existing shared libraries, the other dependencies would just fallback to normal shared libraries. |
Tested by manually adding static:true to some of the dependencies i the build file. |
I know it's not exactly what you want, but the above mentioned PR has been merged. So the next meson release should make it a lot easier to do static linking. Wanting to handle only specific dependencies and such is still definitely a valid feature request. Feel free to make one upstream if such an issue isn't already open. I'll go ahead and close this now. Note to self: look at the windows meson builds again since I think they are kind of bugged with the .exe/.com thing. |
Nice, I can build with upstream meson just fine now. The exe/com thing is indeed still an issue though. |
meson build need to better support linking to static libraries
Important Information
Provide following Information:
Reproduction steps
Build ffmpeg and libass using mpv-build. This results in static libraries for them, no shared versions.
Build mpv using meson.
Build will fail in linking due to libraries that libass depends on, are not included.
My analysis of the problem is that as libass is only available as a static library, the needed libraries it depends on, are not included by meson as they are not included by pkg-config unless --static option is given.
I have two ways I can fix this, by adding static: true for the libass dependency in the meson.build file, or by changing the pkg-config libass.pc file.
But adding static: true in the meson.build file results in warnings from meson about not finding static version on the libraries libass depend. But most people will want them to be shared versions even if the have a static libass.
Also, those not needing the latest libass from mpv-build, would prefer to link to the shared version.
Changing libass.pc works but is an extra step and best if it can be avoided as the changed version is not suitable for a shared library.
Best would be if meson could handle this.
Looking at the meson source code I see that meson locates the full path for all libraries if locates. So it could easily see that a library is only available in static format and then add the needed libraries it depends on.
If you cannot get meson to fix this you should add some information to/about mpv-build of how to handle linking to libass with meson.
For a developer of mpv it is good to be able to use a static libass as you the can experiment with libass to better suit mpv, without disrupting other programs using libass. So using libraries like in mpv-build is needed.
The text was updated successfully, but these errors were encountered: