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

[backport: 20.09] darwin (Big Sur): tbd based stdenv #105799

Closed

Conversation

davidtwco
Copy link
Member

Motivation for this change

This PR backports #98541 to 20.09. This is helpful for projects using NixOps that have a pinned nixpkgs commit to a stable NixOS release, in that circumstance, developers using Big Sur can't enter the nix-shell without these changes.

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

While I was working on pyobjc I needed the two commits below to to build some things. I am not sure we should backport such major change to a stable version. Big Sur has probably more bugs and telling them to use the unstable channel until 21.XX is out is probably less hassle.

79f3fa3
0cc95f6

@davidtwco
Copy link
Member Author

I am not sure we should backport such major change to a stable version. Big Sur has probably more bugs and telling them to use the unstable channel until 21.XX is out is probably less hassle.

I think there's enough value in having a stable branch which can be pinned by projects and have those projects still be usable on Big Sur to justify this backport.

@matthewbauer
Copy link
Member

We usually don't backport big stdenv changes like this. However, since Big Sur is pretty much broken without it, I think it's probably a good idea in this case.

@LnL7
Copy link
Member

LnL7 commented Dec 3, 2020

I would definitively like to backport the fixes, we can test for regressions with a wip jobset to make sure nothing important was missed. However I think it would be best to wait until bootstrapping and some of the missing stubs are sorted out.

@LnL7 LnL7 added this to Big Sur in Darwin Dec 17, 2020
@chessai
Copy link
Member

chessai commented Dec 17, 2020

Agreed, Big Sur breakage is too big a deal to not backport IMO

@jonringer
Copy link
Contributor

If someone is able to verify that there's no regressions, I'm fine with merging this. But it should target staging-20.09

LnL7 and others added 10 commits January 7, 2021 16:52
This new version has tapi support, which is needed to build the new
stubs based libSystem, etc. and Big Sur support.

You can verify the provenance of these yourself by checking Hydra here:
https://hydra.nixos.org/build/128192471
Adapted from main expression for clang 7.
Build the llvm support libraries (libcxx, libcxxabi) from scratch
without using the existing llvm libraries. This is the same spirit and
similar implementation as the "useLLVM" bootstrap in llvm package
sets. Critically it avoids having libcxxabi provided by the cc-wrapper
when building libcxx, which otherwise results in two libcxxabi
instances.

$ otool -L /nix/store/vd4vvgs9xngqbjzpg3qc41wl6jh42s9i-libc++-7.1.0/lib/libc++.dylib
/nix/store/vd4vvgs9xngqbjzpg3qc41wl6jh42s9i-libc++-7.1.0/lib/libc++.dylib:
        /nix/store/vd4vvgs9xngqbjzpg3qc41wl6jh42s9i-libc++-7.1.0/lib/libc++.1.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /nix/store/gmpwk5fyp3iasppqrrdpswxvid6kcp8r-libc++abi-7.1.0/lib/libc++abi.dylib (compatibility version 1.0.0, current version 1.0.0)
        /nix/store/3hn7azynqgp2pm5gpdg45gpq0ia72skg-libc++abi-7.1.0/lib/libc++abi.dylib (compatibility version 1.0.0, current version 1.0.0)
        /nix/store/1nq94scbxs6bk7pimqhvz76q6cfmbv97-Libsystem-osx-10.12.6/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

Additionally move some utilities (clang, binutils, coreutils, gnugrep)
to the stage layers so they can be replaced before the final
stdenv. This should cause most of stage4 to be built from the
toolchain assembled as of stage3 instead of the bootstrap toolchain.
Exposed by the tbd stubs which contains fat libraries. The previously
used proxy libraries were x86_64 only.
Used during bootstrap to check that re-exported libraries are not
dangling.
@davidtwco davidtwco changed the base branch from release-20.09 to staging-20.09 January 7, 2021 17:00
@davidtwco
Copy link
Member Author

I've rebased this onto staging-20.09 as requested, and included #107013.

@phile314
Copy link
Contributor

Is there anything that can be done to help getting this merged? If there is anything to test, how do I best test it?

@jonringer
Copy link
Contributor

Is there anything that can be done to help getting this merged? If there is anything to test, how do I best test it?

building the major packages would be a good start, but as I don't have access to darwin hardware (and doing anything else is technically illegal), it's up to @NixOS/darwin-maintainers to merge this.

@jonringer
Copy link
Contributor

@SuperSandro2000 if you could build some of the more major packages, I'm assuming this is good as unstable seems to be fine. However, we could be missing a PR which is correcting unstable behavior.

@@ -41,6 +41,11 @@ stdenv.mkDerivation rec {
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ stdenv.lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.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.optionals (stdenv.hostPlatform.isDarwin) [
] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [

stdenv.lib is deprecated.

Comment on lines +25 to +26
stdenv.lib.optional standalone "-DLLVM_ENABLE_LIBCXX=ON" ++
stdenv.lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF";
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.optional standalone "-DLLVM_ENABLE_LIBCXX=ON" ++
stdenv.lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF";
lib.optional standalone "-DLLVM_ENABLE_LIBCXX=ON" ++
lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF";


stdenv.mkDerivation {
name = "print-reexports";
src = stdenv.lib.sourceFilesBySuffices ./. [".c"];
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
src = stdenv.lib.sourceFilesBySuffices ./. [".c"];
src = lib.sourceFilesBySuffices ./. [".c"];

@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Jan 19, 2021

@SuperSandro2000 if you could build some of the more major packages, I'm assuming this is good as unstable seems to be fine. However, we could be missing a PR which is correcting unstable behavior.

I am against backporting any of these major stdenv changes to 20.09. If you are using Big Sur you either need to wait for 21.05 or use unstable until then. Any of those changes could break a lot and the Darwin maintainers are rare currently so I don't want to deal with any of the potential bugs.

I can try to build a few packages but rebuilding stdenv never worked for me so I expect it to fail. Also I am not on Big Sur and I do not plan to update to it anytime soon.

@domenkozar
Copy link
Member

Note that a lot of macOS users do update their OS and this completely breaks their system currently on 20.09, so having fewer packages to work is better than zero.

@jonringer
Copy link
Contributor

jonringer commented Jan 19, 2021

if any bigsur user wants to help this along, you can run a nixpkgs review of all the channel blockers and a package from most of the toolchains

nixpkgs-review pr 105799 \
  --package ripgrep \
  --package python3Packages.requests \
  --package direnv \
  --package vim \
  --package pandoc \
  --package postgresql \
  --package mariadb \
  --package cabal2nix \
  --package openssh \
  --package git \
  --package ruby \
  --package cachix \
  --package gimp \
  --package emacs \
  --package nix \
  --package python \
  --package wireshark \
  --package transmission-gtk

@SuperSandro2000
Copy link
Member

if any bigsur user wants to help this along, you can run a nixpkgs review of all the channel blockers and a package from most of the toolchains

The problem with this is that nixpkgs-review activates the sandbox which prevents rebuilds of stdenv on darwin.

@jonringer
Copy link
Contributor

The problem with this is that nixpkgs-review activates the sandbox which prevents rebuilds of stdenv on darwin.

Oh.... that's awkward. And I was not aware of this.

Guess I'm just having it easy in purity land.

@MarcoPolo
Copy link
Contributor

Is there a way to disable the sandbox?

I have a Big Sur machine handy. Anything I can do to help?

@SuperSandro2000
Copy link
Member

Is there a way to disable the sandbox?

For nixpkgs-review. Not currently but I am talking to @Mic92 to solve this.

I have a Big Sur machine handy. Anything I can do to help?

You can try building this PR and see if it even works.

@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Jan 19, 2021

Tried building python3 without sandbox:

checking build system type... x86_64-apple-darwin19.6.0
checking host system type... x86_64-apple-darwin19.6.0
checking for a BSD-compatible install... /nix/store/ai232lgqxzkhwl0zd3pvprj3hdgab6v6-coreutils-8.31/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /nix/store/ai232lgqxzkhwl0zd3pvprj3hdgab6v6-coreutils-8.31/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/r4/k85s52jx3555ckj0wty615s00000gp/T/nix-build-expat-2.2.8.drv-0/expat-2.2.8':
configure: error: C compiler cannot create executables
See `config.log' for more details
builder for '/nix/store/w4yqg2rch50rqpwqh1pz94863hbzi0iv-expat-2.2.8.drv' failed with exit code 77
cannot build derivation '/nix/store/bd1523xydp5mndb0d5qk8qw6vnsf8mbc-python3-3.8.5.drv': 1 dependencies couldn't be built
error: build of '/nix/store/bd1523xydp5mndb0d5qk8qw6vnsf8mbc-python3-3.8.5.drv' failed

@davidtwco davidtwco closed this Jan 20, 2021
@MarcoPolo
Copy link
Contributor

Yep, failed at the same spot as Sandro on Big Sur.

@davidtwco davidtwco deleted the backport-20.09-big-sur-tbd branch June 18, 2022 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Darwin
  
Big Sur
Development

Successfully merging this pull request may close these issues.

None yet

10 participants