clang sparc backend

does clang support sparc backend?

I tried " clang -target sparc " to compile a simple c program on ubuntu(x86_64), clang detects sparc as a valid target but does not work with it.

/usr/bin/as: unrecognized option ‘-Av8’
clang-11: error: assembler command failed with exit code 1

Hi,

It sounds as if the sparc back end is not using the integrated assembler and so it will call out to the default assembler for your toolchain. Because you have not specified a -B option, the default search path will be /usr/bin, where it is finding an assembler. This assembler, unfortunately, cannot handle SPARC assembly (it sounds as if it's an x86-64 build of gas).

If you want to assemble the output from clang, you will need to install a SPARC assembler (and, for it to be useful, also install a SPARC linker) and specify -B {path/to/tools} in the flags that you pass to clang.

David

The sparc integrated assembler does generally work, you can enable with -fintegrated-as. IIRC, it was disabled by default because there’s some edge cases it didn’t handle, but I don’t remember the details.

The sparc integrated assembler does generally work, you can enable with
-fintegrated-as. IIRC, it was disabled by default because there's some edge
cases it didn't handle, but I don't remember the details.

rG97f4d2c47fc3 listed some issues with the integrated
assembler.