Bug 102957 - [riscv64] ICE on bogus -march value
Summary: [riscv64] ICE on bogus -march value
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.2.1
: P3 normal
Target Milestone: ---
Assignee: Kito Cheng
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2021-10-26 21:42 UTC by Jan Engelhardt
Modified: 2023-08-29 13:49 UTC (History)
3 users (show)

See Also:
Host:
Target: riscv64-suse-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-11-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Engelhardt 2021-10-26 21:42:49 UTC
> g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/riscv64-suse-linux/11/lto-wrapper
Target: riscv64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,ada,go,d,jit --enable-host-shared --enable-checking=release --disable-werror --with-gxx-include-dir=/usr/include/c++/11 --enable-ssp --disable-libssp --disable-libvtv --enable-cet=auto --disable-libcc1 --enable-plugin --with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-libphobos --enable-version-specific-runtime-libs --with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex --program-suffix=-11 --without-system-libunwind --disable-multilib --enable-link-mutex --build=riscv64-suse-linux --host=riscv64-suse-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.1 20210816 [revision 056e324ce46a7924b5cf10f61010cf9dd2ca10e9] (SUSE Linux) 


> g++ -v -march=rv64gzb
Using built-in specs.
g++: internal compiler error: in multi_letter_subset_rank, at common/config/riscv/riscv-common.c:200
Please submit a full bug report,


Yeah, zb is not valid (should be zbb), but should rather yield a normal message than an ICE.
Comment 1 Kito Cheng 2021-11-01 14:41:46 UTC
Confirmed, thanks for report this issue :)
Comment 2 GCC Commits 2021-11-09 16:26:16 UTC
The master branch has been updated by Kito Cheng <kito@gcc.gnu.org>:

https://gcc.gnu.org/g:abe562bb01479ea2c8952ad98714f3225527aa7e

commit r12-5062-gabe562bb01479ea2c8952ad98714f3225527aa7e
Author: Kito Cheng <kito.cheng@sifive.com>
Date:   Mon Nov 8 22:45:49 2021 +0800

    [PR/target 102957] Allow Z*-ext extension with only 2 char.
    
    We was assume the Z* extension should be more than 2 char, so we put an
    assertion there, but it should just an error or warning rather than an
    assertion, however RISC-V has add `Zk` extension, which just 2 char, so
    actually, we should just allow that.
    
    gcc/ChangeLog
    
            PR target/102957
            * common/config/riscv/riscv-common.c (multi_letter_subset_rank): Remove
            assertion for Z*-ext.
    
    gcc/testsuite/ChangeLog
    
            * gcc.target/riscv/pr102957.c: New.
Comment 3 Kito Cheng 2021-11-09 16:29:15 UTC
Wait another week for make sure stable and backport to gcc-11 and gcc-10 branch.
Comment 4 GCC Commits 2022-03-28 06:43:18 UTC
The releases/gcc-11 branch has been updated by Kito Cheng <kito@gcc.gnu.org>:

https://gcc.gnu.org/g:40e9979cf531e6a1ca1db8804c80e40e0e71de4c

commit r11-9700-g40e9979cf531e6a1ca1db8804c80e40e0e71de4c
Author: Kito Cheng <kito.cheng@sifive.com>
Date:   Mon Nov 8 22:45:49 2021 +0800

    [PR/target 102957] Allow Z*-ext extension with only 2 char.
    
    We was assume the Z* extension should be more than 2 char, so we put an
    assertion there, but it should just an error or warning rather than an
    assertion, however RISC-V has add `Zk` extension, which just 2 char, so
    actually, we should just allow that.
    
    gcc/ChangeLog
    
            PR target/102957
            * common/config/riscv/riscv-common.c (multi_letter_subset_rank): Remove
            assertion for Z*-ext.
    
    gcc/testsuite/ChangeLog
    
            * gcc.target/riscv/pr102957.c: New.
    
    (cherry picked from commit abe562bb01479ea2c8952ad98714f3225527aa7e)
Comment 5 Kito Cheng 2022-03-28 06:43:47 UTC
Backported to GCC 11.
Comment 6 GCC Commits 2023-08-29 13:49:39 UTC
The master branch has been updated by Tsukasa OI <a4lg@gcc.gnu.org>:

https://gcc.gnu.org/g:8b0662254cdac3e0b670c1c54752e1d43113b0f4

commit r14-3544-g8b0662254cdac3e0b670c1c54752e1d43113b0f4
Author: Tsukasa OI <research_trasio@irq.a4lg.com>
Date:   Fri Aug 11 06:09:34 2023 +0000

    RISC-V: Make PR 102957 tests more comprehensive
    
    Commit c283c4774d1c ("RISC-V: Throw compilation error for unknown
    extensions") changed how do we handle unknown extensions and
    commit 6f709f79c915a ("[committed] [RISC-V] Fix expected diagnostic messages
    in testsuite") "fixed" test failures caused by that change (on pr102957.c,
    by testing the error message after the first change).
    
    However, the latter change will partially break the original intent of PR
    102957 test case because we wanted to make sure that we can parse a valid
    two-letter extension name.
    
    Fortunately, there is a valid two-letter extension name, 'Zk' (standard
    scalar cryptography extension superset with NIST algorithm suite).
    
    This commit adds pr102957-2.c to make sure that there will be no errors if
    we parse a valid two-letter extension name.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/riscv/pr102957-2.c: New test case using the 'Zk'
            extension to continue testing whether we can use valid two-letter
            extensions.