From d6718a88debe7e604722d8422a988c2324721d96 Mon Sep 17 00:00:00 2001 From: roblabla Date: Sat, 19 Apr 2025 10:27:17 +0200 Subject: [PATCH] ghidra: Fix build for macos arm64 For some reason I haven't been able to figure out yet, ghidra builds for arm64 seems to build the x64 binaries of the decompiler. These fail to build due to trying to link the x64 object files with arm64 stdc++ library, which obviously fails. Those binaries are entirely unnecessary anyways, since we're targeting arm64 build here, so let's exclude them from the build. --- pkgs/tools/security/ghidra/build.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/security/ghidra/build.nix b/pkgs/tools/security/ghidra/build.nix index e079283c9162..e35516b16dad 100644 --- a/pkgs/tools/security/ghidra/build.nix +++ b/pkgs/tools/security/ghidra/build.nix @@ -22,6 +22,8 @@ let pname = "ghidra"; version = "11.2.1"; + isMacArm64 = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64; + releaseName = "NIX"; distroPrefix = "ghidra_${version}_${releaseName}"; src = fetchFromGitHub { @@ -133,7 +135,21 @@ stdenv.mkDerivation (finalAttrs: { data = ./deps.json; }; - gradleFlags = [ "-Dorg.gradle.java.home=${openjdk21}" ]; + gradleFlags = + [ "-Dorg.gradle.java.home=${openjdk21}" ] + ++ lib.optionals isMacArm64 [ + # For some reason I haven't been able to figure out yet, ghidra builds for + # arm64 seems to build the x64 binaries of the decompiler. These fail to + # build due to trying to link the x64 object files with arm64 stdc++ + # library, which obviously fails. + # + # Those binaries are entirely unnecessary anyways, since we're targeting + # arm64 build here, so let's exclude them from the build. + "-x" + "Decompiler:linkSleighMac_x86_64Executable" + "-x" + "Decompiler:linkDecompileMac_x86_64Executable" + ]; preBuild = '' export JAVA_TOOL_OPTIONS="-Duser.home=$NIX_BUILD_TOP/home"