tree-wide: enable LTO on Darwin

This commit is contained in:
Randy Eckenrode 2024-07-17 23:10:56 -04:00
parent 0d7d9280d3
commit d5f637590e
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9
24 changed files with 8 additions and 88 deletions

View File

@ -34,7 +34,6 @@ stdenv.mkDerivation rec {
postPatch = ''
# needs special setup on Linux, dunno if it can work on Darwin
# https://github.com/NixOS/nixpkgs/issues/19098
sed -i -e '/juce::juce_recommended_lto_flags/d' Source/CMakeLists.txt
'';

View File

@ -49,7 +49,6 @@ stdenv.mkDerivation rec {
postPatch = ''
# 1. Remove hardcoded LTO flags: needs extra setup on Linux,
# possibly broken on Darwin
# https://github.com/NixOS/nixpkgs/issues/19098
# 2. Disable automatic copying of built plugins during buildPhase, it defaults
# into user home and we want to have building & installing separated.
sed -i \

View File

@ -61,7 +61,6 @@ stdenv.mkDerivation (finalAttrs: {
postPatch = lib.optionalString (stdenv.isLinux) ''
# needs special setup on Linux, dunno if it can work on Darwin
# https://github.com/NixOS/nixpkgs/issues/19098
# Also, I get issues with linking without that, not sure why
sed -i -e '/juce::juce_recommended_lto_flags/d' CMakeLists.txt
patchShebangs linux/install.sh

View File

@ -18,12 +18,8 @@ stdenv.mkDerivation rec {
postPatch = lib.optionalString stdenv.isDarwin ''
# Replace hardcoded g++ with c++ so clang can be used
# on darwin
#
# lto must be disabled on darwin as well due to
# https://github.com/NixOS/nixpkgs/issues/19098
substituteInPlace Makefile \
--replace-fail 'g++' 'c++' \
--replace-fail '-flto' ""
--replace-fail 'g++' 'c++'
'';
installPhase = ''

View File

@ -19,9 +19,6 @@ stdenv.mkDerivation rec {
hash = "sha256-ZptjlnOiF+hKuKYvBFJL95H5YQuR99d4biOco/MVEmE=";
};
# work around https://github.com/NixOS/nixpkgs/issues/19098
env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && stdenv.isDarwin) "-fno-lto";
nativeBuildInputs = [ wrapQtAppsHook qmake ];
buildInputs = [ qtbase qtdeclarative qtquickcontrols ];

View File

@ -41,10 +41,6 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
#link-time optimization fails on darwin
#see https://github.com/NixOS/nixpkgs/issues/19098
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-fno-lto";
postPatch = ''
# Fix gcc-13 build failure due to missing includes:
sed -e '1i #include <cstdint>' -i \

View File

@ -38,10 +38,7 @@ stdenv.mkDerivation rec {
makeFlags = [ "PREFIX=$(out)" ]
++ lib.optional enableSDL "USE_SDL=2" # Use SDL2 instead of SDL1
++ lib.optional (!enableSDL && !enableX11) "USE_FB=0"
# work around https://github.com/NixOS/nixpkgs/issues/19098
++ lib.optional (stdenv.cc.isClang && stdenv.isDarwin) "CFLAGS=-fno-lto";
++ lib.optional (!enableSDL && !enableX11) "USE_FB=0";
meta = with lib; {
homepage = "https://github.com/LekKit/RVVM";

View File

@ -56,9 +56,7 @@ stdenv.mkDerivation rec {
# ../../../server/TracyView.cpp:649:34, preventing building.
++ lib.optional stdenv.isDarwin "-Wno-format-security"
++ lib.optional stdenv.isLinux "-ltbb"
++ lib.optional stdenv.cc.isClang "-faligned-allocation"
# workaround issue #19098
++ lib.optional (stdenv.cc.isClang && stdenv.isDarwin) "-fno-lto");
++ lib.optional stdenv.cc.isClang "-faligned-allocation");
buildPhase = ''
runHook preBuild

View File

@ -4,7 +4,7 @@
, cmake
, coreutils
, libxml2
, lto ? !stdenv.isDarwin
, lto ? true
, makeWrapper
, openssl
, pcre2

View File

@ -14,7 +14,6 @@ stdenv.mkDerivation rec {
postPatch = ''
patchShebangs --host src/bison.sh
'';
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-fno-lto";
installFlags = [ "PREFIX=${placeholder "out"}" ];
meta = with lib; {

View File

@ -70,8 +70,7 @@
, enableNoSemanticInterposition ? true
# enabling LTO on 32bit arch causes downstream packages to fail when linking
# enabling LTO on *-darwin causes python3 to fail when linking.
, enableLTO ? stdenv.is64bit && stdenv.isLinux
, enableLTO ? stdenv.isDarwin || (stdenv.is64bit && stdenv.isLinux)
# enable asserts to ensure the build remains reproducible
, reproducibleBuild ? false
@ -159,7 +158,7 @@ let
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
buildPackages.stdenv.cc
pythonOnBuildForHost
] ++ optionals (stdenv.cc.isClang && (!stdenv.hostPlatform.useAndroidPrebuilt or false) && (enableLTO || enableOptimizations)) [
] ++ optionals (stdenv.cc.isClang && !stdenv.isDarwin && (!stdenv.hostPlatform.useAndroidPrebuilt or false) && (enableLTO || enableOptimizations)) [
stdenv.cc.cc.libllvm.out
];

View File

@ -27,9 +27,6 @@ stdenv.mkDerivation {
ninja
];
# LTO does not work on Darwin: https://github.com/NixOS/nixpkgs/issues/19098
mesonFlags = lib.optionals stdenv.isDarwin [ "-Db_lto=false" ];
meta = with lib; {
description = "LC3 (Low Complexity Communication Codec) is an efficient low latency audio codec";
homepage = "https://github.com/google/liblc3";

View File

@ -10,7 +10,7 @@
# requiring to build a special variant for that software. Example: 'haproxy'
, variant ? "all"
, extraConfigureFlags ? []
, enableLto ? !(stdenv.isDarwin || stdenv.hostPlatform.isStatic || stdenv.cc.isClang)
, enableLto ? !(stdenv.hostPlatform.isStatic || stdenv.cc.isClang)
}:
stdenv.mkDerivation (finalAttrs: {
pname = "wolfssl-${variant}";

View File

@ -45,11 +45,6 @@ buildPythonPackage rec {
# remove circular dependency cocotb-bus from setup.py
substituteInPlace setup.py --replace "'cocotb-bus<1.0'" ""
''
+ lib.optionalString stdenv.isDarwin ''
# disable lto on darwin
# https://github.com/NixOS/nixpkgs/issues/19098
substituteInPlace cocotb_build_libs.py --replace "-flto" ""
'';
patches = [

View File

@ -37,12 +37,6 @@ buildPythonPackage rec {
buildInputs = [ rapidfuzz-cpp ];
env.NIX_CFLAGS_COMPILE = toString (
lib.optionals (stdenv.cc.isClang && stdenv.isDarwin) [
"-fno-lto" # work around https://github.com/NixOS/nixpkgs/issues/19098
]
);
dependencies = [ rapidfuzz ];
nativeCheckInputs = [ pytestCheckHook ];

View File

@ -1,15 +0,0 @@
diff --git a/nuitka/build/SconsCompilerSettings.py b/nuitka/build/SconsCompilerSettings.py
index 319b72c4e..89d40f2a2 100644
--- a/nuitka/build/SconsCompilerSettings.py
+++ b/nuitka/build/SconsCompilerSettings.py
@@ -173,8 +173,8 @@ def _enableLtoSettings(
lto_mode = False
reason = "known to be not supported (CondaCC)"
elif isMacOS() and env.gcc_mode and env.clang_mode:
- lto_mode = True
- reason = "known to be supported (macOS clang)"
+ lto_mode = False
+ reason = "known to not be supported (macOS nix clang)"
elif env.mingw_mode and env.clang_mode:
lto_mode = False
reason = "known to not be supported (new MinGW64 Clang)"

View File

@ -23,9 +23,6 @@ buildPythonPackage rec {
hash = "sha256-nKdCMgA92v9VsSgfktXDbSh3DyKsGlcTjpn0Y7u4rxU=";
};
# default lto off for darwin
patches = [ ./darwin-lto.patch ];
build-system = [
setuptools
wheel

View File

@ -59,12 +59,6 @@ buildPythonPackage rec {
export CMAKE_ARGS="-DCMAKE_CXX_COMPILER_AR=$AR -DCMAKE_CXX_COMPILER_RANLIB=$RANLIB"
'';
env.NIX_CFLAGS_COMPILE = toString (
lib.optionals (stdenv.cc.isClang && stdenv.isDarwin) [
"-fno-lto" # work around https://github.com/NixOS/nixpkgs/issues/19098
]
);
passthru.optional-dependencies = {
full = [ numpy ];
};

View File

@ -783,10 +783,7 @@ in
substituteInPlace lib/sassc/native.rb \
--replace 'gem_root = spec.gem_dir' 'gem_root = File.join(__dir__, "../../")'
'';
} // (lib.optionalAttrs stdenv.isDarwin {
# https://github.com/NixOS/nixpkgs/issues/19098
buildFlags = [ "--disable-lto" ];
});
};
sass-embedded = attrs: {
# Patch the Rakefile to use our dart-sass and not try to fetch anything.

View File

@ -83,9 +83,6 @@ in stdenv.mkDerivation (finalAttrs: {
makeFlags = [
"SDLCONFIG=${SDL2}/bin/sdl2-config"
] ++ lib.optionals stdenv.isDarwin [
# broken, see: https://github.com/NixOS/nixpkgs/issues/19098
"LTO=0"
];
buildFlags = [

View File

@ -30,12 +30,6 @@ stdenv.mkDerivation rec {
sha256 = "sha256-ASy2vIP94lnSKgxixK1GoC84yAysaJpxeyuggV4MrP4=";
};
# This addresses a linker issue with Darwin
# https://github.com/NixOS/nixpkgs/issues/19098
preBuild = lib.optionalString stdenv.isDarwin ''
sed -i.orig '/^\#\#\# 3.*Link Time Optimization/,/^\#\#\# 3/d' Makefile
'';
postUnpack = ''
sourceRoot+=/src
echo ${nnue}

View File

@ -30,9 +30,6 @@ tcl.mkTclDerivation rec {
'';
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin (toString [
# Disable clang link time optimization until the following issue is resolved:
# https://github.com/NixOS/nixpkgs/issues/19098
"-fno-lto"
# On Darwin setenv and unsetenv are defined in stdlib.h from libSystem
"-DHAVE_SETENV"
"-DHAVE_UNSETENV"

View File

@ -188,7 +188,6 @@ stdenv.mkDerivation {
mesonFlags =
[
# LTO optimization
(lib.mesonBool "b_lto" (!stdenv.isDarwin))
(lib.mesonEnable "gc" true)
(lib.mesonBool "enable-tests" true)
(lib.mesonBool "enable-docs" enableDocumentation)

View File

@ -13,11 +13,6 @@ stdenv.mkDerivation rec {
buildInputs = [ oniguruma ] ++ lib.optionals stdenv.isLinux [ libcap acl liburing ];
# Disable LTO on darwin. See https://github.com/NixOS/nixpkgs/issues/19098
preConfigure = lib.optionalString stdenv.isDarwin ''
substituteInPlace GNUMakefile --replace "-flto=auto" ""
'';
makeFlags = [ "PREFIX=$(out)" ];
buildFlags = [ "release" ]; # "release" enables compiler optimizations