about summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
authorRahul Butani <rrbutani@users.noreply.github.com>2022-10-07 20:01:05 -0500
committerRahul Butani <rrbutani@users.noreply.github.com>2023-01-27 13:29:22 -0800
commit1d3ca42323ce573a12dccf2590e3b18454a58289 (patch)
treef96605115058dff54078db1fb470ce2609a755b8 /pkgs/development/compilers
parentd7299071d4c5d765c7c5a6ea25a5fc98eb32c323 (diff)
downloadnixlib-1d3ca42323ce573a12dccf2590e3b18454a58289.tar
nixlib-1d3ca42323ce573a12dccf2590e3b18454a58289.tar.gz
nixlib-1d3ca42323ce573a12dccf2590e3b18454a58289.tar.bz2
nixlib-1d3ca42323ce573a12dccf2590e3b18454a58289.tar.lz
nixlib-1d3ca42323ce573a12dccf2590e3b18454a58289.tar.xz
nixlib-1d3ca42323ce573a12dccf2590e3b18454a58289.tar.zst
nixlib-1d3ca42323ce573a12dccf2590e3b18454a58289.zip
llvmPackages_15.lldb: fix `lldb` on x86_64 macOS
See:
https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/llvm/15/lldb/cpu_subtype_arm64e_replacement.patch12
-rw-r--r--pkgs/development/compilers/llvm/15/lldb/default.nix36
2 files changed, 46 insertions, 2 deletions
diff --git a/pkgs/development/compilers/llvm/15/lldb/cpu_subtype_arm64e_replacement.patch b/pkgs/development/compilers/llvm/15/lldb/cpu_subtype_arm64e_replacement.patch
new file mode 100644
index 000000000000..20d35c9f3ea9
--- /dev/null
+++ b/pkgs/development/compilers/llvm/15/lldb/cpu_subtype_arm64e_replacement.patch
@@ -0,0 +1,12 @@
+diff --git a/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+--- a/source/Host/macosx/objcxx/HostInfoMacOSX.mm
++++ b/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+@@ -233,7 +233,7 @@ void HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32,
+     len = sizeof(is_64_bit_capable);
+     ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0);
+ 
+-    if (cputype == CPU_TYPE_ARM64 && cpusubtype == CPU_SUBTYPE_ARM64E) {
++    if (cputype == CPU_TYPE_ARM64 && cpusubtype == ((cpu_subtype_t) 2)) { // CPU_SUBTYPE_ARM64E is not available in the macOS 10.12 headers
+       // The arm64e architecture is a preview. Pretend the host architecture
+       // is arm64.
+       cpusubtype = CPU_SUBTYPE_ARM64_ALL;
diff --git a/pkgs/development/compilers/llvm/15/lldb/default.nix b/pkgs/development/compilers/llvm/15/lldb/default.nix
index 6e6fe5cf0671..1ceca3813fa4 100644
--- a/pkgs/development/compilers/llvm/15/lldb/default.nix
+++ b/pkgs/development/compilers/llvm/15/lldb/default.nix
@@ -20,6 +20,7 @@
 , Cocoa
 , lit
 , makeWrapper
+, darwin
 , enableManpages ? false
 , lua5_3
 }:
@@ -44,7 +45,21 @@ stdenv.mkDerivation (rec {
       substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir
     '')
     ./gnu-install-dirs.patch
-  ];
+  ]
+  # This is a stopgap solution if/until the macOS SDK used for x86_64 is
+  # updated.
+  #
+  # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
+  # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
+  # of this preprocessor symbol in `lldb` with its expansion.
+  #
+  # See here for some context:
+  # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
+  ++ lib.optional (
+    stdenv.targetPlatform.isDarwin
+      && !stdenv.targetPlatform.isAarch64
+      && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
+  ) ./cpu_subtype_arm64e_replacement.patch;
 
   outputs = [ "out" "lib" "dev" ];
 
@@ -67,7 +82,24 @@ stdenv.mkDerivation (rec {
     bootstrap_cmds
     Carbon
     Cocoa
-  ];
+  ]
+  # The older libSystem used on x86_64 macOS is missing the
+  # `<bsm/audit_session.h>` header which `lldb` uses.
+  #
+  # We copy this header over from macOS 10.12 SDK.
+  #
+  # See here for context:
+  # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
+  ++ lib.optional (
+      stdenv.targetPlatform.isDarwin
+        && !stdenv.targetPlatform.isAarch64
+    ) (
+      runCommand "bsm-audit-session-header" { } ''
+        install -Dm444 \
+          "${lib.getDev darwin.apple_sdk.sdk}/include/bsm/audit_session.h" \
+          "$out/include/bsm/audit_session.h"
+      ''
+    );
 
   hardeningDisable = [ "format" ];