Merge pull request #328586 from reckenrode/darwin-lto

tree-wide: enable LTO on Darwin
This commit is contained in:
Randy Eckenrode
2024-07-20 03:30:43 -04:00
committed by GitHub
24 changed files with 12 additions and 91 deletions
@@ -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
'';
-1
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 \
@@ -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
@@ -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 = ''
@@ -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 ];
@@ -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 \
@@ -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";
+1 -3
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
+1 -1
View File
@@ -4,7 +4,7 @@
, cmake
, coreutils
, libxml2
, lto ? !stdenv.isDarwin
, lto ? true
, makeWrapper
, openssl
, pcre2
@@ -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; {
@@ -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
];
@@ -406,9 +405,6 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
configureFlags = [
"--without-ensurepip"
"--with-system-expat"
] ++ optionals (!(stdenv.isDarwin && pythonAtLeast "3.12")) [
# ./Modules/_decimal/_decimal.c:4673:6: error: "No valid combination of CONFIG_64, CONFIG_32 and _PyHASH_BITS"
# https://hydra.nixos.org/build/248410479/nixlog/2/tail
"--with-system-libmpdec"
] ++ optionals (openssl != null) [
"--with-openssl=${openssl.dev}"
@@ -480,6 +476,10 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
export PYTHON_DECIMAL_WITH_MACHINE=${if stdenv.isAarch64 then "uint128" else "x64"}
# Ensure that modern platform features are enabled on Darwin in spite of having no version suffix.
sed -E -i -e 's|Darwin/\[12\]\[0-9\]\.\*|Darwin/*|' configure
'' + optionalString (pythonAtLeast "3.11") ''
# Also override the auto-detection in `configure`.
substituteInPlace configure \
--replace-fail 'libmpdec_machine=universal' 'libmpdec_machine=${if stdenv.isAarch64 then "uint128" else "x64"}'
'' + optionalString (stdenv.isDarwin && x11Support && pythonAtLeast "3.11") ''
export TCLTK_LIBS="-L${tcl}/lib -L${tk}/lib -l${tcl.libPrefix} -l${tk.libPrefix}"
export TCLTK_CFLAGS="-I${tcl}/include -I${tk}/include"
@@ -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";
@@ -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}";
@@ -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 = [
@@ -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 ];
@@ -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)"
@@ -23,9 +23,6 @@ buildPythonPackage rec {
hash = "sha256-nKdCMgA92v9VsSgfktXDbSh3DyKsGlcTjpn0Y7u4rxU=";
};
# default lto off for darwin
patches = [ ./darwin-lto.patch ];
build-system = [
setuptools
wheel
@@ -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 ];
};
@@ -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.
-3
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 = [
-6
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}
-3
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"
@@ -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)
-5
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