-
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 does not add objects from not-installed static libraries while creating static libraries #3937
Comments
Actually, it's worse, even objects from |
link_whole:
static libraries are internal static libraries
As a crutch for this bug, we had another bad behaviour: we were always transitively adding static libraries when linking to a static library, even with As a side-effect of this, we were also incorrectly adding internal static library dependencies of shared libraries while linking to shared libraries. |
This commit contains the following fixes: 1. When a shared library A does `link_with:` to static library B, the parts of B used by A will be added to A, and so we don't need to return B in A.get_dependencies() for targets that link to A. This already is the behaviour when a shared library A does `link_whole:` on B. 2. In situation (1), when generating a pkg-config file for A, we must also not add B to Libs.private for A. This already is the behaviour when a shared library A does `link_whole:` on B. 3. When a static library A does `link_whole:` to static library B, we must add the objects in B to A. 4. When a static library A does `link_with:` to static library B, and B is not installed (which makes it an internal static library), we must add the objects in B to A, otherwise nothing can use A. 5. In situation (4), when generating a pkg-config file for A, we must also not add B to Libs.private for A. All these situations are tested by the unit test added in this commit. Closes #3934 Closes #3937
This commit contains the following fixes: 1. When a shared library A does `link_with:` to static library B, the parts of B used by A will be added to A, and so we don't need to return B in A.get_dependencies() for targets that link to A. This already is the behaviour when a shared library A does `link_whole:` on B. 2. In situation (1), when generating a pkg-config file for A, we must also not add B to Libs.private for A. This already is the behaviour when a shared library A does `link_whole:` on B. 3. When a static library A does `link_whole:` to static library B, we must add the objects in B to A. 4. When a static library A does `link_with:` to static library B, and B is not installed (which makes it an internal static library), we must add the objects in B to A, otherwise nothing can use A. 5. In situation (4), when generating a pkg-config file for A, we must also not add B to Libs.private for A. All these situations are tested by the unit test added in this commit. Closes #3934 Closes #3937
This commit contains the following fixes: 1. When a shared library A does `link_with:` to static library B, the parts of B used by A will be added to A, and so we don't need to return B in A.get_dependencies() for targets that link to A. This already is the behaviour when a shared library A does `link_whole:` on B. 2. In situation (1), when generating a pkg-config file for A, we must also not add B to Libs.private for A. This already is the behaviour when a shared library A does `link_whole:` on B. 3. When a static library A does `link_whole:` to static library B, we must add the objects in B to A. 4. When a static library A does `link_with:` to static library B, and B is not installed (which makes it an internal static library), we must add the objects in B to A, otherwise nothing can use A. 5. In situation (4), when generating a pkg-config file for A, we must also not add B to Libs.private for A. All these situations are tested by the unit test added in this commit. Closes #3934 Closes #3937
This commit contains the following fixes: 1. When a shared library A does `link_with:` to static library B, the parts of B used by A will be added to A, and so we don't need to return B in A.get_dependencies() for targets that link to A. This already is the behaviour when a shared library A does `link_whole:` on B. 2. In situation (1), when generating a pkg-config file for A, we must also not add B to Libs.private for A. This already is the behaviour when a shared library A does `link_whole:` on B. 3. When a static library A does `link_whole:` to static library B, we must add the objects in B to A. 4. When a static library A does `link_with:` to static library B, and B is not installed (which makes it an internal static library), we must add the objects in B to A, otherwise nothing can use A. 5. In situation (4), when generating a pkg-config file for A, we must also not add B to Libs.private for A. All these situations are tested by the unit test added in this commit. Closes #3934 Closes #3937
This commit contains the following fixes: 1. When a shared library A does `link_with:` to static library B, the parts of B used by A will be added to A, and so we don't need to return B in A.get_dependencies() for targets that link to A. This already is the behaviour when a shared library A does `link_whole:` on B. 2. In situation (1), when generating a pkg-config file for A, we must also not add B to Libs.private for A. This already is the behaviour when a shared library A does `link_whole:` on B. 3. When a static library A does `link_whole:` to static library B, we must add the objects in B to A. 4. When a static library A does `link_with:` to static library B, and B is not installed (which makes it an internal static library), we must add the objects in B to A, otherwise nothing can use A. 5. In situation (4), when generating a pkg-config file for A, we must also not add B to Libs.private for A. All these situations are tested by the unit test added in this commit. Closes #3934 Closes #3937
This commit contains the following fixes: 1. When a shared library A does `link_with:` to static library B, the parts of B used by A will be added to A, and so we don't need to return B in A.get_dependencies() for targets that link to A. This already is the behaviour when a shared library A does `link_whole:` on B. 2. In situation (1), when generating a pkg-config file for A, we must also not add B to Libs.private for A. This already is the behaviour when a shared library A does `link_whole:` on B. 3. When a static library A does `link_whole:` to static library B, we must add the objects in B to A. 4. When a static library A does `link_with:` to static library B, and B is not installed (which makes it an internal static library), we must add the objects in B to A, otherwise nothing can use A. 5. In situation (4), when generating a pkg-config file for A, we must also not add B to Libs.private for A. All these situations are tested by the unit test added in this commit. Closes #3934 Closes #3937
This commit contains the following fixes: 1. When a shared library A does `link_with:` to static library B, the parts of B used by A will be added to A, and so we don't need to return B in A.get_dependencies() for targets that link to A. This already is the behaviour when a shared library A does `link_whole:` on B. 2. In situation (1), when generating a pkg-config file for A, we must also not add B to Libs.private for A. This already is the behaviour when a shared library A does `link_whole:` on B. 3. When a static library A does `link_whole:` to static library B, we must add the objects in B to A. 4. When a static library A does `link_with:` to static library B, and B is not installed (which makes it an internal static library), we must add the objects in B to A, otherwise nothing can use A. 5. In situation (4), when generating a pkg-config file for A, we must also not add B to Libs.private for A. All these situations are tested by the unit test added in this commit. Closes #3934 Closes #3937
As a side note, https://github.com/swaywm/wlroots seems to be affected as well when built with |
This works around meson bug 3937, 'link_whole' arguments don't get added into the final static library and we end up with a virtually empty 8-byte libxkbcommon.a file, see mesonbuild/meson#3937 Woraround is simply by adding all sources to both libraries we need them in. This obioviously compiles them twice but this year's winter was cold and bit of extra warmth will be appreciated. Fixes xkbcommon#84 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This works around meson bug 3937, 'link_whole' arguments don't get added into the final static library and we end up with a virtually empty 8-byte libxkbcommon.a file, see mesonbuild/meson#3937 Woraround is simply by adding all sources to both libraries we need them in. This obioviously compiles them twice but this year's winter was cold and bit of extra warmth will be appreciated. Fixes xkbcommon#84 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This works around meson bug 3937, 'link_whole' arguments don't get added into the final static library and we end up with a virtually empty 8-byte libxkbcommon.a file, see mesonbuild/meson#3937 Woraround is simply by adding all sources to both libraries we need them in. This obioviously compiles them twice but this year's winter was cold and bit of extra warmth will be appreciated. Fixes xkbcommon#84 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This works around meson bug 3937, 'link_whole' arguments don't get added into the final static library and we end up with a virtually empty 8-byte libxkbcommon.a file, see mesonbuild/meson#3937 Workaround is simply by adding all sources to both libraries we need them in. This obioviously compiles them twice but this year's winter was cold and bit of extra warmth will be appreciated. Fixes xkbcommon#84 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This works around meson bug 3937, 'link_whole' arguments don't get added into the final static library and we end up with a virtually empty 8-byte libxkbcommon.a file, see mesonbuild/meson#3937 Workaround is simply to add all sources to both libraries we need them in. This obviously compiles them twice but this year's winter was cold and bit of extra warmth will be appreciated. Fixes xkbcommon#84 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Similar to 75ce741, just for the -x11 sublibrary. This works around meson bug 3937, 'link_whole' arguments don't get added into the final static library and we end up with a virtually empty 8-byte libxkbcommon-x11.a file, see mesonbuild/meson#3937 The internal lib is still built for the one test case that requires it. Fixes xkbcommon#86 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Similar to 75ce741, just for the -x11 sublibrary. This works around meson bug 3937, 'link_whole' arguments don't get added into the final static library and we end up with a virtually empty 8-byte libxkbcommon-x11.a file, see mesonbuild/meson#3937 The internal lib is still built for the one test case that requires it. Fixes #86 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Switch back to autotools to fix static build with rygel (and so reverts partially commit 66a3fbb "package/gupnp: bump to version 1.0.4"). Indeed gupnp uses meson's subproject feature for guul which is just plainly broken on static build with meson, see: mesonbuild/meson#3934 mesonbuild/meson#3937 mesonbuild/meson#3939 This will fix a build failure with rygel Fixes: - http://autobuild.buildroot.org/results/ebbf96a1be5547e416feb1e96e55986890d0a1de Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
libcommon isn't even installed, so that means libalpm.a (if installed) is fatally broken as it misses objects. The problem is that meson doesn't handle this case correctly: mesonbuild/meson#3934 mesonbuild/meson#3937 mesonbuild/meson#3939 Work around this by manually extracting libcommon's .o files into the list of objects used to create libalpm.
Should be fixed by #5936 |
libcommon isn't even installed, so that means libalpm.a (if installed) is fatally broken as it misses objects. The problem is that meson doesn't handle this case correctly: mesonbuild/meson#3934 mesonbuild/meson#3937 mesonbuild/meson#3939 Work around this by manually extracting libcommon's .o files into the list of objects used to create libalpm. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
Projects often have internal (not-installed) static libraries which are linked into the installed library (f.ex.,
libcharset.a
,libgnulib.a
, andlibpcre.a
intolibglib-2.0
). These static libraries are always correctly linked into the shared library, but not into the static library, because Meson assumes that all static libraries that welink_with:
are available after installation, and must be linked via the pkg-config file.However, the aforementioned libraries must NOT be
link_whole:
because when you're doing a shared link, you don't want all the objects from them, only those that are actually used.Solution: add the objects from not-installed static library that a static library links with.
This is also what autotools does: it tracks
noinst_LTLIBRARIES
and transparently adds the objects from libraries inLIBADD
when generating a static librari.The text was updated successfully, but these errors were encountered: