treewide: remove obsolete aligned allocation workarounds

This commit is contained in:
Emily 2024-10-05 22:36:59 +01:00
parent 3667e0b7e4
commit 205c1696b8
28 changed files with 25 additions and 177 deletions

View File

@ -86,8 +86,6 @@ stdenv.mkDerivation rec {
"-DPY_MOD_INSTALL_DIR=${placeholder "py"}/${python3.sitePackages}/"
];
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-faligned-allocation";
meta = with lib; {
description = "Zeek's Messaging Library";
mainProgram = "broker-benchmark";

View File

@ -91,8 +91,6 @@ stdenv.mkDerivation rec {
"-DLIBKQUEUE_ROOT_DIR=${libkqueue}"
];
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-faligned-allocation";
postInstall = ''
for file in $out/share/zeek/base/frameworks/notice/actions/pp-alarms.zeek $out/share/zeek/base/frameworks/notice/main.zeek; do
substituteInPlace $file \

View File

@ -25,8 +25,6 @@ stdenv.mkDerivation rec {
"-DCAF_ENABLE_EXAMPLES:BOOL=OFF"
];
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-faligned-allocation";
doCheck = !stdenv.hostPlatform.isDarwin;
checkTarget = "test";

View File

@ -30,11 +30,6 @@ buildNpmPackage rec {
npmDepsHash = "sha256-fDoia6evCmXZgeIKL0coRo3yunX1dfud31ROgmop2Sc=";
# Fix error: no member named 'aligned_alloc' in the global namespace
env.NIX_CFLAGS_COMPILE = lib.optionalString (
stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11.0"
) "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1";
nativeBuildInputs = [
python3
pkg-config

View File

@ -38,10 +38,6 @@ stdenv.mkDerivation rec {
yaml-cpp
];
env.NIX_CFLAGS_COMPILE = lib.optionalString (
stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64
) "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1";
meta = with lib; {
description = "Code formatter for Lua";
homepage = "https://github.com/Koihik/LuaFormatter";

View File

@ -99,8 +99,5 @@ rustPlatform.buildRustPackage rec {
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ teutat3s ];
mainProgram = "mas-cli";
# Note: broken on x86_64-darwin because of aligned_alloc, can be revisited after
# https://github.com/NixOS/nixpkgs/pull/346043 is merged
badPlatforms = [ "x86_64-darwin" ];
};
}

View File

@ -50,10 +50,6 @@ stdenv.mkDerivation rec {
"-DMOLD_USE_SYSTEM_TBB:BOOL=ON"
];
env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.hostPlatform.isDarwin [
"-faligned-allocation"
]);
passthru = {
updateScript = nix-update-script { };
tests =

View File

@ -51,14 +51,10 @@ stdenv.mkDerivation {
tbb_2021_11
];
cmakeFlags =
[
(lib.cmakeBool "CPPTRACE_USE_EXTERNAL_LIBDWARF" true)
(lib.cmakeBool "CPPTRACE_USE_EXTERNAL_ZSTD" true)
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
(lib.cmakeFeature "CMAKE_OSX_DEPLOYMENT_TARGET" "10.14") # For aligned allocation
];
cmakeFlags = [
(lib.cmakeBool "CPPTRACE_USE_EXTERNAL_LIBDWARF" true)
(lib.cmakeBool "CPPTRACE_USE_EXTERNAL_ZSTD" true)
];
doCheck = true;

View File

@ -46,14 +46,6 @@ stdenv.mkDerivation rec {
cmakeFlags = [ "-DWITH_LTO=OFF" ];
env.NIX_CFLAGS_COMPILE = toString (
lib.optionals
(stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13")
[
"-faligned-allocation"
]
);
installPhase = ''
runHook preInstall

View File

@ -14,12 +14,7 @@
yq-go,
}:
let
# fix build error, `no member named 'aligned_alloc'` on x86_64-darwin
# https://github.com/NixOS/nixpkgs/issues/272156#issuecomment-1839904283
stdenv' = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv;
in
stdenv'.mkDerivation (finalAttrs: {
stdenv.mkDerivation (finalAttrs: {
pname = "renovate";
version = "39.90.2";
@ -41,7 +36,7 @@ stdenv'.mkDerivation (finalAttrs: {
pnpm_9.configHook
python3
yq-go
] ++ lib.optional stdenv'.hostPlatform.isDarwin xcbuild;
] ++ lib.optional stdenv.hostPlatform.isDarwin xcbuild;
pnpmDeps = pnpm_9.fetchDeps {
inherit (finalAttrs) pname version src;

View File

@ -56,12 +56,6 @@ stdenv.mkDerivation (finalAttrs: {
"tools"
];
env.NIX_CFLAGS_COMPILE = toString (
lib.optionals stdenv.cc.isClang [
"-faligned-allocation"
]
);
cmakeFlags = [
"-DPORTABLE=1"
"-DWITH_JEMALLOC=${if enableJemalloc then "1" else "0"}"

View File

@ -236,11 +236,6 @@ stdenv.mkDerivation rec {
}"
'';
# error: aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on macOS 10.13 or newer
env.CXXFLAGS = lib.optionalString (
stdenv.hostPlatform.system == "x86_64-darwin"
) "-faligned-allocation";
# workaround for
# https://github.com/root-project/root/issues/14778
env.NIX_LDFLAGS = lib.optionalString (

View File

@ -26,8 +26,6 @@ rustPlatform.buildRustPackage rec {
rustPlatform.bindgenHook
];
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-faligned-allocation";
postPatch = ''
substituteInPlace src/main.rs \
--replace-fail "./config.cfg" "$out/etc/sonic/config.cfg"

View File

@ -53,8 +53,6 @@ stdenv.mkDerivation (finalAttrs: {
readline
];
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-faligned-allocation";
doCheck = true;
strictDeps = true;

View File

@ -85,9 +85,6 @@ stdenv.mkDerivation rec {
env.NIX_CFLAGS_COMPILE = toString (
[ ]
++ lib.optional stdenv.hostPlatform.isLinux "-ltbb"
++ lib.optional (
stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13"
) "-fno-aligned-allocation"
# Workaround for https://github.com/NixOS/nixpkgs/issues/19098
++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform.isDarwin) "-fno-lto"
);

View File

@ -94,14 +94,6 @@ stdenv.mkDerivation rec {
"-DENABLE_X11=OFF"
];
# error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on macOS 10.14 or newer
preBuild =
lib.optionalString
(stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "11.0")
''
export MACOSX_DEPLOYMENT_TARGET=10.14
'';
meta = with lib; {
description = "Drop in replacement for ueberzug written in C++";
homepage = "https://github.com/jstkdng/ueberzugpp";

View File

@ -75,9 +75,6 @@ stdenv.mkDerivation rec {
"x86_64-linux"
"x86_64-darwin"
];
# Upstream claims support, but breaks with:
# error: use of undeclared identifier 'aligned_alloc'
broken = stdenv.hostPlatform.isDarwin;
homepage = "https://github.com/clasp-developers/clasp";
mainProgram = "clasp";
};

View File

@ -31,30 +31,14 @@ stdenv.mkDerivation rec {
hash = "sha256-BPalUh9EgdCqVaWC1HoreyyRcPQc4QMIYnLrRoNDDCI=";
};
postPatch =
''
# See https://github.com/halide/Halide/issues/7785
substituteInPlace 'src/runtime/HalideRuntime.h' \
--replace '#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
#define HALIDE_CPP_COMPILER_HAS_FLOAT16' \
'#if defined(__x86_64__) || defined(__i386__)
#define HALIDE_CPP_COMPILER_HAS_FLOAT16'
''
# Note: on x86_64-darwin, clang fails to find AvailabilityVersions.h, so we remove it.
# Halide uses AvailabilityVersions.h and TargetConditionals.h to determine whether
# ::aligned_alloc is available. For us, it isn't.
+ lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) ''
substituteInPlace 'src/runtime/HalideBuffer.h' \
--replace '#ifdef __APPLE__
#include <AvailabilityVersions.h>
#include <TargetConditionals.h>
#endif' \
' ' \
--replace 'TARGET_OS_OSX && (__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_15)' \
'1' \
--replace 'TARGET_OS_IPHONE && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_14_0)' \
'0'
'';
postPatch = ''
# See https://github.com/halide/Halide/issues/7785
substituteInPlace 'src/runtime/HalideRuntime.h' \
--replace '#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
#define HALIDE_CPP_COMPILER_HAS_FLOAT16' \
'#if defined(__x86_64__) || defined(__i386__)
#define HALIDE_CPP_COMPILER_HAS_FLOAT16'
'';
cmakeFlags = [
"-DWARNINGS_AS_ERRORS=OFF"

View File

@ -69,16 +69,9 @@ stdenv.mkDerivation {
export XDG_CACHE_HOME=$(mktemp -d)/.cache
'';
cmakeFlags =
[
"-DGUILE_CCACHE_DIR=${placeholder "out"}/${guile.siteCcacheDir}"
]
++ lib.optionals
(stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "11")
[
# warning: 'aligned_alloc' is only available on macOS 10.15 or newer
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15"
];
cmakeFlags = [
"-DGUILE_CCACHE_DIR=${placeholder "out"}/${guile.siteCcacheDir}"
];
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_CFLAGS_COMPILE = "-Wno-error=enum-constexpr-conversion";

View File

@ -38,8 +38,6 @@ stdenv.mkDerivation rec {
scikit-build-core
];
env.CXXFLAGS = toString (lib.optional stdenv.hostPlatform.isDarwin [ "-faligned-allocation" "-fno-aligned-new" "-fvisibility=hidden" ]);
postBuild = ''
pushd ../api/python
${pyEnv.interpreter} -m build --no-isolation --wheel --skip-dependency-check --config-setting=--parallel=$NIX_BUILD_CORES

View File

@ -41,18 +41,6 @@ stdenv.mkDerivation rec {
"-DOPENVDB_BUILD_NANOVDB=ON"
];
# error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on macOS 10.13 or newer
env =
lib.optionalAttrs
(
stdenv.hostPlatform.isDarwin
&& lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13"
&& lib.versionAtLeast tbb.version "2021.8.0"
)
{
NIX_CFLAGS_COMPILE = "-faligned-allocation";
};
postFixup = ''
substituteInPlace $dev/lib/cmake/OpenVDB/FindOpenVDB.cmake \
--replace \''${OPENVDB_LIBRARYDIR} $out/lib \

View File

@ -1,14 +0,0 @@
diff --git a/hacl-star-raw/karamel/include/krml/internal/target.h b/hacl-star-raw/karamel/include/krml/internal/target.h
index 695873a..c0aed18 100644
--- a/hacl-star-raw/karamel/include/krml/internal/target.h
+++ b/hacl-star-raw/karamel/include/krml/internal/target.h
@@ -82,6 +82,9 @@
# endif
# if (defined(_MSC_VER) || (defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR)))
# define KRML_ALIGNED_MALLOC(X, Y) _aligned_malloc(Y, X)
+# elif defined(__APPLE__)
+# include <mm_malloc.h>
+# define KRML_ALIGNED_MALLOC(X, Y) _mm_malloc(Y, X)
# else
# define KRML_ALIGNED_MALLOC(X, Y) aligned_alloc(X, Y)
# endif

View File

@ -19,10 +19,6 @@ stdenv.mkDerivation rec {
stripRoot = false;
};
patches = [
./aligned-alloc.patch
];
# strictoverflow is disabled because it breaks aarch64-darwin
hardeningDisable = [ "strictoverflow" ];

View File

@ -342,17 +342,7 @@ buildPythonPackage rec {
# until https://github.com/pytorch/pytorch/issues/76082 is addressed
+ lib.optionalString cudaSupport ''
rm cmake/Modules/FindCUDAToolkit.cmake
''
# error: no member named 'aligned_alloc' in the global namespace; did you mean simply 'aligned_alloc'
# This lib overrided aligned_alloc hence the error message. Tltr: his function is linkable but not in header.
+
lib.optionalString
(stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11.0")
''
substituteInPlace third_party/pocketfft/pocketfft_hdronly.h --replace-fail '#if (__cplusplus >= 201703L) && (!defined(__MINGW32__)) && (!defined(_MSC_VER))
inline void *aligned_alloc(size_t align, size_t size)' '#if 0
inline void *aligned_alloc(size_t align, size_t size)'
'';
'';
# NOTE(@connorbaker): Though we do not disable Gloo or MPI when building with CUDA support, caution should be taken
# when using the different backends. Gloo's GPU support isn't great, and MPI and CUDA can't be used at the same time

View File

@ -40,12 +40,6 @@ let
hash = source.npmDepsHash;
};
env = lib.optionalAttrs (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) {
# Make sure libc++ uses `posix_memalign` instead of `aligned_alloc` on x86_64-darwin.
# Otherwise, nodejs would require the 11.0 SDK and macOS 10.15+.
NIX_CFLAGS_COMPILE = "-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=101300";
};
nativeBuildInputs = [
nodejs
python3

View File

@ -36,15 +36,9 @@ buildGoModule rec {
};
# borrowed from: https://github.com/NixOS/nixpkgs/blob/d70d9425f49f9aba3c49e2c389fe6d42bac8c5b0/pkgs/development/tools/analysis/snyk/default.nix#L20-L22
env =
{
CYPRESS_INSTALL_BINARY = 0;
}
// lib.optionalAttrs (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) {
# Fix error: no member named 'aligned_alloc' in the global namespace.
# Occurs while building @esfx/equatable@npm:1.0.2 on x86_64-darwin
NIX_CFLAGS_COMPILE = "-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION=1";
};
env = {
CYPRESS_INSTALL_BINARY = 0;
};
offlineCache = stdenv.mkDerivation {
name = "${pname}-${version}-yarn-offline-cache";

View File

@ -47,14 +47,10 @@ rustPlatform.buildRustPackage rec {
pkg-config
];
env =
{
# Needed to get openssl-sys to use pkg-config.
OPENSSL_NO_VENDOR = 1;
}
// lib.optionalAttrs stdenv.cc.isClang {
NIX_CFLAGS_COMPILE = "-faligned-allocation";
};
env = {
# Needed to get openssl-sys to use pkg-config.
OPENSSL_NO_VENDOR = 1;
};
passthru = {
updateScript = nix-update-script { };

View File

@ -58,8 +58,5 @@ buildPostgresqlExtension (finalAttrs: {
license = licenses.agpl3Only;
maintainers = [ ];
platforms = postgresql.meta.platforms;
# error: use of undeclared identifier 'aligned_alloc'
broken =
stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13";
};
})