This improves the handling of -platform_version by addressing the FIXME in the code to process the arguments.
Details
- Reviewers
smeenai int3 Ktwu compnerd - Group Reviewers
Restricted Project - Commits
- rG49fb1c2e9018: [lld-macho] improve handling of -platform_version
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Neither PlatformType nor PlatformKind cover all cases of -platform_version, but TextAPI uses PlatformKind.
The ld man page references <mach-o/loader.h> for the numeric values. PlatformType seems to be outdated. It is missing PLATFORM_DRIVERKIT = 10. For the same reason, PlatformKind might be missing driverkit support.
The OSX 10.14 loader.h is missing the driverkit entry. Only the OSX 10.15 loader.h contains the driverkit entry.
DriverKit was introduced in 10.15, so its not surprising that the LLVM enumeration for the object file format (PLATFORM_TYPE) does not contain the value yet. AIUI, PlatformType is the loader representation (and is used in the object file format). The values in the general purpose usage live outside of the loader (TAPI and dyld are separate code bases) but the PlatformKind enumeration mirrors the PlatformType enumeration.
lld/test/MachO/platform-version.s | ||
---|---|---|
11 | nit: it's more common to use hyphens instead of underscores for check prefixes, i.e. FAIL-MISSING Also, I was thinking it might make sense to split this test into two parts, with all the FAIL- checks going under invalid/, and the passing ones remaining here. Once we support LC_BUILD_VERSION, we'll probably want to expand the test for passing platform strings to include checks that the LC_BUILD_VERSION command contains the expected output. | |
42 | even though man ld indicates that ios-sim is a valid platform string, I couldn't get it to work on ld64 :/ it seems like ios-simulator is expected instead. (I tried that string out after finding it in rG25ce33a6e). |
lld/test/MachO/platform-version.s | ||
---|---|---|
11 | For now, I would rather keep all tests in one place. | |
42 | Indeed, I got the *-sim names from the ld(1) manual page in Xcode 11. Obviously it is wrong. I looked at ld64/src/ld/PlatformSupport.cpp the newest ld64 source I have (v512), and found that -platform_version matches are case insensitive, with words separated by either dash or space. Here are the official names: "unknown" "macOS" "iOS" "tvOS" "watchOS" "bridgeOS" "Mac Catalyst" "iOS Simulator" "tvOS Simulator" "watchOS Simulator" "DriverKit" "free standing" I cross-checked against the binary for Xcode 11.3 (v530) via strings(1). I update to make the matches case insensitive and to tolerate either space or dash for word separators. |
lgtm!
lld/test/MachO/platform-version.s | ||
---|---|---|
46 | would be good to make one of these test strings contain a hyphen |
lld/test/MachO/platform-version.s | ||
---|---|---|
46 | Done. |
LLVM's option library does support multi-part options directly. See the first rev. of D80582.