Skip to content

Triple: Fix handling of macos with unexpected target arches #75469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Dec 14, 2023

Some tools with a specified target arch, but no full triple default to the host triple. On macos hosts, this would then force using macho on targets that didn't expect it, resulting in assertions.

We should also probably emit explicit errors if the object format is specified on targets which don't handle it.

Some tools with a specified target arch, but no full triple default
to the host triple. On macos hosts, this would then force using macho
on targets that didn't expect it, resulting in assertions.

We should also probably emit explicit errors if the object format
is specified on targets which don't handle it.
Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the correct change, but I'm sure Apple has some out-of-tree code that will likely be impacted.

cc: @lhames, @dsandersllvm, @rudkx. Apologies I don't know Aditya, or Charu's GitHub accounts and the autocomplete is failing me.


if (T.isOSDarwin())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we combine this with the two if's above and make it a switch on the OS (Windows, UEFI and Darwin are all OS bits)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It kind of works but isOSDarwin covers a few too many things:

return isMacOSX() || isiOS() || isWatchOS() || isDriverKit();

  bool isiOS() const {
    return getOS() == Triple::IOS || isTvOS();
  }

@arsenm arsenm merged commit 6294129 into llvm:main Dec 18, 2023
@arsenm arsenm deleted the triple-macos-is-not-macho branch December 18, 2023 14:28
@nico
Copy link
Contributor

nico commented Dec 18, 2023

@MaskRay FYI (since you did a bunch of march -> mtriple changes that were necessary before this).

@MaskRay
Copy link
Member

MaskRay commented Dec 19, 2023

@MaskRay FYI (since you did a bunch of march -> mtriple changes that were necessary before this).

Thanks for CCing me!

  EXPECT_EQ(Triple::ELF, Triple("amdgcn-apple-macosx").getObjectFormat());
  EXPECT_EQ(Triple::ELF, Triple("r600-apple-macosx").getObjectFormat());

I know that this serves as a change detector about the current behavior and not an endorsement of whether this makes sense.

However, ELF does not make more sense here. If we want to unsupport some unexpected target triples, I feel that the change should be made at an upper level, or change the return value to UnknownObjectFormat.

If the issue is {opt,llc} -march=..., fix them to switch to -mtriple= instead.

@MaskRay
Copy link
Member

MaskRay commented Dec 19, 2023

Created #75982 to change AMDGPU tests to use -mtriple=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants