[Bug 3629] Building with Clang-17 fails due to -fzero-call-used-regs

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Tue Nov 21 16:18:33 AEDT 2023


https://bugzilla.mindrot.org/show_bug.cgi?id=3629

--- Comment #8 from Darren Tucker <dtucker at dtucker.net> ---
Sigh.  Looks like clang is not the only compiler to have problems with
this flag: gcc 11 on mips and mipsel (at least on OpenWRT, not sure if
it's specific to that or not) also does:

cc -g -O2 -pipe -Wno-error=format-truncation -Wall -Wpointer-arith
-Wuninitialized -Wsign-compare -Wformat-security
-Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result
-Wimplicit-fallthrough -Wmisleading-indentation -fno-strict-aliasing
-D_FORTIFY_SOURCE=2 -ftrapv -fzero-call-used-regs=used
-fno-builtin-memset -fstack-protector-strong   -fPIC -I. -I.. -I.
-I./..  -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE
-D_GNU_SOURCE -DHAVE_CONFIG_H -c arc4random_uniform.c
during RTL pass: final
arc4random_uniform.c: In function 'arc4random_uniform':
arc4random_uniform.c:63:1: internal compiler error: in
mips_output_move, at config/mips/mips.c:5327
   63 | }
      | ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://dev.openwrt.org/> for instructions.
{standard input}: Assembler messages:
{standard input}: Warning: missing .end at end of assembly
{standard input}: Error: open CFI at the end of file; missing
.cfi_endproc directive

$ cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/mipsel-openwrt-linux-musl/11.2.0/lto-wrapper
Target: mipsel-openwrt-linux-musl
Configured with:
/builder/shared-workdir/build/sdk/build_dir/target-mipsel_24kc_musl/gcc-11.2.0/configure
--target=mipsel-openwrt-linux --host=mipsel-openwrt-linux
--build=x86_64-pc-linux-gnu --program-prefix= --program-suffix=
--prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
--libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share
--localstatedir=/var --mandir=/usr/man --infodir=/usr/info
--disable-nls 'CXXFLAGS_FOR_TARGET=-g -O2
-D_GLIBCXX_INCLUDE_NEXT_C_HEADERS' --build=x86_64-pc-linux-gnu
--host=mipsel-openwrt-linux-musl --target=mipsel-openwrt-linux-musl
--enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/
--with-pkgversion='OpenWrt GCC 11.2.0' --enable-shared
--disable-__cxa_atexit --with-default-libstdcxx-abi=gcc4-compatible
--enable-target-optspace --with-gnu-ld --disable-nls
--disable-libsanitizer --disable-libvtv --disable-libcilkrts
--disable-libmudflap --disable-libmpx --disable-multilib
--disable-libgomp --disable-libquadmath --disable-libssp
--disable-decimal-float --disable-libstdcxx-pch
--with-host-libstdcxx=-lstdc++ --prefix=/usr --libexecdir=/usr/lib
--with-local-prefix=/usr --with-stage1-ldflags=-lstdc++
--with-float=soft
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (OpenWrt GCC 11.2.0) 

We can reduce this to a fairly minimal testcase:

$ cat conftest.c 
unsigned int
arc4random_uniform(unsigned int upper_bound)
{
    return arc4random() % upper_bound;
}

$ cc -O -fzero-call-used-regs=used -c conftest.c 
conftest.c: In function 'arc4random_uniform':
conftest.c:4:16: warning: implicit declaration of function 'arc4random'
[-Wimplicit-function-declaration]
    4 |         return arc4random() % upper_bound;
      |                ^~~~~~~~~~
during RTL pass: final
conftest.c:5:1: internal compiler error: in mips_output_move, at
config/mips/mips.c:5327
    5 | }
      | ^

Prior to my change, the AC_COMPILE_IFELSE test in
OSSH_CHECK_CFLAG_COMPILE was sufficient to catch the problem with
-fzero-call-used-regs=all, but does not catch it with
-fzero-call-used-regs=used.  Expanding the testcase  in
OSSH_CHECK_CFLAG_COMPILE does seem to help:

-void f(int n) {}
+int f(int n) {return rand() % n;}

-- 
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list