From bb74af5a874c8b521ae0159ba4d892af9df93d09 Mon Sep 17 00:00:00 2001 From: Alex Chiang Date: Thu, 1 Jun 2023 00:19:00 -0700 Subject: [PATCH] Enable riscv llvm & qemu build flow Update readme about llvm & qemu examples Co-authored-by: Kito Cheng --- .github/setup-apt.sh | 2 +- .github/workflows/build.yaml | 58 ++++++++++++++ .gitmodules | 2 +- Makefile.in | 68 +++++++++++----- README.md | 45 ++++++----- binutils | 2 +- configure | 80 ++++++++++++++++++- configure.ac | 25 +++++- dejagnu | 2 +- glibc | 2 +- scripts/march-to-cpu-opt | 60 +++++++++++++- scripts/testsuite-filter | 2 +- .../qemu/riscv64-unknown-linux-gnu-run | 4 +- 13 files changed, 294 insertions(+), 58 deletions(-) diff --git a/.github/setup-apt.sh b/.github/setup-apt.sh index 5ce65e55..63bd6820 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 11399133..0f05d50f 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 87e78392..340189f4 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 d4cc9a4d..f44fbd1f 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)" \ $ $@ -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 $@) && $ $@ -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 $@) && $ $@ +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 $@) && $ -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 index b51c2fec..b2bc62b7 160000 --- a/binutils +++ b/binutils @@ -1 +1 @@ -Subproject commit b51c2fec1da205ea3e7354cbb3e253018d64873c +Subproject commit b2bc62b7b4e7638c3a249d2d2728ceb4d5f2b22c diff --git a/configure b/configure index 5afcc613..63351d7c 100755 --- a/configure +++ b/configure @@ -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 a0cd3b60..9e70bb2f 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 index d51e3f9f..c298959e 160000 --- a/dejagnu +++ b/dejagnu @@ -1 +1 @@ -Subproject commit d51e3f9f8188a735a64e7b2348e8fb7084f1d666 +Subproject commit c298959ef991b389b64a825f70094738c6a48780 diff --git a/glibc b/glibc index 9826b03b..a704fd9a 160000 --- a/glibc +++ b/glibc @@ -1 +1 @@ -Subproject commit 9826b03b747b841f5fc6de2054bf1ef3f5c4bdf3 +Subproject commit a704fd9a133bfb10510e18702f48a6a9c88dbbd5 diff --git a/scripts/march-to-cpu-opt b/scripts/march-to-cpu-opt index f85bd26b..752cf031 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 6812d33a..8096d7f7 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 078360e0..93dfccf7 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} "$@"