Skip to content

Commit

Permalink
patch libunwind for 16K without triggering rebuilds
Browse files Browse the repository at this point in the history
  • Loading branch information
tpwrules committed Mar 19, 2022
1 parent 4419eda commit 4c99b8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/uefi-standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ If you used the cross-compiled installer image, i.e. you downloaded the ISO from

The configuration above is the minimum required to produce a bootable system, but you can further edit the file as desired to perform additional configuration. Uncomment the relevant options and change their values as explained in the file. Note that some advertised features may not work properly at this time. Refer to the [NixOS installation manual](https://nixos.org/manual/nixos/stable/index.html#ch-configuration) for further guidance.

You can optionally choose to build the Asahi kernel with a 16K page size by enabling the appropriate option. This provides an improvement in compiler speed of 10-30%, but some important graphical software is currently incompatible, so this option is only recommended for build systems and the like. Patches to make the graphical software work are included, but compilation of it will take a long time!
You can optionally choose to build the Asahi kernel with a 16K page size by enabling the appropriate option. This provides an improvement in compiler speed of 10-30%, but some important graphical software is currently incompatible, so this option is only recommended for build systems and the like. Patches to make the graphical software work are included, but be prepared to spend some time compiling!
```
# Build the kernel with 16K pages for a performance boost with some workloads.
boot.kernelBuildIs16K = true;
Expand Down Expand Up @@ -344,7 +344,7 @@ Modify your `/etc/nixos/configuration.nix` to reference the channel instead of t
];
```

You can now update NixOS as normal. Note that M1 support module updates will generally reqiure reboots to load new kernels and other boot components:
You can now update NixOS as normal. Note that M1 support module updates will generally require reboots to load new kernels and other boot components:
```
$ sudo nix-channel --update
$ sudo nixos-rebuild switch
Expand Down
15 changes: 10 additions & 5 deletions nix/m1-support/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

nixpkgs.overlays = lib.optional config.boot.kernelBuildIs16K (self: super: {
# patch libunwind to work with dynamic pagesizes
libunwind = super.libunwind.overrideAttrs (o: {
libunwind_fixed_for_16k = super.libunwind.overrideAttrs (o: {
patches = (o.patches or []) ++ [
(self.fetchpatch {
url = "https://github.com/libunwind/libunwind/pull/330.patch";
Expand All @@ -55,6 +55,14 @@
];
});
});

# sub the fixed libunwind in for the broken copy without triggering
# horrendous rebuilds
system.replaceRuntimeDependencies = lib.optionals config.boot.kernelBuildIs16K [
{ original = pkgs.libunwind;
replacement = pkgs.libunwind_fixed_for_16k;
}
];
};

options.boot.kernelBuildIsCross = lib.mkOption {
Expand All @@ -68,10 +76,7 @@
default = false;
description = ''
Set that the Asahi Linux kernel should be built with 16K pages and various
software patched to be compatible.
WARNING: be prepared to spend a couple hours compiling if you choose a
graphical environment plus this option. You will also need >20GB RAM+swap!
software patched to be compatible. Some software may still be broken.
'';
};
}

0 comments on commit 4c99b8e

Please sign in to comment.