cpu-exec.c fails to compile - code path is reachable
Host environment
- Operating system: OmniOS
- OS/kernel version: SunOS build 5.11 omnios-r151044-d3b715b9d1 i86pc i386 i86pc
- Architecture: x86
- QEMU flavor:
- QEMU version: 7.2.0
- QEMU command line:
Description of problem
Building qemu (tested with both gcc11 and gcc12) fails with:
[34/76] Compiling C object libqemu-aarch64-softmmu.fa.p/accel_tcg_cpu-exec.c.o
FAILED: libqemu-aarch64-softmmu.fa.p/accel_tcg_cpu-exec.c.o
gcc -m64 -mcx16 -Ilibqemu-aarch64-softmmu.fa.p -I. -I.. -Itarget/arm
-I../target/arm -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader
-I/opt/ooce/include/pixman-1
-I/data/omnios-build/omniosorg/qemu/libtasn1-4.19.0/out/include
-I/usr/include/glib-2.0 -I/usr/lib/amd64/glib-2.0/include
-fdiagnostics-color=auto -Wall -Winvalid-pch -std=gnu11 -O2 -g
-iquote . -iquote /data/omnios-build/omniosorg/qemu
-iquote /data/omnios-build/omniosorg/qemu/include
-iquote /data/omnios-build/omniosorg/qemu/tcg/i386
-pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D__EXTENSIONS__
-D_XOPEN_SOURCE=600 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes
-fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition
-Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
-Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
-Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value
-Wno-psabi -fstack-protector-strong -m64 -gdwarf-2 -gstrict-dwarf
-fno-omit-frame-pointer -fno-aggressive-loop-optimizations -DNEED_CPU_H
'-DCONFIG_TARGET="aarch64-softmmu-config-target.h"'
'-DCONFIG_DEVICES="aarch64-softmmu-config-devices.h"' -MD -MQ
libqemu-aarch64-softmmu.fa.p/accel_tcg_cpu-exec.c.o
-MF libqemu-aarch64-softmmu.fa.p/accel_tcg_cpu-exec.c.o.d
-o libqemu-aarch64-softmmu.fa.p/accel_tcg_cpu-exec.c.o
-c ../accel/tcg/cpu-exec.c
In file included from ../accel/tcg/cpu-exec.c:20:
In function 'tb_pc',
inlined from 'cpu_tb_exec' at ../accel/tcg/cpu-exec.c:465:13:
/data/omnios-build/omniosorg/qemu/include/qemu/osdep.h:184:35: error: call to 'qemu_build_not_reached_always' declared with attribute error: code path is reachable
184 | #define qemu_build_not_reached() qemu_build_not_reached_always()
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/data/omnios-build/omniosorg/qemu/include/exec/exec-all.h:608:5: note: in expansion of macro 'qemu_build_not_reached'
608 | qemu_build_not_reached();
| ^~~~~~~~~~~~~~~~~~~~~~
Additional information
It appears that the compiler is not smart enough to realise that TARGET_TB_PCREL
is false in the branch there or is not able to infer that from the assert()
.
Adding an explicit check as a workaround allows compilation to continue.
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -459,7 +459,7 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
if (cc->tcg_ops->synchronize_from_tb) {
cc->tcg_ops->synchronize_from_tb(cpu, last_tb);
- } else {
+ } else if (!TARGET_TB_PCREL) {
assert(!TARGET_TB_PCREL);
assert(cc->set_pc);
cc->set_pc(cpu, tb_pc(last_tb));