By default with ld64, architecture mismatches are just warnings, then
this flag can be passed to make these fail. This matches that behavior.
Details
- Reviewers
int3 gkm - Group Reviewers
Restricted Project - Commits
- rG6629ec3ecc16: [lld-macho] Implement -arch_errors_fatal
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| lld/MachO/InputFiles.cpp | ||
|---|---|---|
| 798 | I'm not sure if the unconditional return here is the right behavior, or if in the warning case something else should be done here. I think this is right though | |
Thanks!
| lld/MachO/InputFiles.cpp | ||
|---|---|---|
| 793 | could we factor out the arguments somehow? E.g. something like auto f = config->errorForArchMismatch ? error : warning? (not sure if that compiles though) | |
| 798 | yeah we do the same thing for checkCompatibility below so the early return of an incompletely initialized InputFile should be fine | |
| lld/test/MachO/invalid/incompatible-arch.s | ||
| 7 | this should be no_fatal_warnings_lld too, otherwise we'll get an error regardless of whether -arch_errors_fatal is passed | |
| lld/MachO/InputFiles.cpp | ||
|---|---|---|
| 793 | I couldn't get a version of assigning the functions to a variable to work due to reference to overloaded function could not be resolved, I might have been doing something wrong? Either way for now I added a simple lambda to de-duplicate the string, lmk what you think. Note the whole reason I didn't assign the string to a variable instead was it seems like Twine is prime to use-after-free issues so the string was garbled in the output, clang-tidy also warned about that. | |
| lld/MachO/InputFiles.cpp | ||
|---|---|---|
| 793 | ah yeah I guess we need to use static_cast to indicate which overload we want. this should work: auto msg = config->errorForArchMismatch
? static_cast<void (*)(const Twine &)>(error)
: warn;
msg(toString(this) + " has architecture " + getArchitectureName(arch) +
" which is incompatible with target architecture " +
getArchitectureName(config->arch())); | |
Improve logic
| lld/MachO/InputFiles.cpp | ||
|---|---|---|
| 793 | Ah thanks, I tried wrapping the whole ternary in the static_cast, but this works | |
could we factor out the arguments somehow? E.g. something like auto f = config->errorForArchMismatch ? error : warning? (not sure if that compiles though)