Skip to content
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

Case for Xcoff not handled in prefix_and_suffix #137219

Closed
Pyr0de opened this issue Feb 18, 2025 · 3 comments · Fixed by #137816
Closed

Case for Xcoff not handled in prefix_and_suffix #137219

Pyr0de opened this issue Feb 18, 2025 · 3 comments · Fixed by #137816
Labels
A-binary-formats Area: binary formats (e.g. ELF, XCOFF, etc.) A-inline-assembly Area: Inline assembly (`asm!(…)`) A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` O-aix OS: Big Blue's Advanced Interactive eXecutive.. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Pyr0de
Copy link
Contributor

Pyr0de commented Feb 18, 2025

          Added Xcoff here with Elf since it wasn't taken into account before and AsmBinaryFormat defaulted to elf

Originally posted by @Pyr0de in #136637 (comment)

There is no case handling xcoff here and so it defaults to elf

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 18, 2025
@Pyr0de
Copy link
Contributor Author

Pyr0de commented Feb 18, 2025

@rustbot label +O-aix

@rustbot rustbot added the O-aix OS: Big Blue's Advanced Interactive eXecutive.. label Feb 18, 2025
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-binary-formats Area: binary formats (e.g. ELF, XCOFF, etc.) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 18, 2025
@folkertdev
Copy link
Contributor

folkertdev commented Feb 23, 2025

inline/global assembly for these targets does not appear to be well-supported in llvm. Many of the directives that LLVM itself emits are not supported by its assembly parser.

I've made this https://godbolt.org/z/xTq8rW876 which shows some of the issues (it needs a bunch of hackery so that we can actually compile for the target). So, I'm not sure that we can make much progress on the rust side without more LLVM support.

@rustbot label +F-naked-functions

@folkertdev
Copy link
Contributor

folkertdev commented Feb 23, 2025

@rustbot label +F-naked_functions +A-naked +A-inline-assembly

@rustbot rustbot added A-inline-assembly Area: Inline assembly (`asm!(…)`) A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS F-naked_functions `#![feature(naked_functions)]` labels Feb 23, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 13, 2025
…trieb

attempt to support `BinaryFormat::Xcoff` in `naked_asm!`

Fixes rust-lang#137219

So, the inline assembly support for xcoff is extremely limited. The LLVM [XCOFFAsmParser](https://github.com/llvm/llvm-project/blob/1b25c0c4da968fe78921ce77736e5baef4db75e3/llvm/lib/MC/MCParser/XCOFFAsmParser.cpp) does not support many of the attributes that LLVM itself emits, and that should exist based on [the assembler docs](https://www.ibm.com/docs/en/ssw_aix_71/assembler/assembler_pdf.pdf). It also does accept some that should not exist based on those docs.

So, I've tried to do the best I can given those limitations. At least it's better than emitting the directives for elf and having that fail somewhere deep in LLVM. Given that inline assembly for this target is incomplete (under `asm_experimental_arch`), I think that's OK (and again I don't see how we can do better given the limitations in LLVM).

r? `@Noratrieb` (given that you reviewed rust-lang#136637)

It seems reasonable to ping the [`powerpc64-ibm-aix` target maintainers](https://doc.rust-lang.org/rustc/platform-support/aix.html), hopefully they have thoughts too: `@daltenty` `@gilamn5tr`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 13, 2025
…trieb

attempt to support `BinaryFormat::Xcoff` in `naked_asm!`

Fixes rust-lang#137219

So, the inline assembly support for xcoff is extremely limited. The LLVM [XCOFFAsmParser](https://github.com/llvm/llvm-project/blob/1b25c0c4da968fe78921ce77736e5baef4db75e3/llvm/lib/MC/MCParser/XCOFFAsmParser.cpp) does not support many of the attributes that LLVM itself emits, and that should exist based on [the assembler docs](https://www.ibm.com/docs/en/ssw_aix_71/assembler/assembler_pdf.pdf). It also does accept some that should not exist based on those docs.

So, I've tried to do the best I can given those limitations. At least it's better than emitting the directives for elf and having that fail somewhere deep in LLVM. Given that inline assembly for this target is incomplete (under `asm_experimental_arch`), I think that's OK (and again I don't see how we can do better given the limitations in LLVM).

r? ``@Noratrieb`` (given that you reviewed rust-lang#136637)

It seems reasonable to ping the [`powerpc64-ibm-aix` target maintainers](https://doc.rust-lang.org/rustc/platform-support/aix.html), hopefully they have thoughts too: ``@daltenty`` ``@gilamn5tr``
@bors bors closed this as completed in 762acf5 Mar 13, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 13, 2025
Rollup merge of rust-lang#137816 - folkertdev:naked-asm-xcoff, r=Noratrieb

attempt to support `BinaryFormat::Xcoff` in `naked_asm!`

Fixes rust-lang#137219

So, the inline assembly support for xcoff is extremely limited. The LLVM [XCOFFAsmParser](https://github.com/llvm/llvm-project/blob/1b25c0c4da968fe78921ce77736e5baef4db75e3/llvm/lib/MC/MCParser/XCOFFAsmParser.cpp) does not support many of the attributes that LLVM itself emits, and that should exist based on [the assembler docs](https://www.ibm.com/docs/en/ssw_aix_71/assembler/assembler_pdf.pdf). It also does accept some that should not exist based on those docs.

So, I've tried to do the best I can given those limitations. At least it's better than emitting the directives for elf and having that fail somewhere deep in LLVM. Given that inline assembly for this target is incomplete (under `asm_experimental_arch`), I think that's OK (and again I don't see how we can do better given the limitations in LLVM).

r? ```@Noratrieb``` (given that you reviewed rust-lang#136637)

It seems reasonable to ping the [`powerpc64-ibm-aix` target maintainers](https://doc.rust-lang.org/rustc/platform-support/aix.html), hopefully they have thoughts too: ```@daltenty``` ```@gilamn5tr```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-binary-formats Area: binary formats (e.g. ELF, XCOFF, etc.) A-inline-assembly Area: Inline assembly (`asm!(…)`) A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` O-aix OS: Big Blue's Advanced Interactive eXecutive.. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants