https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119122
Bug ID: 119122 Summary: Zca does not imply C extension when it is possible Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: Yuriy.Kolerov at synopsys dot com Target Milestone: --- Target: riscv GCC must imply C extension from Zca extension when it's possible. It's necessary for achieving compatibility between different march strings which in fact may be the same. E.g., if rv32ic multilib configuration is presented in GCC, then GCC will not choose this configuration for linking if -march=rv32i_zca is passed. Here is a more practical example. From RISC-V Instruction Set Manual: Therefore common ISA strings can be updated as follows to include the relevant Zc extensions, for example: - RV32IMC becomes RV32IM_Zce - RV32IMCF becomes RV32IMF_Zce With current implication rules this will not work well if rv32imc configuration is presented and a user passes -march=rv32im_zce. This is how we can check this with a simple empty test.c source file: $ riscv64-unknown-elf-gcc -march=rv32ic -mabi=ilp32 -mriscv-attribute -S test.c $ grep "attribute arch" test.s .attribute arch, "rv32i2p1_c2p0_zca1p0" $ riscv64-unknown-elf-gcc -march=rv32i_zce -mabi=ilp32 -mriscv-attribute -S test.c $ grep "attribute arch" test.s .attribute arch, "rv32i2p1_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0" According to current GCC these march strings are incompatible: the first one contains c2p0 and the second on doesn't. GCC version, configuration and system type: $ riscv64-unknown-elf-gcc --version riscv64-unknown-elf-gcc (ga0d29dd218e) 15.0.1 20250301 (experimental) $ riscv64-unknown-elf-gcc -v Using built-in specs. COLLECT_GCC=./install-old/bin/riscv64-unknown-elf-gcc COLLECT_LTO_WRAPPER=/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/install-old/libexec/gcc/riscv64-unknown-elf/15.0.1/lto-wrapper Target: riscv64-unknown-elf Configured with: /SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/gcc/configure --target=riscv64-unknown-elf --prefix=/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/install-old --disable-shared --disable-threads --enable-languages=c,c++ --with-pkgversion=ga0d29dd218e --with-system-zlib --enable-tls --with-newlib --with-headers=/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/install-old/riscv64-unknown-elf/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --src=/SCRATCH/ykolerov/workspace/arc-v/testing/gcc-zce/gcc --enable-multilib --with-multilib-generator='rv32i-ilp32--;rv32ic-ilp32--;rv32ifc-ilp32f--;rv32ifdc-ilp32d--;rv64i-lp64--;rv64ic-lp64--;rv64ifc-lp64f--;rv64ifdc-lp64d--' --with-abi=lp64d --with-arch=rv64gc --with-tune=rocket --with-isa-spec=20191213 CFLAGS='-O0 -g' CXXFLAGS='-O0 -g' 'CFLAGS_FOR_TARGET=-Os -g ' 'CXXFLAGS_FOR_TARGET=-Os -g ' Thread model: single Supported LTO compression algorithms: zlib gcc version 15.0.1 20250301 (experimental) (ga0d29dd218e) $ uname -rvio 6.6.36.6-microsoft-standard-WSL2+ #1 SMP PREEMPT_DYNAMIC Thu Nov 28 17:58:07 +04 2024 x86_64 GNU/Linux