conan
conan copied to clipboard
[bug] conan.tools.AutotoolsDeps: linker error due to `-F -Wl,-rpath -Wl,<libdirs>` on macOS when there are dependencies
Environment Details (include every applicable attribute)
- Operating System+version: macOS Monterey
- Compiler+version: AppleClang 13.1.6
- Conan version: 1.52.0
- Python version: 3.10.6
Steps to reproduce (Include if Applicable)
- create an autotools recipe with dependencies, relying on AutotoolsToolchain, AutotoolsDeps & Autotools
- run conan create
(I have a CCI branch for capnproto reproducing this issue, it's the first autotools recipe migrating to conan v2 and allowing a build on macOS, I'll submit a PR in CCI and provide the link)
Logs (Executed commands with output) (Include/Attach if Applicable)
libtool: link: g++ -std=gnu++14 -dynamiclib -o .libs/libkj-0.10.1.dylib src/kj/.libs/common.o src/kj/.libs/units.o src/kj/.libs/memory.o src/kj/.libs/refcount.o src/kj/.libs/array.o src/kj/.libs/list.o src/kj/.libs/string.o src/kj/.libs/string-tree.o src/kj/.libs/source-location.o src/kj/.libs/hash.o src/kj/.libs/table.o src/kj/.libs/encoding.o src/kj/.libs/exception.o src/kj/.libs/debug.o src/kj/.libs/arena.o src/kj/.libs/io.o src/kj/.libs/mutex.o src/kj/.libs/thread.o src/kj/.libs/time.o src/kj/.libs/filesystem.o src/kj/.libs/filesystem-disk-unix.o src/kj/.libs/filesystem-disk-win32.o src/kj/.libs/test-helpers.o src/kj/.libs/main.o src/kj/parse/.libs/char.o -L/Users/spaceim/.conan/data/zlib/1.2.12/_/_/package/bda713dd3b257827c8d11a06ac9d824038871572/lib -L/Users/spaceim/.conan/data/openssl/1.1.1q/_/_/package/bda713dd3b257827c8d11a06ac9d824038871572/lib -lz -lssl -lcrypto -stdlib=libc++ -m64 -O3 -m64 -Wl,-rpath -Wl,@loader_path/../lib -F -Wl,-rpath -Wl,/Users/spaceim/.conan/data/zlib/1.2.12/_/_/package/bda713dd3b257827c8d11a06ac9d824038871572/lib -Wl,-rpath -Wl,/Users/spaceim/.conan/data/openssl/1.1.1q/_/_/package/bda713dd3b257827c8d11a06ac9d824038871572/lib -install_name //lib/libkj-0.10.1.dylib -Wl,-single_module
ld: warning: directory not found for option '-F-Wl,-rpath'
ld: warning: double slash removed from -install_name (//lib/libkj-0.10.1.dylib)
ld: can't map file, errno=22 file '/Users/spaceim/.conan/data/zlib/1.2.12/_/_/package/bda713dd3b257827c8d11a06ac9d824038871572/lib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libkj.la] Error 1
In this example with capnproto, dependencies are openssl & zlib:
It's worth noting that zlib
recipe defines a layout, so it shouldn't propagate frameworkdirs (according to discussions in https://github.com/conan-io/conan/issues/11867?). But maybe it comes indirectly from the fact that openssl recipe doesn't define yet a layout and zlib is also one of its dependencies?
But maybe it comes indirectly from the fact that openssl recipe doesn't define yet a layout and zlib is also one of its dependencies?
Answering myself: indeed when I disable openssl in capnproto, no issue, so openssl recipe must be migrated to conan v2 (at least layout).
Anyway I'm surprised to see that linker fails with -F
injection from AutotoolsDeps
even though libdir exists. -F -Wl,-rpath -Wl,<libdir>
is odd, it should be -F<libdir>
This is similar to an issue we've seen in the past (although still under investigation).
I think this is caused by libtool: one of the packages probably has .la
files next to the library files. If you have a library that uses Autotools to drive the build, and uses libtools, it will parse those .la files - which unfortunately have the "install prefix" that build was configured with. Which is likely to be /
if it uses the new Autotools integration.
In the case that I saw in the past, the issue was solved by removing the .la from the contents of the package, then consumers won't see odd libtool behaviours. Still pondering whether this is a general solution for every package that may contain .la
files - but I know some Linux distros explicitly expect the .la files to be removed in most circumstances, one of the reasons being the hardcoded paths.
@jcar87 I confirm it's a side effect of missing layout in openssl recipe.
This addition in openssl recipe is sufficient to fix issue in downstream recipes relying on AutotoolsDeps and depending on openssl:
def layout(self):
pass
In a sense it's quite similar to https://github.com/conan-io/conan/issues/11867. But it's really not a good thing for conan v2 migration.
Does https://github.com/conan-io/conan/pull/12307 fix this issue as suggested by @theartful ?