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

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

Closed
wants to merge 2 commits into from

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.

@SuperSandro2000
Copy link
Member

/rebase-staging

@SuperSandro2000
Copy link
Member

@hannesweisbach please rebase on staging.

@github-actions
Copy link
Contributor

@jtojnar
Copy link
Contributor

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 …

@SuperSandro2000
Copy link
Member

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

@@ -70,6 +70,12 @@ stdenv.mkDerivation rec {
# CC_FOR_BUILD and CXX_FOR_BUILD are used to bootstrap cmake
+ ''
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.

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.

None yet

4 participants