[PATCH] D85415: [Sparc] Don't use SunStyleELFSectionSwitchSyntax

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 06:03:19 PDT 2020


ro added a comment.

In D85415#2223611 <https://reviews.llvm.org/D85415#2223611>, @ro wrote:

> In D85415#2216469 <https://reviews.llvm.org/D85415#2216469>, @efriedma wrote:
>
>>> Instead of adapting the affected tests, this patch changes that default. The internal assembler still accepts both forms as input, only the output syntax is affected.
>>
>> There's a check in the parser for usesSunStyleELFSectionSwitchSyntax(); what effect does that have?
>
> It now rejects the Sun-style syntax on input.  That's certainly not what I wanted to happen: instead my intent was to produce common ELF syntax on output, but accept both on input as the current/unpatched `clang` does. I must have been dreaming when I tested this!



>> If we expect that everyone targeting SPARC these days is using an assembler that understands the standard ELF syntax, printing that syntax seems fine.  I assume that's true on Linux; not sure what assemblers are commonly used on Solaris.
>
> It's not true for the Solaris assembler, but a recent `gas` is always bundled on Solaris 11.4, too.  In fact, the included versions of `gcc` are configured to use `gas`, not `/bin/as`.  The situation is similar to what was remedied for the linker with D84029 <https://reviews.llvm.org/D84029>: if you rely on one of two incompatible versions (`/bin/ld` instead of `/usr/gnu/bin/ld`in that case), you must somehow make certain that you always use the right one.

I've done more checking now:

- `gas` claims to support Sun style section syntax for all ELF targets, but a quick test on Solaris/amd64 and Linux/x86_64 didn't confirm that.
- While `clang` defaults to the internal assembler on Solaris, with `-fno-integrated-as` it creates output that the native Solaris assembler cannot handle:
  - While `as` requires the section name in double quotes, `clang` emits it unquoted.
  - `clang` unconditionally emits `gas`-only directives, e.g. `.type var, at object` where `#object` should be used, or `.p2align 2` which isn't supported at all.

Overall the Sun style syntax is support is mostly useless with an external assembler (maybe `gas` could handle it, but it can already handle the common ELF syntax).

So my suggestion would be

- Default to common ELF style on Sparc for output.
- Make certain that only `gas` is used on Solaris/Sparc to match just in case someone decides to use `-fno-integrated-as`.
- Still allow Sun style syntax on input (or rather the meagre subset `clang` currently supports).  This could either be achieved by doing it unconditionally for all ELF targets (by removing the `usesSunStyleELFSectionSwitchSyntax` check in `ELFAsmParser.cpp` (`ELFAsmParser::ParseSectionArguments`) or splitting `usesSunStyleELFSectionSwitchSyntax` into separate `emitSunStyleELFSectionSwitchSyntax` and `readSunStyleELFSectionSwitchSyntax`.  The latter seems overkill for such obscure a feature.

Comments?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85415/new/

https://reviews.llvm.org/D85415



More information about the llvm-commits mailing list