File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,25 @@ llvm::DataLayout get_data_layout_for_target(Target target) {
422
422
423
423
namespace Internal {
424
424
425
+ namespace {
426
+
427
+ std::optional<llvm::VersionTuple> get_os_version_constraint (const llvm::Triple &triple) {
428
+ if (!triple.isOSBinFormatMachO ()) {
429
+ return std::nullopt;
430
+ }
431
+
432
+ if (triple.getOS () == llvm::Triple::MacOSX && triple.getArch () == llvm::Triple::x86_64) {
433
+ // At time of writing (June 2024), this is one version prior
434
+ // to the oldest version still supported by Apple.
435
+ return llvm::VersionTuple (11 , 0 , 0 );
436
+ }
437
+
438
+ llvm::VersionTuple t = triple.getMinimumSupportedOSVersion ();
439
+ return t.empty () ? std::nullopt : std::make_optional (t);
440
+ }
441
+
442
+ } // namespace
443
+
425
444
llvm::Triple get_triple_for_target (const Target &target) {
426
445
llvm::Triple triple;
427
446
@@ -555,6 +574,14 @@ llvm::Triple get_triple_for_target(const Target &target) {
555
574
// Return default-constructed triple. Must be set later.
556
575
}
557
576
577
+ // Setting a minimum OS version here enables LLVM to include platform
578
+ // metadata in the MachO object file. Without this, Xcode 15's ld
579
+ // issues warnings about missing the "platform load command".
580
+ if (auto version = get_os_version_constraint (triple)) {
581
+ // llvm::Triple determines the version by parsing the OSName.
582
+ triple.setOSName ((triple.getOSName () + version->getAsString ()).str ());
583
+ }
584
+
558
585
return triple;
559
586
}
560
587
You can’t perform that action at this time.
0 commit comments