public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/116303] New: RISC-V: -mcpu doesn't populate .attribute arch string when directly invoking cc1
@ 2024-08-08 23:20 ewlu at rivosinc dot com
  2024-08-08 23:30 ` [Bug target/116303] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: ewlu at rivosinc dot com @ 2024-08-08 23:20 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug target/116303] RISC-V: -mcpu doesn't populate .attribute arch string when directly invoking cc1
  2024-08-08 23:20 [Bug target/116303] New: RISC-V: -mcpu doesn't populate .attribute arch string when directly invoking cc1 ewlu at rivosinc dot com
@ 2024-08-08 23:30 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-08 23:30 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is expected.

Basically the driver expands mcpu when invoked via riscv_expand_arch_from_cpu
function.

%{mcpu=*:%:riscv_expand_arch_from_cpu(%* %(VALUE))}}


See r11-3906-g72eb8335848be7 on how it is implemented fully. But this is by
design. That is if you are invoking cc1 directly you should follow the same way
the driver does it.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-08 23:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-08 23:20 [Bug target/116303] New: RISC-V: -mcpu doesn't populate .attribute arch string when directly invoking cc1 ewlu at rivosinc dot com
2024-08-08 23:30 ` [Bug target/116303] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).