<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/77028>77028</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang produces broken reproducers when invoked as assembler
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
brooksdavis
</td>
</tr>
</table>
<pre>
TL;DR: if clang crashes when invoked as an assembler on a .S file (assembly with CPP directives) it produces a reproducer that doesn't work due to a mismatch between the invocation of `clang -cc1as` and the partially preprocessed source file. It's unclear if the source should be more fully processed or the command in the .sh file should be different.
Due to a bug in assembly I hit an assert in the PowerPC backend.
```
Assertion failed: (MO.isImm() && "Relocation required in an instruction that we cannot encode!"), function getMachineOpValue, file /home/bed22/cheri/freebsd/contrib/llvm-project/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp, line 406.
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /home/bed22/tmp/obj/home/bed22/cheri/freebsd/powerpc.powerpc64/tmp/usr/bin/clang -cc1as -triple powerpc-unknown-freebsd15.0 -filetype obj -main-file-name symlink-7b6cec.S -target-cpu ppc -target-feature +secure-plt -fdebug-compilation-dir=/tmp -dwarf-debug-producer "FreeBSD clang version 17.0.6 (https://github.com/llvm/llvm-project.git llvmorg-17.0.6-0-g6009708b4367)" -debug-info-kind=constructor -dwarf-version=4 -mrelocation-model static -object-file-name=/dev/null -o /dev/null /tmp/symlink-7b6cec-448e06.s
#0 0x0000000003a27ca6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/bed22/tmp/obj/home/bed22/cheri/freebsd/powerpc.powerpc64/tmp/usr/bin/clang+0x3a27ca6)
#1 0x0000000003a26175 llvm::sys::RunSignalHandlers() (/home/bed22/tmp/obj/home/bed22/cheri/freebsd/powerpc.powerpc64/tmp/usr/bin/clang+0x3a26175)
#2 0x0000000003a2823e SignalHandler(int) (/home/bed22/tmp/obj/home/bed22/cheri/freebsd/powerpc.powerpc64/tmp/usr/bin/clang+0x3a2823e)
#3 0x00000000049397df handle_signal (/home/bed22/tmp/obj/home/bed22/cheri/freebsd/powerpc.powerpc64/tmp/usr/bin/clang+0x49397df)
clang: error: unable to execute command: Abort trap (core dumped)
clang: error: clang integrated assembler command failed due to signal (use -v to see invocation)
FreeBSD clang version 17.0.6 (https://github.com/llvm/llvm-project.git llvmorg-17.0.6-0-g6009708b4367)
Target: powerpc-unknown-freebsd15.0
Thread model: posix
InstalledDir: /home/bed22/tmp/obj/home/bed22/cheri/freebsd/powerpc.powerpc64/tmp/usr/bin
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/symlink-7b6cec.S
clang: note: diagnostic msg: /tmp/symlink-7b6cec.sh
clang: note: diagnostic msg:
********************
```
Clang dutifully produced the reproducers in https://gist.github.com/brooksdavis/4f2f973eb0c001603e79143233418450 which fail to reproduce the problem with many errors which look like it's trying to parse unexpanded macros as assembly.
```
/home/bed22/cheri/freebsd/lib/libsys/../libc/include/compat.h:42:22: error: expected ')'
__sym_compat(__semctl, freebsd7___semctl, FBSD_1.0);
^
/home/bed22/cheri/freebsd/lib/libsys/../libc/include/compat.h:42:13: error: unknown operand
__sym_compat(__semctl, freebsd7___semctl, FBSD_1.0);
^
...
```
I believe the issue is that `clang -cc1as` expects a fully processed assembly file, not one where includes have been embedded. The file is a hacked up version of the reproducer script that invokes clang in a way that actually triggers the crash.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWE1v4zjS_jXMpSBBphR_HHxw4ng6QPcbo5N39xhQZEliWyK1JBXH_35BUlacbHbQg5mdNoLYIlnFp76rxKyVtUJck-sbcr29YoNrtFmXRuuDFexF2qtSi9P66SvJb7bf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