Skip to content
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

[bug] -rpath flag separator depends on build OS instead of host OS #7715

Closed
Erlkoenig90 opened this issue Sep 17, 2020 · 2 comments
Closed
Assignees
Milestone

Comments

@Erlkoenig90
Copy link
Contributor

Environment Details (include every applicable attribute)

Steps to reproduce (Include if Applicable)

Install osxcross on Linux, create a profile with os=Macos and attempt to build glib with this PR applied, like this:

Logs (Executed commands with output) (Include/Attach if Applicable)

conan create . -pr:h x86_64-apple-darwin19-macosx-clang -pr:b default -o glib:with_elf=False

results in

[111/398] Linking target glib/libglib-2.0.0.dylib
FAILED: glib/libglib-2.0.0.dylib 
x86_64-apple-darwin19-clang  -o glib/libglib-2.0.0.dylib ... lots of stuff ... -Wl,-rpath=/home/niklas.guertler/.conan/data/pcre/8.41/_/_/package/ddd42dd21f101343926e8ee9dff966bdba84b078/lib /home/niklas.guertler/.conan/data/bzip2/1.0.8/_/_/package/d81a2c40ef3ca9d7c9333cd75ac1bcdef9183a77/lib/libbz2.a -Wl,-rpath=/home/niklas.guertler/.conan/data/bzip2/1.0.8/_/_/package/d81a2c40ef3ca9d7c9333cd75ac1bcdef9183a77/lib /home/niklas.guertler/.conan/data/zlib/1.2.11/_/_/package/099680e166ebfb4e7a7b9e0126a86c3d8bf1e7a7/lib/libz.a -Wl,-rpath=/home/niklas.guertler/.conan/data/zlib/1.2.11/_/_/package/099680e166ebfb4e7a7b9e0126a86c3d8bf1e7a7/lib -lgnuintl -liconv -liconv
ld: unknown option: -rpath=/home/niklas.guertler/.conan/data/pcre/8.41/_/_/package/ddd42dd21f101343926e8ee9dff966bdba84b078/lib
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

The libpcre.pc file created by the pkg_config generator looks like this:

prefix=/home/niklas.guertler/.conan/data/pcre/8.41/_/_/package/ddd42dd21f101343926e8ee9dff966bdba84b078
libdir=${prefix}/lib
includedir=${prefix}/include

Name: pcre-libpcre
Description: Conan package: pcre-libpcre
Version: 8.41
Libs: -L${libdir} -lpcre  -Wl,-rpath="${libdir}"
Cflags: -I${includedir} -DPCRE_STATIC=1
Requires: bzip2 zlib

The ld64 linker used by Clang to (cross-)compile for Mac OS doesn't understand rpath flags with a = separator, which is why the rpath_flags function uses , instead of = when compiling on Mac OS. However, this does not work when cross-compiling on Linux for Mac OS, resulting in the malformed .pc files.

I would suggest changing the rpath_flags function to take the host (instead of build) OS as parameter and use that to determine the rpath_separator. I will submit a PR that does that.

Erlkoenig90 added a commit to Erlkoenig90/conan that referenced this issue Sep 17, 2020
…determine the separator for the ld -rpath flag which is neccessary for cross-compiling to Mac OS
@jgsogo
Copy link
Contributor

jgsogo commented Sep 17, 2020

Hi, I'm afraid this change will work for this scenario because "The ld64 linker used by Clang to (cross-)compile for Mac OS doesn't understand rpath flags with a = separator", but it might be broken for other scenarios where the linker used by other compilers to cross-compile expect those files in the format natural for the machine where the compiler is running (the build machine).

I'm not an expert on this topic, maybe @SSE4 has more sound opinion.

@jgsogo jgsogo self-assigned this Sep 17, 2020
Erlkoenig90 added a commit to Erlkoenig90/conan that referenced this issue Sep 17, 2020
… settings, pass os_build again and only set rpath_separator to , if compiling for Mac OS from Linux or Mac OS via GCC_LIKE
@Erlkoenig90
Copy link
Contributor Author

Right, well it works for Cross-Compiling from Linux to Mac OS via osxcross and to Windows via MinGW32. I just noticed it's silly to pass os_host to rpath_flags because it's already in settings, so I reverted that. I added some logic to only set the -rpath to , when compiling for Mac OS from Linux or Mac OS via a GCC_LIKE-compiler (but left the other solution as a comment, so we can decide). That should fix this issue without influencing other use cases.

@memsharded memsharded added this to the 1.33 milestone Jan 14, 2021
memsharded added a commit to memsharded/conan that referenced this issue Jan 18, 2021
…determine -rpath separator (conan-io#7716)

* Fix conan-io#7715, in rpath_flags use host OS instead of build OS to determine the separator for the ld -rpath flag which is neccessary for cross-compiling to Mac OS

* For conan-io#7715, don't pass os_host to rpath_flags but extract from settings, pass os_build again and only set rpath_separator to , if compiling for Mac OS from Linux or Mac OS via GCC_LIKE

* Fix test_compiler_args for cross-compiling Mac OS X -> Linux

* Update conans/client/build/compiler_flags.py

Co-authored-by: SSE4 <tomskside@gmail.com>

* Update conans/client/build/compiler_flags.py

Co-authored-by: SSE4 <tomskside@gmail.com>

* Update conans/test/unittests/client/generators/compiler_args_test.py

* Update conans/client/build/compiler_flags.py

* Use -rpath, in all tests for all platforms

* fixing tests

Co-authored-by: James <james@conan.io>
Co-authored-by: SSE4 <tomskside@gmail.com>
memsharded added a commit that referenced this issue Jan 18, 2021
* working in msvc new settings

* preliminary support for msvc compiler

* fix migration

* adding msvc for msbuild toolchain

* changing to version 19.1, 19.11, etc

* working on static/dynamic runtime

* extracting toolchain checkers to use in CMake

* removed unused import

* adding checks

* adding check

* first proposal

* msvc proposal for runtime

* fix migration test

* fixing tests

* binary compatibility

* command conan new generates files with new toolchains

* removed conanfile

* removed files

* msbuild working for msvc

* fixing tests

* fixing tests

* refactors

* Update conan/tools/microsoft/toolchain.py

Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>

* Update conan/tools/microsoft/toolchain.py

Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>

* Fix #7715, in rpath_flags use host OS instead of build OS to determine -rpath separator (#7716)

* Fix #7715, in rpath_flags use host OS instead of build OS to determine the separator for the ld -rpath flag which is neccessary for cross-compiling to Mac OS

* For #7715, don't pass os_host to rpath_flags but extract from settings, pass os_build again and only set rpath_separator to , if compiling for Mac OS from Linux or Mac OS via GCC_LIKE

* Fix test_compiler_args for cross-compiling Mac OS X -> Linux

* Update conans/client/build/compiler_flags.py

Co-authored-by: SSE4 <tomskside@gmail.com>

* Update conans/client/build/compiler_flags.py

Co-authored-by: SSE4 <tomskside@gmail.com>

* Update conans/test/unittests/client/generators/compiler_args_test.py

* Update conans/client/build/compiler_flags.py

* Use -rpath, in all tests for all platforms

* fixing tests

Co-authored-by: James <james@conan.io>
Co-authored-by: SSE4 <tomskside@gmail.com>

* modernizing tests (#8340)

* extracting some common code to base class (#8341)

* modernizing tests (#8345)

* Fix help message in command remove --outdated (#8350)

* [test] Add test creating a target without namespaces (CMake) (#8338)

* use target without namespace

* add marks

* use target from the build-module

* remove line

* build-module per generator

* revert changes in build_info

* make it explicit it is PATH

* even without build-type, compiler.runtime is different for Release/Debug

* use x64 for Windows generator

* update tests (#8354)

* added integration test for msbuild

Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
Co-authored-by: Niklas Gürtler <Erlkoenig90@users.noreply.github.com>
Co-authored-by: SSE4 <tomskside@gmail.com>
Co-authored-by: Daniel <danimanzaneque@gmail.com>
Co-authored-by: Javier G. Sogo <jgsogo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants