Skip to content

Commit

Permalink
Provide a minimum OS version for MachO objects
Browse files Browse the repository at this point in the history
This gives LLVM enough information to generate a
"platform load-command" in the object file.

Fixes #7941
  • Loading branch information
alexreinking committed Jun 25, 2024
1 parent 8c836b3 commit 6cb4d84
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/LLVM_Runtime_Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,18 @@ llvm::Triple get_triple_for_target(const Target &target) {
// Return default-constructed triple. Must be set later.
}

// Setting a minimum OS version here enables LLVM to include platform
// metadata in the MachO object file. Without this, Xcode 15's ld
// issues warnings about missing the "platform load command".
if (triple.isOSBinFormatMachO()) {
const llvm::VersionTuple minVer = triple.getMinimumSupportedOSVersion();
if (!minVer.empty()) {
const llvm::StringRef name = triple.getOSName();
// llvm::Triple determines the version by parsing the OSName.
triple.setOSName(name.str() + minVer.getAsString());
}
}

return triple;
}

Expand Down

0 comments on commit 6cb4d84

Please sign in to comment.