query
On this page

useLibsFrom

pkgs.useLibsFrom

Docs pulled from | This Revision | 10 minutes ago


Copy the libstdc++ from the model stdenv to the target stdenv.

TODO(@connorbaker): This interface provides behavior which should be revisited prior to the release of 24.05. For a more detailed explanation and discussion, see https://github.com/NixOS/nixpkgs/issues/283517.

Inputs

modelStdenv

1. Function argument

targetStdenv

2. Function argument


Noogle detected

Implementation

The following is the current implementation of this function.

useLibsFrom =
    modelStdenv: targetStdenv:
    let
      ccForLibs = modelStdenv.cc.cc;
      /**
        NOTE(@connorbaker):
        This assumes targetStdenv.cc is a cc-wrapper.
      */
      cc = targetStdenv.cc.override {
        /**
          NOTE(originally by rrbutani):
          Normally the `useCcForLibs`/`gccForLibs` mechanism is used to get a
          clang based `cc` to use `libstdc++` (from gcc).

          Here we (ab)use it to use a `libstdc++` from a different `gcc` than our
          `cc`.

          Note that this does not inhibit our `cc`'s lib dir from being added to
          cflags/ldflags (see `cc_solib` in `cc-wrapper`) but this is okay: our
          `gccForLibs`'s paths should take precedence.
        */
        useCcForLibs = true;
        gccForLibs = ccForLibs;
      };
    in
    overrideCC targetStdenv cc;