OpenBLAS: can we build openblas for riscv (bare metal system ) using riscv64-unknown-elf toolchain

I tried from following cmd make TARGET=RISCV64_GENERIC BINARY=64 CC=riscv64-unknown-elf-gcc FC=riscv64-unknown-elf-gfortran HOSTCC=gcc NO_SHARED=1 USE_THREAD=0 NO_AFFINITY=1 CFLAGS=“-march=rv64gc -mabi=lp64d -mcmodel=medany -O2 -z noexecstack -DOS_EMBEDDED” FCFLAGS=“-march=rv64gc -mabi=lp64d -mcmodel=medany -O2 -z noexecstack” LDFLAGS=“-lm” PREFIX=/path/to/build/ -j16 I got errors like touch libopenblas_riscv64_generic-r0.3.28.dev.a make -C test all make[1]: Entering directory ‘/home/openblas_riscv/OpenBLAS/test’ make[1]: warning: -j16 forced in makefile: resetting jobserver mode. riscv64-unknown-elf-gfortran -O2 -Wall -frecursive -fno-optimize-sibling-calls -march=rv64imafdc -mabi=lp64d -fno-tree-vectorize -lm -o sblat1 sblat1.o …/libopenblas_riscv64_generic-r0.3.28.dev.a -lgfortran -lgfortran -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/…/…/…/…/riscv64-unknown-elf/lib/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/riscv64-unknown-elf/lib/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0 -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/…/…/…/…/riscv64-unknown-elf/lib -L/home/openblas_riscv/riscv_elf/riscv64-unknown-elf/lib -lc -lgloss riscv64-unknown-elf-gfortran -O2 -Wall -frecursive -fno-optimize-sibling-calls -march=rv64imafdc -mabi=lp64d -fno-tree-vectorize -lm -o zblat3 zblat3.o …/libopenblas_riscv64_generic-r0.3.28.dev.a -lgfortran -lgfortran -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/…/…/…/…/riscv64-unknown-elf/lib/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/riscv64-unknown-elf/lib/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0 -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/…/…/…/…/riscv64-unknown-elf/lib -L/home/openblas_riscv/riscv_elf/riscv64-unknown-elf/lib -lc -lgloss riscv64-unknown-elf-gfortran -O2 -Wall -frecursive -fno-optimize-sibling-calls -march=rv64imafdc -mabi=lp64d -fno-tree-vectorize -lm -o cblat3 cblat3.o …/libopenblas_riscv64_generic-r0.3.28.dev.a -lgfortran -lgfortran -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/…/…/…/…/riscv64-unknown-elf/lib/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/riscv64-unknown-elf/lib/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0 -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/…/…/…/…/riscv64-unknown-elf/lib -L/home/openblas_riscv/riscv_elf/riscv64-unknown-elf/lib -lc -lgloss riscv64-unknown-elf-gfortran -O2 -Wall -frecursive -fno-optimize-sibling-calls -march=rv64imafdc -mabi=lp64d -fno-tree-vectorize -lm -o dblat3 dblat3.o …/libopenblas_riscv64_generic-r0.3.28.dev.a -lgfortran -lgfortran -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/…/…/…/…/riscv64-unknown-elf/lib/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/riscv64-unknown-elf/lib/rv64imafdc/lp64d -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0 -L/home/openblas_riscv/riscv_elf/lib/gcc/riscv64-unknown-elf/14.2.0/…/…/…/…/riscv64-unknown-elf/lib -L/home/openblas_riscv/riscv_elf/riscv64-unknown-elf/lib -lc -lgloss … (rest of the output follows the same pattern) … make[1]: Leaving directory ‘/home/openblas_riscv/OpenBLAS/test’

make -C utest all make[1]: Entering directory ‘/home/…/openblas_riscv/OpenBLAS/utest’ make[1]: warning: -j16 forced in makefile: resetting jobserver mode. riscv64-unknown-elf-gcc -march=rv64gc -mabi=lp64d -mcmodel=medany -O2 -z noexecstack -DOS_EMBEDDED -O2 -DUTEST_CHECK -DSANITY_CHECK -DREFNAME=f_ -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_WARMUP -DMAX_CPU_NUMBER=16 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION="0.3.28.dev" -march=rv64imafdc -mabi=lp64d -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME="" -DCHAR_CNAME="" -DNO_AFFINITY -I… -lm -o openblas_utest utest_main.o test_min.o test_amax.o test_ismin.o test_rotmg.o test_axpy.o test_dotu.o test_dsdot.o test_swap.o test_rot.o test_dnrm2.o test_zscal.o test_amin.o test_axpby.o test_gemv.o test_potrs.o test_kernel_regress.o test_fork.o test_post_fork.o …/libopenblas_riscv64_generic-r0.3.28.dev.a -lgfortran -lgfortran …/lib/gcc/riscv64-unknown-elf/14.2.0/…/ld: test_potrs.o: in function __ctest_potrf_smoketest_trivial_run': test_potrs.c:(.text+0x496): undefined reference to cabsf’ …/lib/gcc/riscv64-unknown-elf/14.2.0/…/ld: test_potrs.c:(.text+0x4cc): undefined reference to cabs' .../lib/gcc/riscv64-unknown-elf/14.2.0/.../ld: ../libopenblas_riscv64_generic-r0.3.28.dev.a(dnrm2_k.o): in function dnrm2_k’: nrm2.c:(.text+0xc4): undefined reference to sqrt' .../lib/gcc/riscv64-unknown-elf/14.2.0/.../ld: ../libopenblas_riscv64_generic-r0.3.28.dev.a(spotf2_U.o): in function spotf2_U’: potf2_U.c:(.text+0x152): undefined reference to sqrt' .../lib/gcc/riscv64-unknown-elf/14.2.0/.../ld: ../libopenblas_riscv64_generic-r0.3.28.dev.a(spotf2_L.o): in function spotf2_L’: potf2_L.c:(.text+0x150): undefined reference to sqrt' .../lib/gcc/riscv64-unknown-elf/14.2.0/.../ld: ../libopenblas_riscv64_generic-r0.3.28.dev.a(cpotf2_U.o): in function cpotf2_U’: zpotf2_U.c:(.text+0x164): undefined reference to sqrt' .../lib/gcc/riscv64-unknown-elf/14.2.0/.../ld: ../libopenblas_riscv64_generic-r0.3.28.dev.a(cpotf2_L.o): in function cpotf2_L’: zpotf2_L.c:(.text+0x178): undefined reference to sqrt' .../lib/gcc/riscv64-unknown-elf/14.2.0/.../ld: ../libopenblas_riscv64_generic-r0.3.28.dev.a(dbdsqr.o): in function dbdsqr’: dbdsqr.f:(.text+0x2f8): undefined reference to pow' .../lib/gcc/riscv64-unknown-elf/14.2.0/.../ld: ../libopenblas_riscv64_generic-r0.3.28.dev.a(iparmq.o): in function iparmq_‘: iparmq.f:(.text+0xbc): undefined reference to `logf’ collect2: error: ld returned 1 exit status make[1]: * [Makefile:78: openblas_utest] Error 1 make[1]: Leaving directory ‘/home/…/openblas_riscv/OpenBLAS/utest’ make: * [Makefile:172: tests] Error 2

is it possible to build openblas

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21

Most upvoted comments

There’s a small chance that you are simply running out of space for internal memory buffers, try building with -DBUFFERSIZE=18 or a smaller number. But unfortunately I have no experience with embedded systems and I wouldn’t be able to tell you if the problem is e.g. with your compiler options.

Based on the comments in your linked riscv-gnu-toolchain issue it might make sense to try without the OS_EMBEDDED keyword, as the riscv “newlib” is said to include all necessary function.

This is what is also mentioned on the Wiki page regarding compilation for “bare metal” CortexM - on a “bare metal” system you usually need to supply your own memory management functions like “malloc” and “free” (things that normally would be handled by an operating system) - the author of the Wiki page suggested libmemory, there are probably other implementations.