Details
- Reviewers
int3 - Group Reviewers
Restricted Project - Commits
- rGfc5d804ddbef: [lld-macho] Check platform and version when constructor ObjFile
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Neat. Could you clean up the clang-tidy issues? Kind of hard to review the code with all that in the way.
Also, I think the method is getting large enough, it would be nice to factor out the arch/platform check into a separate method.
Finally, don't forget about the test :)
lld/MachO/InputFiles.cpp | ||
---|---|---|
351 | ultra nit: given that you're casting cmd->platform to a PlatformKind below, why not do it here too for uniformity? | |
364–368 | how about constructing another VersionTuple instance and compare that against platformInfo.minimum? that way you can also use VersionTuple::getAsString() below | |
513 | no need to repeat the type name on the same line | |
677 | seems kind of janky to pass in a function here just so we can prepend "dylib". I think it's clear enough that it's a dylib from the name (and if it's not, we should update toString so that all our error messages are uniform). Basically I think it would be cleaner to just pass in the InputFile * | |
lld/MachO/InputFiles.h | ||
179 | nice, I like the convenient casting. But I don't think there's a need to move this function into the header |
lld/test/MachO/incompat-version.s | ||
---|---|---|
1 ↗ | (On Diff #328387) | Can we merge this test into invalid/incompatible-arch.s? (and rename the file to incompatible-target or something). That test file is pretty small as-is and this test is covering very similar functionality. (In general we put tests that only check for error handling into invalid/.) |
updated diff:
- moved test into existing incompatible-arch.s
- added additional test case to cover the ObjFile path
- fixed other styling issues
lld/MachO/InputFiles.h | ||
---|---|---|
179 | It's a templated function, so you can't put it in the cpp file. If we put it in the cpp file, then it can only be a static local function. |
lld/MachO/InputFiles.h | ||
---|---|---|
179 | Oh, I didn't realize this was being used in ObjC.cpp | |
lld/test/MachO/invalid/incompatible-arch.s | ||
11–12 | doesn't seem like the -o %t/new.dylib is necessary given that we have -o /dev/null later | |
16 | nit: use hyphens for uniformity with things like CHECK-NEXT | |
19–22 | I'm guessing you created a bitcode file in order to specify the platform? You can actually specify it by compiling a regular assembly file via llvm-mc: llvm-mc -filetype=obj -triple=x86_64-apple-macos14.0 |
Updated test to specify the platform version with llvm-mc rather than going through the trouble of using a bitcode file
lld/test/MachO/invalid/incompatible-arch.s | ||
---|---|---|
19–22 | Good to know! |
lld/MachO/InputFiles.cpp | ||
---|---|---|
345 | oh I just noticed that you passed in the Configuration as a parameter. It's not necessary since config is a global singleton |
lld/MachO/InputFiles.cpp | ||
---|---|---|
345 | it was kind of intentional since I didn't like using a global variable in this context . |
nice, I like the convenient casting. But I don't think there's a need to move this function into the header