<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/81603>81603</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang changed __builtin___stpncpy_chk, breaking glibc fortify users
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fefe17
</td>
</tr>
</table>
<pre>
Here's a small test program:
$ cat > t.c
int main() {
char buf[100];
__builtin___stpncpy_chk (buf, "foo", 3,
__builtin_object_size (buf, 2 > 1));
}
$ gcc -c t.c
$ /usr/bin/clang -c t.c
$ /opt/llvm/bin/clang -c t.c
t.c:5:41: error: too few arguments to function call, expected 5, have 4
4 | __builtin___stpncpy_chk (buf, "foo", 3,
| ~~~~~~~~~~~~~~~~~~~~~~~
5 | __builtin_object_size (buf, 2 > 1));
| ^
gcc is 13.2.0, /usr/bin/clang is 17.0.6, /opt/llvm/bin/clang is git from Jan 24.
This bug manifests when trying to compile Firefox. Some Rust module includes string.h from glibc with Fortify support enabled, which manifests with this error message:
In file included from /src/firefox/third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb.c:101:
In file included from /src/firefox/obj-x86_64-pc-linux-gnu/dist/system_wrappers/string.h:3:
In file included from /usr/include/string.h:548:
/usr/include/bits/string_fortified.h:105:31: error: too few arguments to function call, expected 5, have 4
104 | return __builtin___stpncpy_chk (__dest, __src, __n,
| ~~~~~~~~~~~~~~~~~~~~~~~
105 | __glibc_objsize (__dest));
| ^
1 error generated.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU2TozYQ_TXypcsUSGAzBw7zsVSSY5I7JaQGtCMkSh_jcQ757SmBvZ5NZndSyVIuW2p363U_9Wu492o0iA2pHkj1tOMxTNY1Aw5YHHe9lefmJ3RI6NEDBz9zrSGgD7A4Ozo-E3ZP8ieSX79pCYIHIOwThExsRmUCzFwZQmt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