https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116303

            Bug ID: 116303
           Summary: RISC-V: -mcpu doesn't populate .attribute arch string
                    when directly invoking cc1
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ewlu at rivosinc dot com
  Target Milestone: ---

Simple testcase:

int square(int num) {
    return num * num;
}

running the command./build-gcc-linux-stage1/gcc/cc1 ./testcase.c -o testcase.s
-mcpu=sifive-x280 -O3 results in the following assembly

ewlu@ewlu:/scratch/ewlu/ci/triage/baseline/build$ cat testcase.s
        .file   "testcase.c"
        .option nopic
        .attribute arch, ""
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .align  2
        .globl  square
        .type   square, @function
square:
.LFB0:
        .cfi_startproc
        addi    sp,sp,-16
        .cfi_def_cfa_offset 16
        mv      a1,a0
        sw      ra,12(sp)
        .cfi_offset 1, -4
        call    __mulsi3
        lw      ra,12(sp)
        .cfi_restore 1
        addi    sp,sp,16
        .cfi_def_cfa_offset 0
        jr      ra
        .cfi_endproc
.LFE0:
        .size   square, .-square
        .globl  __mulsi3
        .ident  "GCC: (GNU) 15.0.0 20240806 (experimental)"
        .section        .note.GNU-stack,"",@progbits

whereas running the command
./build-gcc-linux-stage1/gcc/xgcc -B./build-gcc-linux-stage1/gcc/ ./testcase.c
-S -o testcase.s -mcpu=sifive-x280 -O3
results in the following assembly

ewlu@ewlu:/scratch/ewlu/ci/triage/baseline/build$
./build-gcc-linux-stage1/gcc/xgcc -B./build-gcc-linux-stage1/gcc/ ./testcase.c
-S -o testcase.s -mcpu=sifive-x280 -O3
ewlu@ewlu:/scratch/ewlu/ci/triage/baseline/build$ cat testcase.s
        .file   "testcase.c"
        .option nopic
        .attribute arch,
"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zaamo1p0_zalrsc1p0_zfh1p0_zfhmin1p0_zca1p0_zcd1p0_zba1p0_zbb1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvfh1p0_zvl128b1p0_zvl256b1p0_zvl32b1p0_zvl512b1p0_zvl64b1p0"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .align  1
        .globl  square
        .type   square, @function
square:
.LFB0:
        .cfi_startproc
        mulw    a0,a0,a0
        ret
        .cfi_endproc
.LFE0:
        .size   square, .-square
        .ident  "GCC: (GNU) 15.0.0 20240806 (experimental)"
        .section        .note.GNU-stack,"",@progbits

configure:
/scratch/ewlu/ci/triage/baseline/build/../gcc/configure
--target=riscv64-unknown-linux-gnu
--prefix=/scratch/ewlu/ci/triage/baseline/build
--with-sysroot=/scratch/ewlu/ci/triage/baseline/build/sysroot --with-newlib
--without-headers --disable-shared --disable-threads --with-system-zlib
--enable-tls --enable-languages=c --disable-libatomic --disable-libmudflap
--disable-libssp --disable-libquadmath --disable-libgomp --disable-nls
--disable-bootstrap --src=../../gcc --enable-multilib --with-abi=lp64d
--with-arch=rv64imafdc --with-tune=rocket --with-isa-spec=20191213
CFLAGS_FOR_TARGET=-O2    -mcmodel=medlow CXXFLAGS_FOR_TARGET=-O2   
-mcmodel=medlow

Reply via email to