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

Re-enable @rpath on OS/X when using relative install prefix #1524

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

mtl1979
Copy link
Collaborator

@mtl1979 mtl1979 commented Jun 23, 2023

See #1523.

@codecov
Copy link

codecov bot commented Jun 23, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.01 🎉

Comparison is base (afd2a0c) 83.88% compared to head (053bbcc) 83.90%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1524      +/-   ##
===========================================
+ Coverage    83.88%   83.90%   +0.01%     
===========================================
  Files          132      132              
  Lines        10841    10841              
  Branches      2792     2792              
===========================================
+ Hits          9094     9096       +2     
+ Misses        1048     1046       -2     
  Partials       699      699              
Flag Coverage Δ
macos_clang 42.97% <ø> (ø)
macos_gcc 73.69% <ø> (ø)
ubuntu_clang 82.53% <ø> (ø)
ubuntu_clang_debug 82.16% <ø> (ø)
ubuntu_clang_inflate_allow_invalid_dist 81.95% <ø> (-0.23%) ⬇️
ubuntu_clang_inflate_strict 82.52% <ø> (ø)
ubuntu_clang_mmap 82.85% <ø> (ø)
ubuntu_clang_pigz 14.16% <ø> (-0.06%) ⬇️
ubuntu_clang_pigz_no_optim 11.61% <ø> (ø)
ubuntu_clang_pigz_no_threads 14.03% <ø> (+0.05%) ⬆️
ubuntu_clang_reduced_mem 82.93% <ø> (ø)
ubuntu_clang_toolchain_riscv ∅ <ø> (∅)
ubuntu_gcc 75.32% <ø> (ø)
ubuntu_gcc_aarch64 77.43% <ø> (ø)
ubuntu_gcc_aarch64_compat_no_opt 75.71% <ø> (?)
ubuntu_gcc_aarch64_no_acle 76.24% <ø> (ø)
ubuntu_gcc_aarch64_no_neon 76.24% <ø> (ø)
ubuntu_gcc_armhf 77.50% <ø> (ø)
ubuntu_gcc_armhf_compat_no_opt 75.68% <ø> (ø)
ubuntu_gcc_armhf_no_acle 77.45% <ø> (ø)
ubuntu_gcc_armhf_no_neon 77.35% <ø> (ø)
ubuntu_gcc_armsf 74.82% <ø> (ø)
ubuntu_gcc_armsf_compat_no_opt 74.28% <ø> (ø)
ubuntu_gcc_benchmark 73.72% <ø> (ø)
ubuntu_gcc_compat_no_opt 76.88% <ø> (+0.01%) ⬆️
ubuntu_gcc_compat_sprefix 73.75% <ø> (ø)
ubuntu_gcc_m32 73.38% <ø> (ø)
ubuntu_gcc_mingw_i686 73.60% <ø> (ø)
ubuntu_gcc_mingw_x86_64 73.76% <ø> (ø)
ubuntu_gcc_mips 75.07% <ø> (ø)
ubuntu_gcc_mips64 75.08% <ø> (ø)
ubuntu_gcc_no_avx2 74.35% <ø> (ø)
ubuntu_gcc_no_ctz 74.81% <ø> (ø)
ubuntu_gcc_no_ctzll 74.80% <ø> (ø)
ubuntu_gcc_no_pclmulqdq 74.34% <ø> (ø)
ubuntu_gcc_no_sse2 74.55% <ø> (-0.06%) ⬇️
ubuntu_gcc_no_sse42 74.79% <ø> (+0.55%) ⬆️
ubuntu_gcc_o1 74.18% <ø> (ø)
ubuntu_gcc_osb ∅ <ø> (∅)
ubuntu_gcc_pigz 38.34% <ø> (-0.03%) ⬇️
ubuntu_gcc_pigz_aarch64 39.22% <ø> (+0.02%) ⬆️
ubuntu_gcc_ppc 74.08% <ø> (ø)
ubuntu_gcc_ppc64 74.51% <ø> (ø)
ubuntu_gcc_ppc64_power9 74.69% <ø> (ø)
ubuntu_gcc_ppc64le 74.52% <ø> (ø)
ubuntu_gcc_ppc64le_novsx 74.89% <ø> (ø)
ubuntu_gcc_ppc64le_power9 74.46% <ø> (ø)
ubuntu_gcc_ppc_no_power8 74.77% <ø> (ø)
ubuntu_gcc_s390x 74.96% <ø> (ø)
ubuntu_gcc_s390x_dfltcc 72.03% <ø> (ø)
ubuntu_gcc_s390x_dfltcc_compat 74.04% <ø> (ø)
ubuntu_gcc_s390x_no_crc32 74.75% <ø> (ø)
ubuntu_gcc_sparc64 74.89% <ø> (ø)
ubuntu_gcc_sprefix 73.40% <ø> (ø)
win64_gcc 74.14% <ø> (ø)
win64_gcc_compat_no_opt 74.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mtl1979 mtl1979 force-pushed the mac-rpath branch 26 times, most recently from e53b637 to 15414eb Compare June 23, 2023 09:31
@mtl1979 mtl1979 marked this pull request as ready for review June 23, 2023 10:01
@@ -963,8 +963,15 @@ else()
set(PC_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
endif()

if(APPLE)
option(WITH_RPATH "Enable RPATH for shared library" OFF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have an option? Just allow it always.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it would break installation to system directory. You can't just change CMAKE_INSTALL_LIBDIR to alter RPATH, because the default might match the new value as it's not guaranteed to be absolute path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an option allows backwards compatibility (if someone depended on this). But I think that default should be ON.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with having it ON by default is that there is no way to recover the full RPATH from the information in the cache because the cache isn't built at this stage yet... so the RPATH would be incorrect. With configure there is no issue as we don't use cache at all.

It's a lot more common for the CMAKE_INSTALL_LIBDIR to contain just lib than to contain full path like /usr/local/lib. As there is no cache yet, we can't use CMAKE_INSTALL_FULL_LIBDIR to determine what the full path would be, as it isn't updated before first install() call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ITK, we will want to use RPATH by default. I assume the problem with @kislinsk's suggestion (remove custom code) is that configure has slightly different behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that cmake doesn't like relative paths, so ./lib must be specified as /lib even though the two refer to two distinct paths.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem pretty cludgy, but I guess if anyone knows of a cleaner way to do this, they can open a PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmake has a lot more limitations than configure script and I'm pretty sure cmake developers are not going to fix every limitation that is by design. I tried whole night different options and either it failed CI tests, or it didn't work as expected.

Only limitation in configure script and its Makefiles affecting this PR is that DESTDIR must end with `/´, otherwise relative paths don't work at all...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradking Do you have some suggestion for CMake build system?

Copy link
Contributor

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on a glance. Thanks for working on this.

@mtl1979
Copy link
Collaborator Author

mtl1979 commented Jun 23, 2023

Looks good on a glance. Thanks for working on this.

It wasn't easy to get working the right way as cmake doesn't support paths relative to DESTDIR... It only supports paths relative to CMAKE_INSTALL_PREFIX, which defaults to /usr/local on Unix-like systems. The trick was to prepend / to CMAKE_INSTALL_LIBDIR at the latest possible location before defining the install rules but after any rule that generates files.

@Dead2 Dead2 merged commit eace956 into zlib-ng:develop Jun 28, 2023
134 checks passed
@Dead2 Dead2 mentioned this pull request Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants