mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
packaging: Build without symbolic interposition on GCC
This turns out to be a big problem for performance of Bison generated code, that for whatever reason cannot be made internal to the shared library. This causes GCC to make a bunch of function calls go through PLT. Ideally these hot functions (like move/copy ctor) could become inline in upstream Bison. That will make sure that GCC can do interprocedular optimizations without -fno-semantic-interposition [^]. Considering that LLVM already does inlining and whatnot is a good motivation for this change. I don't know of any case where Nix relies on LD_PRELOAD tricks for the shared libraries in production use-cases. [^]: https://maskray.me/blog/2021-05-09-fno-semantic-interposition
This commit is contained in:
parent
a8715a2d6e
commit
c1f805b856
1 changed files with 18 additions and 0 deletions
|
|
@ -164,6 +164,24 @@ let
|
|||
};
|
||||
|
||||
mesonLibraryLayer = finalAttrs: prevAttrs: {
|
||||
preConfigure =
|
||||
let
|
||||
interpositionFlags = [
|
||||
"-fno-semantic-interposition"
|
||||
"-Wl,-Bsymbolic-functions"
|
||||
];
|
||||
in
|
||||
# NOTE: By default GCC disables interprocedular optimizations (in particular inlining) for
|
||||
# position-independent code and thus shared libraries.
|
||||
# Since LD_PRELOAD tricks aren't worth losing out on optimizations, we disable it for good.
|
||||
# This is not the case for Clang, where inlining is done by default even without -fno-semantic-interposition.
|
||||
# https://reviews.llvm.org/D102453
|
||||
# https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup
|
||||
prevAttrs.preConfigure or ""
|
||||
+ lib.optionalString stdenv.cc.isGNU ''
|
||||
export CFLAGS="''${CFLAGS:-} ${toString interpositionFlags}"
|
||||
export CXXFLAGS="''${CXXFLAGS:-} ${toString interpositionFlags}"
|
||||
'';
|
||||
outputs = prevAttrs.outputs or [ "out" ] ++ [ "dev" ];
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue