Index: llvm/trunk/include/llvm/BinaryFormat/MachO.h =================================================================== --- llvm/trunk/include/llvm/BinaryFormat/MachO.h +++ llvm/trunk/include/llvm/BinaryFormat/MachO.h @@ -487,6 +487,7 @@ PLATFORM_TVOS = 3, PLATFORM_WATCHOS = 4, PLATFORM_BRIDGEOS = 5, + PLATFORM_MACCATALYST = 6, PLATFORM_IOSSIMULATOR = 7, PLATFORM_TVOSSIMULATOR = 8, PLATFORM_WATCHOSSIMULATOR = 9 Index: llvm/trunk/include/llvm/Object/MachO.h =================================================================== --- llvm/trunk/include/llvm/Object/MachO.h +++ llvm/trunk/include/llvm/Object/MachO.h @@ -608,6 +608,7 @@ case MachO::PLATFORM_TVOS: return "tvos"; case MachO::PLATFORM_WATCHOS: return "watchos"; case MachO::PLATFORM_BRIDGEOS: return "bridgeos"; + case MachO::PLATFORM_MACCATALYST: return "maccatalyst"; case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator"; case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator"; case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator"; Index: llvm/trunk/lib/MC/MCAsmStreamer.cpp =================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp @@ -541,6 +541,7 @@ case MachO::PLATFORM_TVOS: return "tvos"; case MachO::PLATFORM_WATCHOS: return "watchos"; case MachO::PLATFORM_BRIDGEOS: return "bridgeos"; + case MachO::PLATFORM_MACCATALYST: return "maccatalyst"; case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator"; case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator"; case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator"; Index: llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp =================================================================== --- llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp +++ llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp @@ -1148,6 +1148,7 @@ case MachO::PLATFORM_TVOS: return Triple::TvOS; case MachO::PLATFORM_WATCHOS: return Triple::WatchOS; case MachO::PLATFORM_BRIDGEOS: /* silence warning */ break; + case MachO::PLATFORM_MACCATALYST: return Triple::IOS; case MachO::PLATFORM_IOSSIMULATOR: /* silence warning */ break; case MachO::PLATFORM_TVOSSIMULATOR: /* silence warning */ break; case MachO::PLATFORM_WATCHOSSIMULATOR: /* silence warning */ break; @@ -1168,6 +1169,7 @@ .Case("ios", MachO::PLATFORM_IOS) .Case("tvos", MachO::PLATFORM_TVOS) .Case("watchos", MachO::PLATFORM_WATCHOS) + .Case("maccatalyst", MachO::PLATFORM_MACCATALYST) .Default(0); if (Platform == 0) return Error(PlatformLoc, "unknown platform name"); Index: llvm/trunk/lib/MC/MCStreamer.cpp =================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp +++ llvm/trunk/lib/MC/MCStreamer.cpp @@ -1077,6 +1077,15 @@ unsigned Major; unsigned Minor; unsigned Update; + if (Target.isMacCatalystEnvironment()) { + // Mac Catalyst always uses the build version load command. + Target.getiOSVersion(Major, Minor, Update); + assert(Major && "A non-zero major version is expected"); + EmitBuildVersion(MachO::PLATFORM_MACCATALYST, Major, Minor, Update, + SDKVersion); + return; + } + MCVersionMinType VersionType; if (Target.isWatchOS()) { VersionType = MCVM_WatchOSVersionMin; Index: llvm/trunk/test/CodeGen/X86/macCatalyst.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/macCatalyst.ll +++ llvm/trunk/test/CodeGen/X86/macCatalyst.ll @@ -0,0 +1,3 @@ +; RUN: llc %s -o - | FileCheck %s +target triple="x86_64-apple-ios13.0-maccatalyst" +; CHECK: .build_version maccatalyst, 13, 0 Index: llvm/trunk/test/MC/MachO/build-version-maccatalyst.s =================================================================== --- llvm/trunk/test/MC/MachO/build-version-maccatalyst.s +++ llvm/trunk/test/MC/MachO/build-version-maccatalyst.s @@ -0,0 +1,4 @@ +// RUN: llvm-mc -triple x86_64-apple-ios %s | FileCheck %s + +.build_version maccatalyst,13,0 +// CHECK: .build_version maccatalyst, 13, 0 Index: llvm/trunk/test/MC/MachO/darwin-version-min-load-command.s =================================================================== --- llvm/trunk/test/MC/MachO/darwin-version-min-load-command.s +++ llvm/trunk/test/MC/MachO/darwin-version-min-load-command.s @@ -1,6 +1,7 @@ // RUN: llvm-mc -triple x86_64-apple-macosx10.10.0 %s -filetype=obj -o - | llvm-objdump -macho -private-headers - | FileCheck %s // RUN: llvm-mc -triple x86_64-apple-ios8.0.0 %s -filetype=obj -o - | llvm-objdump -macho -private-headers - | FileCheck %s --check-prefix=CHECK-IOS // RUN: llvm-mc -triple x86_64-apple-darwin %s -filetype=obj -o - | llvm-objdump -macho -private-headers - | FileCheck %s --check-prefix=CHECK-DARWIN +// RUN: llvm-mc -triple x86_64-apple-ios13.0-maccatalyst %s -filetype=obj -o - | llvm-objdump -macho -private-headers - | FileCheck %s --check-prefix=CHECK-MACCATALYST // Test version-min load command should be inferred from triple and should always be generated on Darwin // CHECK: Load command @@ -33,3 +34,10 @@ // CHECK-BRIDGEOS-NEXT: sdk n/a // CHECK-BRIDGEOS-NEXT: minos 2.0 // CHECK-BRIDGEOS-NEXT: ntools 0 + +// CHECK-MACCATALYST: cmd LC_BUILD_VERSION +// CHECK-MACCATALYST-NEXT: cmdsize 24 +// CHECK-MACCATALYST-NEXT: platform maccatalyst +// CHECK-MACCATALYST-NEXT: sdk n/a +// CHECK-MACCATALYST-NEXT: minos 13.0 +// CHECK-MACCATALYST-NEXT: ntools 0 Index: llvm/trunk/test/tools/llvm-objdump/X86/macho-maccatalyst-build-version.yaml =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/macho-maccatalyst-build-version.yaml +++ llvm/trunk/test/tools/llvm-objdump/X86/macho-maccatalyst-build-version.yaml @@ -0,0 +1,54 @@ +# RUN: yaml2obj %s | llvm-objdump -macho -private-headers - | FileCheck %s + +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x00000004 + ncmds: 2 + sizeofcmds: 192 + flags: 0x00000000 + reserved: 0 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 152 + segname: __TEXT + vmaddr: 4294967296 + vmsize: 8192 + fileoff: 0 + filesize: 3099 + maxprot: 7 + initprot: 5 + nsects: 1 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000100001160 + size: 3099 + offset: 0x00001160 + align: 4 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_BUILD_VERSION + cmdsize: 32 + platform: 6 + minos: 0x000D0000 + sdk: 0x00090000 + ntools: 1 + Tools: + - tool: 1 + version: 0x00000000 +... + +CHECK: Load command 1 +CHECK-NEXT: cmd LC_BUILD_VERSION +CHECK-NEXT: cmdsize 32 +CHECK-NEXT: platform maccatalyst +CHECK-NEXT: sdk 9.0 +CHECK-NEXT: minos 13.0