Skip to content

cmake: classify libraries in /usr/lib as system libraries#98565

Closed
hannesweisbach wants to merge 2 commits intoNixOS:stagingfrom
hannesweisbach:cmake
Closed

cmake: classify libraries in /usr/lib as system libraries#98565
hannesweisbach wants to merge 2 commits intoNixOS:stagingfrom
hannesweisbach:cmake

Conversation

@hannesweisbach
Copy link
Contributor

@hannesweisbach hannesweisbach commented Sep 23, 2020

Motivation for this change

This change is only relevant for App Bundle builds on macOS. For an App Bundle
every non-system runtime dependency gets copied recursively into the App Bundle
to make a standalone distributable package.
The replacement of every occurence of '/usr' by '/var/empty' by Nix thwarts App
Bundle builds, because libraries in /usr/lib do not get correctly classified as
system libraries.
This patch reverts this single path name back to '/usr/lib', so that packaging
App Bundles on macOS works. FYI: within CMake the occurence is also guarded by
an 'if(APPLE)' statement.

The substituteInPlace matches only a single line: https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/GetPrerequisites.cmake#L522
Let me know, if a proper patch is preferred instead.

Draft, because I'm still building ;)
Edit: Building the world succeeded

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. label Sep 23, 2020
@ofborg ofborg bot requested review from LnL7 and ttuegel September 23, 2020 15:15
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Sep 23, 2020
@hannesweisbach hannesweisbach marked this pull request as ready for review September 24, 2020 05:23
@SuperSandro2000
Copy link
Member

/rebase-staging

@SuperSandro2000
Copy link
Member

@hannesweisbach please rebase on staging.

@github-actions
Copy link
Contributor

@jtojnar
Copy link
Member

jtojnar commented Jan 18, 2021

Would not this make builds less hermetic on Darwin (especially when not using sandbox)?

AndersonTorres and others added 2 commits January 18, 2021 16:12
This change is only relevant for App Bundle builds on macOS. For an App Bundle
every non-system runtime dependency gets copied recursively into the App Bundle
to make a standalone distributable package.
The replacement of every occurence of '/usr' by '/var/empty' by Nix thwarts App
Bundle builds, because libraries in /usr/lib do not get correctly classified as
system libraries.
This patch reverts this single path name back to '/usr/lib', so that packaging
App Bundles on macOS works. FYI: within CMake the occurence is also guarded by
an 'if(APPLE)' statement.
@hannesweisbach
Copy link
Contributor Author

@hannesweisbach please rebase on staging.

I hope I did that right. "cimg: 2.9.1 -> 2.9.2", commit
a85ad18 had a conflict, I'm not sure why …

@ofborg ofborg bot added 6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled. 6.topic: python Python is a high-level, general-purpose programming language. 8.has: documentation This PR adds or changes documentation 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jan 18, 2021
@SuperSandro2000 SuperSandro2000 changed the base branch from master to staging January 18, 2021 22:53
@SuperSandro2000
Copy link
Member

@hannesweisbach you forgot to change the base branch. I did that for you.

configureFlags="--parallel=''${NIX_BUILD_CORES:-1} CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD $configureFlags"
''
# Detect dylibs in /usr/lib as system libraries on Darwin to correctly build App bundles
+ stdenv.lib.optionalString stdenv.isDarwin ''
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
+ stdenv.lib.optionalString stdenv.isDarwin ''
+ lib.optionalString stdenv.isDarwin ''

As per recent contributing change.

@ofborg ofborg bot removed 6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled. 6.topic: python Python is a high-level, general-purpose programming language. 8.has: documentation This PR adds or changes documentation 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. labels Jan 18, 2021
@ofborg ofborg bot requested a review from AndersonTorres January 18, 2021 23:09
@ofborg ofborg bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Jan 18, 2021
@zowoq zowoq removed their request for review January 27, 2021 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants