-
Notifications
You must be signed in to change notification settings - Fork 245
Description
Let's say you are a customer and you've created a custom architecture plugin for something like Xtensa. Right now, when you register your architecture plugin and go to use it, you won't be able to set types because we calculate the target triple as xtensa-unknown-unknown-unknown
, which isn't real.
This shouldn't be a problem. We have code in GuessTripleFromPlatform
that provides a sane default for type parsing based upon the platform's address size. Unfortunately, in this specific case, it doesn't look like we get there for some reason.
EDIT: So, this is a problem because xtensa
is understood to be a real architecture by clang
in ArchType
from Triple.h
. We only trigger the 'sane default' described above if the value we find is not found (UnknownArch
) in the ArchType
enum
. We should probably consider changing this to also bail and use the 'sane default' if it's not an architecture we have first-party support (and maybe even special-cased by edition).
If you have this problem, you can work around it by setting analysis.types.parserDefaultArgs
to your target triple. Our clang subsystem will then pick that up and use it instead of the one calculated above. Unfortunately, this was implemented as a user setting and not a resource setting, so it applies to everything you open. You can work around this with a callback, but it's a hack.
Finally, when #4868 was resolved, an API was added (Platform::adjustTypeParserInput
, see here for the Python API) so you can set the triple. Unfortunately, if you don't have a platform (because you're using a raw firmware and, thus, using the placeholder standalone
platform), this won't actually work for you. We may need to consider having these APIs available for Architecture
as well to fall back on if the standalone
platform has been used to provide a default (which would not be used if an actual platform is specified).
It's not entirely clear to me how the above should be resolved specifically, but it's definitely bad UX and we should address it.