Unverified Commit 1d3ca423 authored by Rahul Butani's avatar Rahul Butani
Browse files

llvmPackages_15.lldb: fix `lldb` on x86_64 macOS

parent d7299071
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
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;
+34 −2
Original line number Diff line number Diff line
@@ -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" ];