lib.systems: introduce hasSharedLibraries #240575
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes
This PR adds
hasSharedLibraries
tolib.systems
, and causesgcc
to usehasSharedLibraries
instead of!isStatic
as the default forenableShared
.Motivation
See #238154 for a concrete example.
We need
plat.hasSharedLibraries
in order to know whether or not to expectgcc
(and many other tools) to emit shared libraries (likelibgcc_s.so
). Many of the GNU build scripts are smart enough that if you configure them with--enable-shared
on a platform (such asarm-none-eabi
) that doesn't support dynamic linking, they will simply skip the shared libraries instead of aborting theconfigurePhase
. Unfortunately the missing shared libraries in the final build product cause very hard-to-troubleshoot problems later on. So we need something inlib.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 setisStatic
in these situations. However doing so causesmake-derivation.nix
to insert-static
between thepname
andhostPlatform
suffix, which is undesirable.If at some point in the future we eliminate the
-static
suffix, thenhasSharedLibraries
can be made equal to!isStatic
.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)