Skip to content

lib.systems: introduce hasSharedLibraries#240575

Merged
2 commits merged intomasterfrom
unknown repository
Jul 12, 2023
Merged

lib.systems: introduce hasSharedLibraries#240575
2 commits merged intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Jun 29, 2023

Description of changes

This PR adds hasSharedLibraries to lib.systems, and causes gcc to use hasSharedLibraries instead of !isStatic as the default for enableShared.

Motivation

See #238154 for a concrete example.

We need plat.hasSharedLibraries in order to know whether or not to expect gcc (and many other tools) to emit shared libraries (like libgcc_s.so). Many of the GNU build scripts are smart enough that if you configure them with --enable-shared on a platform (such as arm-none-eabi) that doesn't support dynamic linking, they will simply skip the shared libraries instead of aborting the configurePhase. Unfortunately the missing shared libraries in the final build product cause very hard-to-troubleshoot problems later on. So we need something in lib.systems that knows whether or not to expect these shared libraries to appear (and, if they won't appear, to not get upset about that).

The alternative to introducing hasSharedLibraries would be to set isStatic in these situations. However doing so causes make-derivation.nix to insert -static between the pname and hostPlatform suffix, which is undesirable.

If at some point in the future we eliminate the -static suffix, then hasSharedLibraries can be made equal to !isStatic.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@ghost ghost requested review from Ericson2314, alyssais and matthewbauer as code owners June 29, 2023 18:06
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Jun 29, 2023
@ghost
Copy link
Copy Markdown
Author

ghost commented Jun 29, 2023

This PR causes a rebuild of arm-none-eabi because it adds an explicit --disable-shared flag to the ./configure invocation for that platform instead of letting gcc figure that out on its own.

These 48 packages are rebuilt:
aarch64-linux	ubootPine64LTS
aarch64-linux	spike
x86_64-linux	nixos-install-tools
aarch64-linux	qmk
x86_64-linux	simavr
aarch64-linux	armTrustedFirmwareRK3328
aarch64-linux	ubootOrangePiZeroPlus2H5
aarch64-linux	ubootOdroidC2
aarch64-linux	ubootOlimexA64Olinuxino
aarch64-darwin	qmk
aarch64-linux	gnuk
aarch64-linux	ubootNanoPCT4
aarch64-linux	armTrustedFirmwareAllwinner
x86_64-linux	klipper-firmware
x86_64-linux	armTrustedFirmwareTools
aarch64-darwin	simavr
aarch64-linux	ubootRockPro64
x86_64-linux	tinygo
aarch64-linux	ubootROCPCRK3399
aarch64-linux	klipper-firmware
aarch64-linux	armTrustedFirmwareAllwinnerH616
aarch64-linux	ubootPinebook
x86_64-darwin	tinygo
x86_64-linux	tests.nixos-functions.nixos-test
aarch64-linux	ubootSopine
aarch64-linux	ubootOrangePiZero2
aarch64-linux	ubootPine64
aarch64-linux	armTrustedFirmwareS905
x86_64-linux	gnuk
x86_64-darwin	qmk
aarch64-linux	ubootOrangePi3
x86_64-linux	klipper-genconf
aarch64-linux	ubootPinebookPro
aarch64-linux	nixos-install-tools
aarch64-linux	tinygo
aarch64-linux	ubootBananaPim64
aarch64-linux	armTrustedFirmwareAllwinnerH6
aarch64-linux	ubootRock64
x86_64-linux	spike
aarch64-linux	armTrustedFirmwareRK3399
x86_64-darwin	simavr
aarch64-linux	armTrustedFirmwareQemu
x86_64-linux	fusee-launcher
aarch64-linux	ubootRockPi4
aarch64-linux	simavr
x86_64-linux	qmk
x86_64-linux	klipper-flash
aarch64-darwin	tinygo

Adam Joseph added 2 commits July 1, 2023 13:12
This commit adds `hasSharedLibraries` to `lib.systems`.

We need `plat.hasSharedLibraries` in order to know whether or not to
expect `gcc` (and many other tools) to emit shared libraries (like
`libgcc_s.so`).  Many of the GNU build scripts are smart enough that
if you configure them with `--enable-shared` on a platform (such as
`arm-none-eabi`) that doesn't support dynamic linking, they will
simply skip the shared libraries instead of aborting the
`configurePhase`.  Unfortunately the missing shared libraries in the
final build product cause very hard-to-troubleshoot problems later
on.

The alternative to introducing `hasSharedLibraries` would be to set
`isStatic` in these situations.  However doing so causes
`make-derivation.nix` to insert `-static` between the `pname` and
`hostPlatform` suffix, which is undesirable.

If at some point in the future we eliminate the `-static` suffix,
then `hasSharedLibraries` can be made equal to `!isStatic`.
@roberth roberth added the 6.topic: lib The Nixpkgs function library label Jul 8, 2023
@ghost ghost merged commit e41f217 into NixOS:master Jul 12, 2023
@ghost ghost deleted the pr/stdenv/hasSharedLibraries branch January 23, 2024 06:50
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant