llvmPackages_{13,14}.lldb: fix build on x86 macOS

See: https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132

+57 -4
+12
pkgs/development/compilers/llvm/13/lldb/cpu_subtype_arm64e_replacement.patch
··· 1 + diff --git a/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/source/Host/macosx/objcxx/HostInfoMacOSX.mm 2 + --- a/source/Host/macosx/objcxx/HostInfoMacOSX.mm 3 + +++ b/source/Host/macosx/objcxx/HostInfoMacOSX.mm 4 + @@ -233,7 +233,7 @@ void HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32, 5 + len = sizeof(is_64_bit_capable); 6 + ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0); 7 + 8 + - if (cputype == CPU_TYPE_ARM64 && cpusubtype == CPU_SUBTYPE_ARM64E) { 9 + + if (cputype == CPU_TYPE_ARM64 && cpusubtype == ((cpu_subtype_t) 2)) { // CPU_SUBTYPE_ARM64E is not available in the macOS 10.12 headers 10 + // The arm64e architecture is a preview. Pretend the host architecture 11 + // is arm64. 12 + cpusubtype = CPU_SUBTYPE_ARM64_ALL;
+17 -2
pkgs/development/compilers/llvm/13/lldb/default.nix
··· 20 20 , Cocoa 21 21 , lit 22 22 , makeWrapper 23 + , darwin 23 24 , enableManpages ? false 24 25 }: 25 26 ··· 38 39 substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir 39 40 '') 40 41 ./gnu-install-dirs.patch 41 - ]; 42 + ] 43 + # This is a stopgap solution if/until the macOS SDK used for x86_64 is 44 + # updated. 45 + # 46 + # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` 47 + # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use 48 + # of this preprocessor symbol in `lldb` with its expansion. 49 + # 50 + # See here for some context: 51 + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 52 + ++ lib.optional ( 53 + stdenv.targetPlatform.isDarwin 54 + && !stdenv.targetPlatform.isAarch64 55 + && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") 56 + ) ./cpu_subtype_arm64e_replacement.patch; 57 + 42 58 43 59 outputs = [ "out" "lib" "dev" ]; 44 60 ··· 102 118 ''; 103 119 104 120 meta = llvm_meta // { 105 - broken = stdenv.isDarwin; 106 121 homepage = "https://lldb.llvm.org/"; 107 122 description = "A next-generation high-performance debugger"; 108 123 longDescription = ''
+12
pkgs/development/compilers/llvm/14/lldb/cpu_subtype_arm64e_replacement.patch
··· 1 + diff --git a/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/source/Host/macosx/objcxx/HostInfoMacOSX.mm 2 + --- a/source/Host/macosx/objcxx/HostInfoMacOSX.mm 3 + +++ b/source/Host/macosx/objcxx/HostInfoMacOSX.mm 4 + @@ -233,7 +233,7 @@ void HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32, 5 + len = sizeof(is_64_bit_capable); 6 + ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0); 7 + 8 + - if (cputype == CPU_TYPE_ARM64 && cpusubtype == CPU_SUBTYPE_ARM64E) { 9 + + if (cputype == CPU_TYPE_ARM64 && cpusubtype == ((cpu_subtype_t) 2)) { // CPU_SUBTYPE_ARM64E is not available in the macOS 10.12 headers 10 + // The arm64e architecture is a preview. Pretend the host architecture 11 + // is arm64. 12 + cpusubtype = CPU_SUBTYPE_ARM64_ALL;
+16 -2
pkgs/development/compilers/llvm/14/lldb/default.nix
··· 20 20 , Cocoa 21 21 , lit 22 22 , makeWrapper 23 + , darwin 23 24 , enableManpages ? false 24 25 , lua5_3 25 26 }: ··· 44 45 substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir 45 46 '') 46 47 ./gnu-install-dirs.patch 47 - ]; 48 + ] 49 + # This is a stopgap solution if/until the macOS SDK used for x86_64 is 50 + # updated. 51 + # 52 + # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` 53 + # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use 54 + # of this preprocessor symbol in `lldb` with its expansion. 55 + # 56 + # See here for some context: 57 + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 58 + ++ lib.optional ( 59 + stdenv.targetPlatform.isDarwin 60 + && !stdenv.targetPlatform.isAarch64 61 + && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") 62 + ) ./cpu_subtype_arm64e_replacement.patch; 48 63 49 64 outputs = [ "out" "lib" "dev" ]; 50 65 ··· 116 131 larger LLVM Project, such as the Clang expression parser and LLVM 117 132 disassembler. 118 133 ''; 119 - broken = stdenv.isDarwin; # error: use of undeclared identifier 'CPU_SUBTYPE_ARM64E' 120 134 }; 121 135 } // lib.optionalAttrs enableManpages { 122 136 pname = "lldb-manpages";