<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-cl /clang: flag causes incorrect crash reproducer comments"
href="https://bugs.llvm.org/show_bug.cgi?id=51997">51997</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl /clang: flag causes incorrect crash reproducer comments
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>$ cat crash.c
#pragma clang __debug crash
$ rm /tmp/crash*
$ out/gn/bin/clang-cl /clang:-ffp-contract=off -c crash.c -Werror
...
$ grep Driver /tmp/crash-*.sh
# Driver args: "--driver-mode=cl" "/clang:-ffp-contract=off" "-c" "crash.c"
"-Werror" "-ffp-contract=off"
Note that "-ffp-contract=off" is present twice, once as (correct) /clang: flag
and once without it. Running this driver command as-is errors out like you'd
expect:
$ out/gn/bin/clang -Werror "--driver-mode=cl" "/clang:-ffp-contract=off" "-c"
"crash.c" "-Werror" "-ffp-contract=off"
clang: error: unknown argument ignored in clang-cl: '-ffp-contract=off'
[-Werror,-Wunknown-argument]
The reason for this bug is that clang/lib/Driver/Driver.cpp implements
OPT__SLASH_clang by appending flags to the argument list. That causes this bug
(the crash report code just writes out the argument list), and possibly others
issues (<a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-cl gets confused by the /clang:-save-temps flag"
href="show_bug.cgi?id=41308">bug 41308</a>, <a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-cl /clang: pass-through causes read-after-free with aliased options"
href="show_bug.cgi?id=42501">bug 42501</a>).
Maybe a better approach for implementing /clang: is to make it replace the
/clang: flag with a new Arg object that points to the original /clang: flag as
an alias. Then everything should work with the existing alias infrastructure.
ArgList doesn't have a replaceArg() method yet, but that should be reasonably
easy to add.
It'd mean we'd want to interpret each /clang: flag standalone, so things like
`/clang:-fdebug-compilation-dir /clang:.` wouldn't work, you'd have to say
`'/clang:-fdebug-compilation-dir .'`. But that seems like it should be fine.
It'd also have the effect that /clang: flags would take effect at the place
where they are in the command line, and not after all non clang-flags. That is,
`/clang:-fsanitize=address -fno-sanitize` would result in sanitizers being off
instead of it being on like currently. That even seems like a progresion.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>