Files
nixpkgs/pkgs/by-name/su/surge/package.nix
Bart Brouns 49c3b62b24 surge: fix build with glibc 2.41
The generated ScalablePiggy.S has no .note.GNU-stack section, so the
linker marks the LV2/VST3 plugin .so as requiring an executable stack.
Since glibc 2.41, dlopen() refuses to load such objects, which breaks
the post-build LV2 step that dlopen()s the freshly built plugin to
generate its .ttl manifest:

    OSError: .../Surge.lv2/Surge.so: cannot enable executable stack as
    shared object requires: Invalid argument

Force a non-executable stack at link time with -z noexecstack.

Fixes #533882
2026-06-21 15:29:54 +02:00

122 lines
3.3 KiB
Nix

{
stdenv,
lib,
fetchurl,
fetchpatch,
fetchFromGitHub,
cmake,
gitMinimal,
pkg-config,
python3,
cairo,
libsndfile,
libxcb,
libxkbcommon,
libxcb-util,
libxcb-cursor,
libxcb-keysyms,
zenity,
curl,
rsync,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "surge";
version = "1.9.0";
src = fetchurl {
url = "https://github.com/surge-synthesizer/releases/releases/download/${finalAttrs.version}/SurgeSrc_${finalAttrs.version}.tgz";
hash = "sha256-k7x+s84OpazARlHWXEP1aC57+o3uEduAzYDeyBwlTgE=";
};
extraContent = fetchFromGitHub {
owner = "surge-synthesizer";
repo = "surge-extra-content";
# rev from: https://github.com/surge-synthesizer/surge/blob/release_1.8.1/cmake/stage-extra-content.cmake#L6
# or: https://github.com/surge-synthesizer/surge/blob/main/cmake/stage-extra-content.cmake
# SURGE_EXTRA_CONTENT_HASH
rev = "afc591cc06d9adc3dc8dc515a55c66873fa10296";
hash = "sha256-/3wrsA7aG7Jb4ehhnKRJ6hAH0Ir5EAvCypRbcKhBG/M=";
};
patches = [
# Fix build error due to newer glibc version by upgrading lib "catch 2"
# Issue: https://github.com/surge-synthesizer/surge/pull/4843
# Patch: https://github.com/surge-synthesizer/surge/pull/4845
(fetchpatch {
url = "https://github.com/surge-synthesizer/surge/commit/7a552038bab4b000d188ae425aa97963dc91db17.patch";
hash = "sha256-5Flf0uJqEK6e+sadB+vr6phdvvdZYXcFFfm4ywhAeW0=";
name = "glibc_build_fix.patch";
})
];
nativeBuildInputs = [
cmake
gitMinimal
pkg-config
python3
];
buildInputs = [
cairo
libsndfile
libxcb
libxkbcommon
libxcb-util
libxcb-cursor
libxcb-keysyms
zenity
curl
rsync
];
# Fix build with gcc 15
env.NIX_CFLAGS_COMPILE = "-Wno-deprecated";
# The generated ScalablePiggy.S has no .note.GNU-stack section, so the linker
# marks the LV2/VST3 plugin .so as requiring an executable stack. Since glibc
# 2.41 dlopen() refuses to load such objects ("cannot enable executable stack
# as shared object requires"). This breaks the post-build step that dlopens
# the freshly built LV2 plugin to generate its .ttl manifest. Force a
# non-executable stack at link time.
env.NIX_LDFLAGS = "-z noexecstack";
postPatch = ''
substituteInPlace src/common/SurgeStorage.cpp \
--replace "/usr/share/Surge" "$out/share/surge"
substituteInPlace src/linux/UserInteractionsLinux.cpp \
--replace '"zenity' '"${zenity}/bin/zenity'
patchShebangs scripts/linux/
cp -r $extraContent/Skins/ resources/data/skins
substituteInPlace libs/libsamplerate/CMakeLists.txt \
--replace-fail "cmake_minimum_required(VERSION 3.1..3.18)" "cmake_minimum_required(VERSION 3.10)"
'';
installPhase = ''
cd ..
cmake --build build --config Release --target install-everything-global
'';
doInstallCheck = true;
installCheckPhase = ''
export HOME=$(mktemp -d)
export SURGE_DISABLE_NETWORK_TESTS=TRUE
build/surge-headless
'';
meta = {
description = ''
LV2 & VST3 synthesizer plug-in (previously released as Vember Audio
Surge)
'';
homepage = "https://surge-synthesizer.github.io";
license = lib.licenses.gpl3;
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [
magnetophon
];
};
})