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

gcc: Fix manpage symlinks when architecture tuples are prefixed to the file name #92704

merged 1 commit into from Oct 25, 2020


Copy link

@iamthememory iamthememory commented Jul 8, 2020

Motivation for this change

In some cases, building gcc generates the binaries and manpages prefixed with their architecture tuples, such as armv6l-unknown-linux-gnueabihf-gcc and armv6l-unknown-linux-gnueabihf-g++.1. One of these cases is building cross compilers like in the following:

  pkgs = import <nixpkgs> {
    crossSystem = (import <nixpkgs/lib>).systems.examples.raspberryPi;

Currently, the gcc builder creates a g++.1 -> gcc.1 symlink to save space, since g++.1 and gcc.1 have the same contents, but in such cases where the architecture tuple is included in the manpage name, this creates a broken symlink (which, coincidentally, leads to file collisions when attempting to add a cross-compiler and native gcc to a home-manager profile or similar). In such cases, .../share/man/man1 ends up containing a broken symlink like this:

total 720
-r--r--r-- 25 root root  13604 Dec 31  1969 armv6l-unknown-linux-gnueabihf-cpp.1.gz
-r--r--r-- 28 root root 335497 Dec 31  1969 armv6l-unknown-linux-gnueabihf-g++.1.gz
-r--r--r-- 28 root root 335497 Dec 31  1969 armv6l-unknown-linux-gnueabihf-gcc.1.gz
-r--r--r-- 25 root root  11318 Dec 31  1969 armv6l-unknown-linux-gnueabihf-gcov.1.gz
-r--r--r-- 25 root root   2517 Dec 31  1969 armv6l-unknown-linux-gnueabihf-gcov-dump.1.gz
-r--r--r-- 25 root root   4056 Dec 31  1969 armv6l-unknown-linux-gnueabihf-gcov-tool.1.gz
lrwxrwxrwx  4 root root      5 Dec 31  1969 g++.1 -> gcc.1

This pull request should fix the way the symlink is created to handle the normal situation without any arch tuples prefixing the file, with arch prefixes, and, since I wasn't sure about any other corner cases, it also handles if there are both a prefixed and non-prefixed manpage or if there aren't any manpages.

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
In some cases, such as when building cross compilers, the binaries and
manpages contain the target architecture tuple, such as

Ensure the symlink created to save space with the duplicated manpage
(`g++.1 -> gcc.1`) properly handles such cases and generates symlinks
such as `i686-w64-mingw32-g++.1 -> i686-w64-mingw32-gcc.1`.
Previously in such cases, a broken `gcc.1` link would be created
@vcunat vcunat merged commit 5aca349 into NixOS:master Oct 25, 2020
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants