Skip to content

add generic GCC and Clang compiler flags for RISC-V#4489

Merged
boegel merged 2 commits intoeasybuilders:developfrom
bedroge:riscv_generic_flags
Mar 29, 2024
Merged

add generic GCC and Clang compiler flags for RISC-V#4489
boegel merged 2 commits intoeasybuilders:developfrom
bedroge:riscv_generic_flags

Conversation

@bedroge
Copy link
Copy Markdown
Contributor

@bedroge bedroge commented Mar 29, 2024

This adds compiler flags (GCC and Clang) for generic builds on RISC-V. It's a bit more involved than on for instance x86_64, because of all the different extensions and ABIs, see:
https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html#index-march-14
https://five-embeddev.com/toolchain/2019/06/26/gcc-targets/

I've picked a sensible default, which also is in line with what Gentoo uses:
https://wiki.gentoo.org/wiki/RISC-V_Multilib

The optimal flags are a bit more complex, since there is no such things as -march=native for RISC-V. I'll try to take a stab at in a follow-up PR.

@bedroge bedroge added enhancement EESSI Related to EESSI project labels Mar 29, 2024
@bedroge
Copy link
Copy Markdown
Contributor Author

bedroge commented Mar 29, 2024

Before:

user@starfive:/nvme/gcc$ eb zlib-1.2.13-GCCcore-13.2.0.eb --installpath=/nvme/easybuild-generic --optarch=GENERIC
== Temporary log file in case of crash /nvme/eb/tmp/eb-77o66l2d/easybuild-lg2hpeci.log
== found valid index for /nvme/easybuild/software/EasyBuild/4.9.0/easybuild/easyconfigs, so using it...
== found valid index for /nvme/easybuild/software/EasyBuild/4.9.0/easybuild/easyconfigs, so using it...
== processing EasyBuild easyconfig /nvme/easybuild/software/EasyBuild/4.9.0/easybuild/easyconfigs/z/zlib/zlib-1.2.13-GCCcore-13.2.0.eb
== building and installing zlib/1.2.13-GCCcore-13.2.0...
== fetching files...
== creating build dir, resetting environment...
== unpacking...
== patching...
== preparing...
== ... (took 1 secs)
== FAILED: Installation ended unsuccessfully (build directory: /nvme/eb/build/zlib/1.2.13/GCCcore-13.2.0): build failed (first 300 chars): Don't know how to
set generic optarch flags for RISC-V-64/RISC-V! Use --optarch='<flags>' to override (see http://easybuild.readthedocs.io/en/latest/Controlling_compiler_optim
ization_flags.html for details) and consider contributing your settings back (see http://easybuild.readthedocs.io/en/latest/C (took 1 secs)
== Results of the build can be found in the log file(s) /nvme/eb/tmp/eb-77o66l2d/easybuild-zlib-1.2.13-20240329.081401.vbrch.log
ERROR: Build of /nvme/easybuild/software/EasyBuild/4.9.0/easybuild/easyconfigs/z/zlib/zlib-1.2.13-GCCcore-13.2.0.eb failed (err: "build failed (first 300 cha
rs): Don't know how to set generic optarch flags for RISC-V-64/RISC-V! Use --optarch='<flags>' to override (see http://easybuild.readthedocs.io/en/latest/Con
trolling_compiler_optimization_flags.html for details) and consider contributing your settings back (see http://easybuild.readthedocs.io/en/latest/C")

After:

user@starfive:/nvme/gcc$ eb zlib-1.2.13-GCCcore-13.2.0.eb --installpath=/nvme/easybuild-generic --optarch=GENERIC
== Temporary log file in case of crash /nvme/eb/tmp/eb-4vr3683t/easybuild-uleen25o.log
== found valid index for /nvme/easybuild/software/EasyBuild/4.9.0/easybuild/easyconfigs, so using it...
== found valid index for /nvme/easybuild/software/EasyBuild/4.9.0/easybuild/easyconfigs, so using it...
== processing EasyBuild easyconfig /nvme/easybuild/software/EasyBuild/4.9.0/easybuild/easyconfigs/z/zlib/zlib-1.2.13-GCCcore-13.2.0.eb
== building and installing zlib/1.2.13-GCCcore-13.2.0...
== fetching files...
== creating build dir, resetting environment...
== unpacking...
== patching...
== preparing...
== configuring...
== ... (took 1 secs)
== building...
== ... (took 9 secs)
== testing...
== installing...
== taking care of extensions...
== restore after iterating...
== postprocessing...
== sanity checking...
== cleaning up...
== creating module...
== ... (took 1 secs)
== permissions...
== packaging...
== COMPLETED: Installation ended successfully (took 15 secs)
== Results of the build can be found in the log file(s) /nvme/easybuild-generic/software/zlib/1.2.13-GCCcore-13.2.0/easybuild/easybuild-zlib-1.2.13-20240329.081717.log
== Build succeeded for 1 out of 1
== Temporary log file(s) /nvme/eb/tmp/eb-4vr3683t/easybuild-uleen25o.log* have been removed.
== Temporary directory /nvme/eb/tmp/eb-4vr3683t has been removed.

# some relevant lines from the build log:
gcc -O2 -ftree-vectorize -march=rv64gc -mabi=lp64d -fno-math-errno -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN  -c -o gzlib.o gzlib.c
gcc -O2 -ftree-vectorize -march=rv64gc -mabi=lp64d -fno-math-errno -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN  -c -o gzread.o gzread.c

Copy link
Copy Markdown
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@boegel boegel added this to the release after 4.9.0 milestone Mar 29, 2024
@boegel boegel merged commit 20df9fd into easybuilders:develop Mar 29, 2024
@bedroge bedroge deleted the riscv_generic_flags branch March 29, 2024 18:04
@boegel boegel added the riscv label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

EESSI Related to EESSI project enhancement riscv

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants