diff options
author | Alex Chiang <alex.chiang@sifive.com> | 2023-06-01 00:19:00 -0700 |
---|---|---|
committer | alexsifivetw <alex.chiang@sifive.com> | 2023-06-01 02:12:22 -0700 |
commit | bb74af5a874c8b521ae0159ba4d892af9df93d09 (patch) | |
tree | 91d618c63550a8de0c171c517b859ab4c8c11187 | |
parent | ea26fd6cb82aaa8e7fc95adc704442dc466dac9e (diff) | |
download | riscv-gnu-toolchain-bb74af5a874c8b521ae0159ba4d892af9df93d09.zip riscv-gnu-toolchain-bb74af5a874c8b521ae0159ba4d892af9df93d09.tar.gz riscv-gnu-toolchain-bb74af5a874c8b521ae0159ba4d892af9df93d09.tar.bz2 |
Enable riscv llvm & qemu build flow
Update readme about llvm & qemu examples
Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
-rwxr-xr-x | .github/setup-apt.sh | 2 | ||||
-rw-r--r-- | .github/workflows/build.yaml | 58 | ||||
-rw-r--r-- | .gitmodules | 2 | ||||
-rw-r--r-- | Makefile.in | 68 | ||||
-rw-r--r-- | README.md | 45 | ||||
m--------- | binutils | 0 | ||||
-rwxr-xr-x | configure | 80 | ||||
-rw-r--r-- | configure.ac | 25 | ||||
m--------- | dejagnu | 0 | ||||
m--------- | glibc | 0 | ||||
-rwxr-xr-x | scripts/march-to-cpu-opt | 60 | ||||
-rwxr-xr-x | scripts/testsuite-filter | 2 | ||||
-rwxr-xr-x | scripts/wrapper/qemu/riscv64-unknown-linux-gnu-run | 4 |
13 files changed, 291 insertions, 55 deletions
diff --git a/.github/setup-apt.sh b/.github/setup-apt.sh index 5ce65e5..63bd682 100755 --- a/.github/setup-apt.sh +++ b/.github/setup-apt.sh @@ -5,4 +5,4 @@ dpkg --add-architecture i386 apt update apt install -y autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev \ libgmp-dev gawk build-essential bison flex texinfo gperf libtool \ - patchutils bc zlib1g-dev libexpat-dev git + patchutils bc zlib1g-dev libexpat-dev git ninja-build cmake ibglib2.0-dev expect diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1139913..0f05d50 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,6 +36,13 @@ jobs: ./configure --prefix=/opt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]} sudo make -j $(nproc) ${{ matrix.mode }} + - name: make report + if: | + matrix.os == 'ubuntu-20.04' + && (matrix.mode == 'linux' || matrix.mode == 'newlib') + run: | + sudo make report-${{ matrix.mode }} -j $(nproc) + - name: tarball build run: tar czvf riscv.tar.gz -C /opt/ riscv/ @@ -57,3 +64,54 @@ jobs: with: name: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }} path: riscv.tar.gz + + build-multilib: + if: ${{ false }} # Disable until multilib errors are triaged + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04] + mode: [newlib, linux] + target: [rv64gc-lp64d] + steps: + - uses: actions/checkout@v2 + + - name: initialize submodules + run: | + git submodule init + git submodule update --recursive --progress --recommend-shallow + + - name: install dependencies + run: sudo ./.github/setup-apt.sh + + - name: build toolchain + run: | + TARGET_TUPLE=($(echo ${{ matrix.target }} | tr "-" "\n")) + ./configure --prefix=/opt/riscv --with-arch=${TARGET_TUPLE[0]} --with-abi=${TARGET_TUPLE[1]} --enable-multilib + sudo make -j $(nproc) ${{ matrix.mode }} + + - name: make report + run: | + sudo make report-${{ matrix.mode }} -j $(nproc) + + - name: tarball build + run: tar czvf riscv.tar.gz -C /opt/ riscv/ + + - name: generate prebuilt toolchain name + id: toolchain-name-generator + run: | + if [[ "${{ matrix.target }}" == *"32"* ]]; then BITS=32; else BITS=64; fi + case "${{ matrix.mode }}" in + "linux") + MODE="glibc";; + "musl") + MODE="musl";; + *) + MODE="elf";; + esac + echo ::set-output name=TOOLCHAIN_NAME::riscv$BITS-$MODE-${{ matrix.os }}-multilib-nightly + + - uses: actions/upload-artifact@v2 + with: + name: ${{ steps.toolchain-name-generator.outputs.TOOLCHAIN_NAME }} + path: riscv.tar.gz diff --git a/.gitmodules b/.gitmodules index 87e7839..340189f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "binutils"] path = binutils url = https://sourceware.org/git/binutils-gdb.git - branch = binutils-2_39-branch + branch = binutils-2_40-branch [submodule "gcc"] path = gcc url = https://gcc.gnu.org/git/gcc.git diff --git a/Makefile.in b/Makefile.in index d4cc9a4..f44fbd1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -13,17 +13,20 @@ QEMU_SRCDIR := @with_qemu_src@ SPIKE_SRCDIR := @with_spike_src@ PK_SRCDIR := @with_pk_src@ LLVM_SRCDIR := @with_llvm_src@ +DEJAGNU_SRCDIR := @with_dejagnu_src@ +DEBUG_INFO := @debug_info@ +DEJAGNU_SRCDIR := @with_dejagnu_src@ SIM ?= @WITH_SIM@ -ifeq ($(srcdir)/riscv-gcc,$(GCC_SRCDIR)) +ifeq ($(srcdir)/gcc,$(GCC_SRCDIR)) # We need a relative source dir for the gcc configure, to make msys2 mingw64 # builds work. Mayberelsrcdir is relative if a relative path was used to run # configure, otherwise absolute, so we have to check. mayberelsrcdir := @top_srcdir@ gccsrcdir := $(shell case $(mayberelsrcdir) in \ - ([\\/]* | ?:[\\/]*) echo $(mayberelsrcdir)/riscv-gcc ;; \ - (*) echo ../$(mayberelsrcdir)/riscv-gcc ;; \ + ([\\/]* | ?:[\\/]*) echo $(mayberelsrcdir)/gcc ;; \ + (*) echo ../$(mayberelsrcdir)/gcc ;; \ esac) else gccsrcdir := $(abspath $(GCC_SRCDIR)) @@ -76,9 +79,9 @@ LINUX_TUPLE ?= $(call make_tuple,$(XLEN),linux-gnu) NEWLIB_TUPLE ?= $(call make_tuple,$(XLEN),elf) MUSL_TUPLE ?= $(call make_tuple,$(XLEN),linux-musl) -CFLAGS_FOR_TARGET := $(CFLAGS_FOR_TARGET_EXTRA) @target_cflags@ @cmodel@ -CXXFLAGS_FOR_TARGET := $(CXXFLAGS_FOR_TARGET_EXTRA) @target_cxxflags@ @cmodel@ -ASFLAGS_FOR_TARGET := $(ASFLAGS_FOR_TARGET_EXTRA) @cmodel@ +CFLAGS_FOR_TARGET := $(CFLAGS_FOR_TARGET_EXTRA) $(DEBUG_INFO) @target_cflags@ @cmodel@ +CXXFLAGS_FOR_TARGET := $(CXXFLAGS_FOR_TARGET_EXTRA) $(DEBUG_INFO) @target_cxxflags@ @cmodel@ +ASFLAGS_FOR_TARGET := $(ASFLAGS_FOR_TARGET_EXTRA) $(DEBUG_INFO) @cmodel@ # --with-expat is required to enable XML support used by OpenOCD. BINUTILS_TARGET_FLAGS := --with-expat=yes $(BINUTILS_TARGET_FLAGS_EXTRA) BINUTILS_NATIVE_FLAGS := $(BINUTILS_NATIVE_FLAGS_EXTRA) @@ -94,6 +97,7 @@ NEWLIB_CC_FOR_TARGET ?= $(NEWLIB_TUPLE)-gcc NEWLIB_CXX_FOR_TARGET ?= $(NEWLIB_TUPLE)-g++ NEWLIB_TARGET_BOARDS ?= $(shell echo "$(NEWLIB_MULTILIB_NAMES)" | sed 's!\([_a-z0-9]*\)-\([_a-z0-9]*\)!riscv-sim/-march=\1/-mabi=\2/@cmodel@!g') NEWLIB_NANO_TARGET_BOARDS ?= $(shell echo "$(NEWLIB_MULTILIB_NAMES)" | sed 's!\([_a-z0-9]*\)-\([_a-z0-9]*\)!riscv-sim-nano/-march=\1/-mabi=\2/@cmodel@!g') +NEWLIB_CC_FOR_MULTILIB_INFO := $(NEWLIB_CC_FOR_TARGET) MUSL_TARGET_FLAGS := $(MUSL_TARGET_FLAGS_EXTRA) MUSL_CC_FOR_TARGET ?= $(MUSL_TUPLE)-gcc @@ -183,10 +187,9 @@ report-gdb: report-gdb-@default_target@ .PHONY: build-sim ifeq ($(SIM),qemu) -QEMU_CPU=$(shell $(srcdir)/scripts/march-to-cpu-opt $(WITH_ARCH)) -SIM_PATH:=$(srcdir)/scripts/wrapper/qemu -SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" QEMU_CPU="$(QEMU_CPU)" -SIM_STAMP:= stamps/build-qemu +SIM_PATH:=$(srcdir)/scripts/wrapper/qemu:$(srcdir)/scripts +SIM_PREPARE:=PATH="$(SIM_PATH):$(INSTALL_DIR)/bin:$(PATH)" RISC_V_SYSROOT="$(SYSROOT)" +SIM_STAMP:= stamps/build-qemu stamps/install-python-package else ifeq ($(SIM),spike) # Using spike simulator. @@ -278,6 +281,7 @@ endif ifeq ($(findstring $(srcdir),$(SPIKE_SRCDIR)),$(srcdir)) SPIKE_SRC_GIT := $(SPIKE_SRCDIR)/.git +PK_SRC_GIT := $(PK_SRCDIR)/.git else SPIKE_SRC_GIT := endif @@ -288,6 +292,12 @@ else LLVM_SRC_GIT := endif +ifeq ($(findstring $(srcdir),$(DEJAGNU_SRCDIR)),$(srcdir)) +DEJAGNU_SRC_GIT := $(DEJAGNU_SRCDIR)/.git +else +DEJAGNU_SRC_GIT := +endif + ifneq ("$(wildcard $(GCC_SRCDIR)/.git)","") GCCPKGVER := g$(shell git -C $(GCC_SRCDIR) describe --always --dirty --exclude '*') else @@ -380,8 +390,8 @@ endif cd $(notdir $@) && \ CC="$(GLIBC_CC_FOR_TARGET) $($@_CFLAGS)" \ CXX="this-is-not-the-compiler-youre-looking-for" \ - CFLAGS="$(CFLAGS_FOR_TARGET) -g -O2 $($@_CFLAGS)" \ - CXXFLAGS="$(CXXFLAGS_FOR_TARGET) -g -O2 $($@_CFLAGS)" \ + CFLAGS="$(CFLAGS_FOR_TARGET) -O2 $($@_CFLAGS)" \ + CXXFLAGS="$(CXXFLAGS_FOR_TARGET) -O2 $($@_CFLAGS)" \ ASFLAGS="$(ASFLAGS_FOR_TARGET) $($@_CFLAGS)" \ $</configure \ --host=$(call make_tuple,$($@_XLEN),linux-gnu) \ @@ -429,6 +439,7 @@ stamps/build-gcc-linux-stage1: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-binutil $(WITH_ARCH) \ $(WITH_TUNE) \ $(WITH_ISA_SPEC) \ + $(GCC_EXTRA_CONFIGURE_FLAGS) \ CFLAGS_FOR_TARGET="-O2 $(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="-O2 $(CXXFLAGS_FOR_TARGET)" $(MAKE) -C $(notdir $@) inhibit-libc=true all-gcc @@ -464,6 +475,7 @@ stamps/build-gcc-linux-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) $(addprefix stamps/b $(WITH_ARCH) \ $(WITH_TUNE) \ $(WITH_ISA_SPEC) \ + $(GCC_EXTRA_CONFIGURE_FLAGS) \ CFLAGS_FOR_TARGET="-O2 $(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="-O2 $(CXXFLAGS_FOR_TARGET)" $(MAKE) -C $(notdir $@) @@ -518,6 +530,7 @@ stamps/build-gcc-linux-native: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-gcc-lin $(WITH_ARCH) \ $(WITH_TUNE) \ $(WITH_ISA_SPEC) \ + $(GCC_EXTRA_CONFIGURE_FLAGS) \ $(MAKE) -C $(notdir $@) $(MAKE) -C $(notdir $@) install cp -a $(INSTALL_DIR)/$(LINUX_TUPLE)/lib* $(SYSROOT) @@ -596,6 +609,7 @@ stamps/build-gcc-newlib-stage1: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-binuti $(WITH_ARCH) \ $(WITH_TUNE) \ $(WITH_ISA_SPEC) \ + $(GCC_EXTRA_CONFIGURE_FLAGS) \ CFLAGS_FOR_TARGET="-Os $(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="-Os $(CXXFLAGS_FOR_TARGET)" $(MAKE) -C $(notdir $@) all-gcc @@ -645,8 +659,13 @@ stamps/build-newlib-nano: $(NEWLIB_SRCDIR) $(NEWLIB_SRC_GIT) stamps/build-gcc-ne stamps/merge-newlib-nano: stamps/build-newlib-nano stamps/build-newlib # Copy nano library files into newlib install dir. + if [ -f $(INSTALL_DIR)/bin/$(NEWLIB_TUPLE)-gcc ] ; then \ + export NEWLIB_CC_FOR_MULTILIB_INFO="$(INSTALL_DIR)/bin/$(NEWLIB_TUPLE)-gcc"; \ + else \ + export NEWLIB_CC_FOR_MULTILIB_INFO="$(NEWLIB_CC_FOR_TARGET)"; \ + fi set -e; \ - for ml in `$(INSTALL_DIR)/bin/$(NEWLIB_TUPLE)-gcc --print-multi-lib`; \ + for ml in `${NEWLIB_CC_FOR_MULTILIB_INFO} --print-multi-lib`; \ do \ mld=`echo $${ml} | sed -e 's/;.*$$//'`; \ cp $(builddir)/install-newlib-nano/$(NEWLIB_TUPLE)/lib/$${mld}/libc.a \ @@ -696,6 +715,7 @@ stamps/build-gcc-newlib-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-newlib $(WITH_ARCH) \ $(WITH_TUNE) \ $(WITH_ISA_SPEC) \ + $(GCC_EXTRA_CONFIGURE_FLAGS) \ CFLAGS_FOR_TARGET="-Os $(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="-Os $(CXXFLAGS_FOR_TARGET)" $(MAKE) -C $(notdir $@) @@ -758,6 +778,7 @@ stamps/build-gcc-musl-stage1: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-binutils $(WITH_ARCH) \ $(WITH_TUNE) \ $(WITH_ISA_SPEC) \ + $(GCC_EXTRA_CONFIGURE_FLAGS) \ CFLAGS_FOR_TARGET="-O2 $(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="-O2 $(CXXFLAGS_FOR_TARGET)" $(MAKE) -C $(notdir $@) inhibit-libc=true all-gcc @@ -785,8 +806,8 @@ stamps/build-musl-linux: $(MUSL_SRCDIR) $(MUSL_SRC_GIT) stamps/build-gcc-musl-st cd $(notdir $@) && \ CC="$(MUSL_CC_FOR_TARGET) $($@_CFLAGS)" \ CXX="$(MUSL_CXX_FOR_TARGET) $($@_CFLAGS)" \ - CFLAGS="$(CFLAGS_FOR_TARGET) -g -O2 $($@_CFLAGS)" \ - CXXFLAGS="$(CXXFLAGS_FOR_TARGET) -g -O2 $($@_CFLAGS)" \ + CFLAGS="$(CFLAGS_FOR_TARGET) -O2 $($@_CFLAGS)" \ + CXXFLAGS="$(CXXFLAGS_FOR_TARGET) -O2 $($@_CFLAGS)" \ ASFLAGS="$(ASFLAGS_FOR_TARGET) $($@_CFLAGS)" \ $</configure \ --host=$(MUSL_TUPLE) \ @@ -826,6 +847,7 @@ stamps/build-gcc-musl-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-musl-lin $(WITH_ARCH) \ $(WITH_TUNE) \ $(WITH_ISA_SPEC) \ + $(GCC_EXTRA_CONFIGURE_FLAGS) \ CFLAGS_FOR_TARGET="-O2 $(CFLAGS_FOR_TARGET)" \ CXXFLAGS_FOR_TARGET="-O2 $(CXXFLAGS_FOR_TARGET)" $(MAKE) -C $(notdir $@) @@ -843,7 +865,7 @@ stamps/build-spike: $(SPIKE_SRCDIR) $(SPIKE_SRC_GIT) mkdir -p $(dir $@) date > $@ -stamps/build-pk32: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2 +stamps/build-pk32: $(PK_SRCDIR) $(PK_SRC_GIT) stamps/build-gcc-newlib-stage2 rm -rf $@ $(notdir $@) mkdir $(notdir $@) cd $(notdir $@) && $</configure \ @@ -856,7 +878,7 @@ stamps/build-pk32: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2 mkdir -p $(dir $@) date > $@ -stamps/build-pk64: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2 +stamps/build-pk64: $(PK_SRCDIR) $(PK_SRC_GIT) stamps/build-gcc-newlib-stage2 rm -rf $@ $(notdir $@) mkdir $(notdir $@) cd $(notdir $@) && $</configure \ @@ -868,6 +890,10 @@ stamps/build-pk64: $(PK_SRCDIR) stamps/build-gcc-newlib-stage2 mkdir -p $(dir $@) date > $@ +stamps/install-python-package: + python3 -m pip install --user pyelftools + date > $@ + stamps/build-qemu: $(QEMU_SRCDIR) $(QEMU_SRC_GIT) rm -rf $@ $(notdir $@) mkdir $(notdir $@) @@ -893,9 +919,10 @@ stamps/build-llvm-linux: $(LLVM_SRCDIR) $(LLVM_SRC_GIT) \ # Without a proper GCC install directory libgcc won't be found. # As a workaround we have to merge both paths: mkdir -p $(SYSROOT)/lib/ - ln -s $(INSTALL_DIR)/lib/gcc $(SYSROOT)/lib/gcc + ln -s -f $(INSTALL_DIR)/lib/gcc $(SYSROOT)/lib/gcc rm -rf $@ $(notdir $@) mkdir $(notdir $@) + cd $(notdir $@) && ln -f -s $(SYSROOT) sysroot cd $(notdir $@) && \ cmake $(LLVM_SRCDIR)/llvm \ -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) \ @@ -904,12 +931,13 @@ stamps/build-llvm-linux: $(LLVM_SRCDIR) $(LLVM_SRC_GIT) \ -DLLVM_ENABLE_PROJECTS="clang;lld" \ -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \ -DLLVM_DEFAULT_TARGET_TRIPLE="$(LINUX_TUPLE)" \ - -DDEFAULT_SYSROOT="$(INSTALL_DIR)/sysroot" \ + -DDEFAULT_SYSROOT="../sysroot" \ -DLLVM_RUNTIME_TARGETS=$(call make_tuple,$(XLEN),linux-gnu) \ -DLLVM_INSTALL_TOOLCHAIN_ONLY=On \ -DLLVM_PARALLEL_LINK_JOBS=4 $(MAKE) -C $(notdir $@) $(MAKE) -C $(notdir $@) install + cp $(notdir $@)/lib/riscv64-unknown-linux-gnu/libc++* $(SYSROOT)/lib cd $(INSTALL_DIR)/bin && ln -s clang $(LINUX_TUPLE)-clang mkdir -p $(dir $@) && touch $@ @@ -917,7 +945,7 @@ stamps/build-llvm-newlib: echo "Building LLVM is only supported in combination with a Linux toolchain." exit 1 -stamps/build-dejagnu: $(srcdir)/dejagnu $(srcdir)/dejagnu/.git +stamps/build-dejagnu: $(DEJAGNU_SRCDIR) $(DEJAGNU_SRC_GIT) rm -rf $@ $(notdir $@) mkdir $(notdir $@) cd $(notdir $@) && $</configure \ @@ -20,7 +20,7 @@ Several standard packages are needed to build the toolchain. On Ubuntu, executing the following command should suffice: - $ sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build + $ sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake ibglib2.0-dev On Fedora/CentOS/RHEL OS, executing the following command should suffice: @@ -34,9 +34,7 @@ Also available for Arch users on the AUR: [https://aur.archlinux.org/packages/ri On OS X, you can use [Homebrew](http://brew.sh) to install the dependencies: - $ brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat - $ brew tap discoteq/discoteq - $ brew install flock + $ brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat texinfo flock To build the glibc (Linux) on OS X, you will need to build within a case-sensitive file system. The simplest approach is to create and mount a new disk image with @@ -50,9 +48,9 @@ complete the process. ### Installation (Newlib) -To build the Newlib cross-compiler, pick an install path. If you choose, -say, `/opt/riscv`, then add `/opt/riscv/bin` to your `PATH` now. Then, simply -run the following command: +To build the Newlib cross-compiler, pick an install path (that is writeable). +If you choose, say, `/opt/riscv`, then add `/opt/riscv/bin` to your `PATH`. +Then, simply run the following command: ./configure --prefix=/opt/riscv make @@ -61,9 +59,9 @@ You should now be able to use riscv64-unknown-elf-gcc and its cousins. ### Installation (Linux) -To build the Linux cross-compiler, pick an install path. If you choose, -say, `/opt/riscv`, then add `/opt/riscv/bin` to your `PATH` now. Then, simply -run the following command: +To build the Linux cross-compiler, pick an install path (that is writeable). +If you choose, say, `/opt/riscv`, then add `/opt/riscv/bin` to your `PATH`. +Then, simply run the following command: ./configure --prefix=/opt/riscv make linux @@ -137,6 +135,9 @@ devtoolset-7 works. There are a number of additional options that may be passed to configure. See './configure --help' for more details. +Also you can define extra flags to pass to specific projects: ```BINUTILS_NATIVE_FLAGS_EXTRA, BINUTILS_TARGET_FLAGS_EXTRA, GCC_EXTRA_CONFIGURE_FLAGS, GDB_NATIVE_FLAGS_EXTRA, GDB_TARGET_FLAGS_EXTRA, GLIBC_NATIVE_FLAGS_EXTRA, GLIBC_TARGET_FLAGS_EXTRA```. +Example: ```GCC_EXTRA_CONFIGURE_FLAGS=--with-gmp=/opt/gmp make linux``` + #### Set default ISA spec version `--with-isa-spec=` can specify the default version of the RISC-V Unprivileged @@ -144,7 +145,7 @@ configure. See './configure --help' for more details. Possible options are: `2.2`, `20190608` and `20191213`. -The default version is `2.2`. +The default version is `20191213`. More details about this option you can refer this post [RISC-V GNU toolchain bumping default ISA spec to 20191213](https://groups.google.com/a/groups.riscv.org/g/sw-dev/c/aE1ZeHHCYf4). @@ -271,10 +272,10 @@ execute the generated binaries using QEMU: make -j$(nproc) all build-sim SIM=qemu # Build C application with clang $RISCV/bin/clang -march=rv64imafdc -o hello_world hello_world.c - $RISCV/bin/qemu-riscv64 ./hello-world + $RISCV/bin/qemu-riscv64 -L $RISCV/sysroot ./hello_world # Build C++ application with clang $RISCV/bin/clang++ -march=rv64imafdc -stdlib=libc++ -o hello_world_cpp hello_world_cpp.cxx - $RISCV/bin/qemu-riscv64 ./hello-world_cpp + $RISCV/bin/qemu-riscv64 -L $RISCV/sysroot ./hello_world_cpp ### Development @@ -293,9 +294,9 @@ Or you can upgrade specific submodule only. git submodule update --remote <component> -For example, upgrade riscv-gcc only, you can using following command: +For example, upgrade gcc only, you can using following command: - git submodule update --remote riscv-gcc + git submodule update --remote gcc #### How to Check Which Branch are Used for Specific submodule @@ -303,15 +304,15 @@ The branch info has recorded in `.gitmodules` file, which can set or update via `git submodule add -b` or `git submodule set-branch`. However the only way to check which branch are using is to check `.gitmodules` -file, here is the example for `riscv-gcc`, it using riscv-gcc-10.2.0 branch, so -it will has a section named `riscv-gcc` and has a field `branch` is -`riscv-gcc-10.2.0`. +file, here is the example for `gcc`, it's using releases/gcc-12 branch, so +it will has a section named `gcc` and has a field `branch` is +`releases/gcc-12`. ``` -[submodule "riscv-gcc"] - path = riscv-gcc - url = ../riscv-gcc.git - branch = riscv-gcc-10.2.0 +[submodule "gcc"] + path = gcc + url = ../gcc.git + branch = releases/gcc-12 ``` #### Use Source Tree Other Than `riscv-gnu-toolchain` diff --git a/binutils b/binutils -Subproject b51c2fec1da205ea3e7354cbb3e253018d64873 +Subproject b2bc62b7b4e7638c3a249d2d2728ceb4d5f2b22 @@ -589,6 +589,10 @@ enable_libsanitizer with_linux_headers_src with_llvm_src with_pk_src +with_dejagnu_src +with_pk_src +with_dejagnu_src +with_pk_src with_spike_src with_qemu_src with_gdb_src @@ -616,6 +620,7 @@ WITH_ISA_SPEC WITH_TUNE WITH_ABI WITH_ARCH +debug_info default_target FETCHER FTP @@ -676,6 +681,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking enable_linux +enable_debug_info with_arch with_abi with_tune @@ -702,6 +708,7 @@ with_qemu_src with_spike_src with_pk_src with_llvm_src +with_dejagnu_src with_linux_headers_src enable_libsanitizer enable_qemu_system @@ -1325,6 +1332,9 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-linux set linux as the default make target [--disable-linux] + --enable-debug-info build glibc/musl/newlibc/libgcc with debug + information + --disable-debug-info build glibc and musl without debug infromation --enable-multilib build both RV32 and RV64 runtime libraries (only RV64 for musl libc) [--disable-multilib] --enable-gcc-checking Enable gcc internal checking, it will make gcc very @@ -1341,8 +1351,9 @@ Optional Packages: --with-arch=rv64imafdc Sets the base RISC-V ISA, defaults to rv64imafdc --with-abi=lp64d Sets the base RISC-V ABI, defaults to lp64d --with-tune=rocket Set the base RISC-V CPU, defaults to rocket - --with-isa-spec=2.2 Set the default ISA spec version, default to 2.2, - available options: 2.2, 20190608, 20191213 + --with-isa-spec=20191213 + Set the default ISA spec version, default to + 20191213, available options: 2.2, 20190608, 20191213 --with-sim=qemu Sets the base RISC-V Simulator, defaults to qemu --with-multilib-generator Multi-libs configuration string, only supported for @@ -1369,6 +1380,8 @@ Optional Packages: --with-spike-src Set spike source path, use builtin source by default --with-pk-src Set pk source path, use builtin source by default --with-llvm-src Set llvm source path, use builtin source by default + --with-dejagnu-src Set dejagnu source path, use builtin source by + default --with-linux-headers-src Set linux-headers source path, use builtin source by default @@ -3285,6 +3298,23 @@ else fi +# Check whether --enable-debug_info was given. +if test "${enable_debug_info+set}" = set; then : + enableval=$enable_debug_info; enable_debug_info=yes +else + enable_debug_info=no + enableval=$enable_debug_info; disable_debug_info=yes +fi + + +if test "x$enable_debug_info" != xyes; then : + debug_info="" + +else + debug_info="-g" + +fi + # Check whether --with-arch was given. if test "${with_arch+set}" = set; then : @@ -3320,7 +3350,7 @@ fi if test "${with_isa_spec+set}" = set; then : withval=$with_isa_spec; else - with_isa_spec=2.2 + with_isa_spec=20191213 fi @@ -3757,6 +3787,50 @@ fi } +======= +>>>>>>> 0ae36fc (Update --with-isa-spec default option.) +{ + +# Check whether --with-dejagnu-src was given. +if test "${with_dejagnu_src+set}" = set; then : + withval=$with_dejagnu_src; +else + with_dejagnu_src=default + +fi + + if test "x$with_dejagnu_src" != xdefault; then : + with_dejagnu_src=$with_dejagnu_src + +else + with_dejagnu_src="\$(srcdir)/dejagnu" + +fi + + } + +======= +>>>>>>> 0ae36fc (Update --with-isa-spec default option.) +{ + +# Check whether --with-dejagnu-src was given. +if test "${with_dejagnu_src+set}" = set; then : + withval=$with_dejagnu_src; +else + with_dejagnu_src=default + +fi + + if test "x$with_dejagnu_src" != xdefault; then : + with_dejagnu_src=$with_dejagnu_src + +else + with_dejagnu_src="\$(srcdir)/dejagnu" + +fi + + } + # Check whether --with-linux-headers-src was given. if test "${with_linux_headers_src+set}" = set; then : diff --git a/configure.ac b/configure.ac index a0cd3b6..9e70bb2 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,24 @@ AS_IF([test "x$enable_linux" != xno], [AC_SUBST(default_target, linux)], [AC_SUBST(default_target, newlib)]) +AC_ARG_ENABLE(debug_info, + [AS_HELP_STRING([--enable-debug-info], + [build glibc/musl/newlibc/libgcc with debug information])], + [enable_debug_info=yes], + [enable_debug_info=no] + ) + +AS_IF([test "x$enable_debug_info" != xyes], + [AS_HELP_STRING([--disable-debug-info], + [build glibc and musl without debug infromation])], + [disable_debug_info=yes], + [disable_debug_info=no] + ) + +AS_IF([test "x$enable_debug_info" != xyes], + [AC_SUBST(debug_info, "")], + [AC_SUBST(debug_info, "-g")]) + AC_ARG_WITH(arch, [AS_HELP_STRING([--with-arch=rv64imafdc], [Sets the base RISC-V ISA, defaults to rv64imafdc])], @@ -72,10 +90,10 @@ AC_ARG_WITH(tune, ) AC_ARG_WITH(isa-spec, - [AS_HELP_STRING([--with-isa-spec=2.2], - [Set the default ISA spec version, default to 2.2, available options: 2.2, 20190608, 20191213])], + [AS_HELP_STRING([--with-isa-spec=20191213], + [Set the default ISA spec version, default to 20191213, available options: 2.2, 20190608, 20191213])], [], - [with_isa_spec=2.2] + [with_isa_spec=20191213] ) AC_ARG_WITH(sim, @@ -256,6 +274,7 @@ AX_ARG_WITH_SRC(qemu, qemu) AX_ARG_WITH_SRC(spike, spike) AX_ARG_WITH_SRC(pk, pk) AX_ARG_WITH_SRC(llvm, llvm) +AX_ARG_WITH_SRC(dejagnu, dejagnu) AC_ARG_WITH(linux-headers-src, [AC_HELP_STRING([--with-linux-headers-src], diff --git a/dejagnu b/dejagnu -Subproject d51e3f9f8188a735a64e7b2348e8fb7084f1d66 +Subproject c298959ef991b389b64a825f70094738c6a4878 diff --git a/glibc b/glibc -Subproject 9826b03b747b841f5fc6de2054bf1ef3f5c4bdf +Subproject a704fd9a133bfb10510e18702f48a6a9c88dbbd diff --git a/scripts/march-to-cpu-opt b/scripts/march-to-cpu-opt index f85bd26..752cf03 100755 --- a/scripts/march-to-cpu-opt +++ b/scripts/march-to-cpu-opt @@ -1,8 +1,11 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 import argparse import sys import unittest +import elftools.elf.elffile +import elftools.elf.enums +import elftools.elf.sections EXT_OPTS = { "zba": "zba=true", @@ -26,6 +29,8 @@ def parse_opt(argv): parser = argparse.ArgumentParser() parser.add_argument('-march', '--with-arch', type=str, dest='march') parser.add_argument('-selftest', action='store_true') + parser.add_argument('--get-riscv-tag', type=str) + parser.add_argument('--get-elf-class', type=str) opt = parser.parse_args() return opt @@ -156,12 +161,63 @@ class TestArchStringParse(unittest.TestCase): def selftest(): unittest.main(argv=sys.argv[1:]) +def open_elf(path): + try: + elffile = elftools.elf.elffile.ELFFile(open(path, 'rb')) + except elftools.common.exceptions.ELFError: + raise Exception("%s is not ELF file!" % path) + return elffile + +def read_elf_class(path): + elffile = open_elf(path) + return elffile.elfclass + +def read_arch_attr (path): + elffile = open_elf(path) + + attr_sec = elffile.get_section_by_name(".riscv.attributes") + if attr_sec: + # pyelftools has support RISC-V attribute but not contain in any + # release yet, so use ARMAttributesSection for now... + xattr_section = \ + elftools.elf.sections.ARMAttributesSection ( + attr_sec.header, + attr_sec.name, + elffile) + for subsec in xattr_section.subsections: + for subsubsec in subsec.subsubsections: + for attr in subsubsec.iter_attributes(): + val = attr.value + if (not isinstance(val, str)): + continue + pos32 = val.find("rv32") + pos64 = val.find("rv64") + # MAGIC WORKAROUND + # Some version of pyelftools has issue for parsing + # Tag number = 5, it will wrongly parse it become + # Tag number = 4 + 0x10 + 0x5 + if (pos32 == 2) or (pos64 == 2): + val = val[2:] + # End of MAGIC WORKAROUND + + if (pos32 != -1 or pos64 != -1): + return val + raise Exception("Not found ELF attribute in %s?" % path) + def main(argv): opt = parse_opt(argv) if opt.selftest: selftest() return 0 - cpu_opt = conver_arch_to_qemu_cpu_opt(opt.march) + if (opt.get_elf_class): + elf_class = read_elf_class (opt.get_elf_class) + print (elf_class) + return + if (opt.get_riscv_tag): + march = read_arch_attr (opt.get_riscv_tag) + else: + march = opt.march + cpu_opt = conver_arch_to_qemu_cpu_opt(march) print (cpu_opt) if __name__ == '__main__': diff --git a/scripts/testsuite-filter b/scripts/testsuite-filter index 6812d33..8096d7f 100755 --- a/scripts/testsuite-filter +++ b/scripts/testsuite-filter @@ -271,7 +271,7 @@ def filter_result(tool, libc, white_list_base_dir, unexpected_results): fail_count = summary[config][tool] print ("%13d |" % fail_count, end='') print ("") - if any_fail: + if any_fail or len(summary.items()) == 0: return 1 else: return 0 diff --git a/scripts/wrapper/qemu/riscv64-unknown-linux-gnu-run b/scripts/wrapper/qemu/riscv64-unknown-linux-gnu-run index 078360e..93dfccf 100755 --- a/scripts/wrapper/qemu/riscv64-unknown-linux-gnu-run +++ b/scripts/wrapper/qemu/riscv64-unknown-linux-gnu-run @@ -10,6 +10,6 @@ do shift done -xlen="$(readelf -h $1 | grep 'Class' | cut -d: -f 2 | xargs echo | sed 's/^ELF//')" +xlen="$(march-to-cpu-opt --get-elf-class $1)" -QEMU_CPU=${QEMU_CPU} qemu-riscv$xlen -r 5.10 "${qemu_args[@]}" -L ${RISC_V_SYSROOT} "$@" +QEMU_CPU="$(march-to-cpu-opt --get-riscv-tag $1)" qemu-riscv$xlen -r 5.10 "${qemu_args[@]}" -L ${RISC_V_SYSROOT} "$@" |