Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rv-virt:nsh64 can't build with stock gcc-riscv64-unknown-elf on Ubuntu Jammy #11341

Closed
yf13 opened this issue Dec 7, 2023 · 4 comments
Closed

Comments

@yf13
Copy link
Contributor

yf13 commented Dec 7, 2023

When buildling rv-virt:nsh64 with the stock toolchain installed via sudo apt install gcc-riscv64-unknown-elf on Ubuntu 22.04, I got the following error:

$ make
./stdlib/lib_strtold.c:44:10: fatal error: math.h: No such file or directory
   44 | #include <math.h>
      |          ^~~~~~~~
compilation terminated.
ERROR: riscv64-unknown-elf-gcc failed: 1
       command: riscv64-unknown-elf-gcc -MT bin/lib_strtold.o  -M '-fno-common' '-Wall' '-Wstrict-prototypes' '-Wshadow' '-Wundef' '-Wno-attributes' '-Wno-unknown-pragmas' '-Wno-psabi' '-Os' '-fno-strict-aliasing' '-fomit-frame-pointer' '-ffunction-sections' '-fdata-sections' '-g' '-mcmodel=medany' '-march=rv64imafdc' '-mabi=lp64d' '-isystem' '/home/yf/Projects/Nuttx/nuttx/include' '-D__NuttX__' '-pipe' '-I' '/home/yf/Projects/Nuttx/nuttx/libs/libc' ./stdlib/lib_strtold.c
make[2]: *** [/home/yf/Projects/Nuttx/nuttx/tools/Config.mk:228: lib_strtold.ddc] Error 1
make[1]: *** [Makefile:189: .depend] Error 2
make: *** [tools/Unix.mk:606: pass1dep] Error 2

The toolchain has the following version info:

$ riscv64-unknown-elf-gcc -v
Using built-in specs.
COLLECT_GCC=riscv64-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-unknown-elf/10.2.0/lto-wrapper
Target: riscv64-unknown-elf
Configured with: ../configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --target=riscv64-unknown-elf --prefix=/usr --infodir=/usr/share/doc/gcc-riscv64-unknown-elf/info --mandir=/usr/share/man --htmldir=/usr/share/doc/gcc-riscv64-unknown-elf/html --pdfdir=/usr/share/doc/gcc-riscv64-unknown-elf/pdf --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --with-pkgversion= --disable-shared --disable-threads --enable-languages=c,c++ --enable-tls --with-newlib --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --with-system-zlib --enable-checking=yes --enable-multilib --with-abi=lp64d --disable-libstdcxx-pch --disable-libstdcxx --disable-fixinc --with-arch=rv64imafdc --with-gnu-as --with-gnu-ld --with-as=/usr/lib/riscv64-unknown-elf/bin/as --with-ld=/usr/lib/riscv64-unknown-elf/bin/ld AR_FOR_TARGET=/usr/lib/riscv64-unknown-elf/bin/ar AS_FOR_TARGET=/usr/lib/riscv64-unknown-elf/bin/as NM_FOR_TARGET=/usr/lib/riscv64-unknown-elf/bin/nm LD_FOR_TARGET=/usr/lib/riscv64-unknown-elf/bin/ld OBJDUMP_FOR_TARGET=/usr/lib/riscv64-unknown-elf/bin/objdump RANLIB_FOR_TARGET=/usr/lib/riscv64-unknown-elf/bin/ranlib READELF_FOR_TARGET=/usr/lib/riscv64-unknown-elf/bin/readelf STRIP_FOR_TARGET=/usr/lib/riscv64-unknown-elf/bin/strip CFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-riscv64-unknown-elf-LkcieF/gcc-riscv64-unknown-elf-10.2.0=. -fstack-protector-strong' CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2' CXXFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-riscv64-unknown-elf-LkcieF/gcc-riscv64-unknown-elf-10.2.0=. -fstack-protector-strong' FCFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-riscv64-unknown-elf-LkcieF/gcc-riscv64-unknown-elf-10.2.0=. -fstack-protector-strong' FFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-riscv64-unknown-elf-LkcieF/gcc-riscv64-unknown-elf-10.2.0=. -fstack-protector-strong' GCJFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-riscv64-unknown-elf-LkcieF/gcc-riscv64-unknown-elf-10.2.0=. -fstack-protector-strong' LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' OBJCFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-riscv64-unknown-elf-LkcieF/gcc-riscv64-unknown-elf-10.2.0=. -fstack-protector-strong' OBJCXXFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-riscv64-unknown-elf-LkcieF/gcc-riscv64-unknown-elf-10.2.0=. -fstack-protector-strong' 'CFLAGS_FOR_TARGET=-Os -mcmodel=medany' 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medany'
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 10.2.0 ()
@yf13 yf13 changed the title failed to built rv-virt:nsh64 with stock gcc-riscv64-unknown-elf on Ubuntu rv-virt:nsh64 can't build with stock gcc-riscv64-unknown-elf on Ubuntu Jammy Dec 7, 2023
@pkarashchenko
Copy link
Contributor

pkarashchenko commented Dec 7, 2023

This is a know issue. Ubuntu release of RISC-V GCC is compiled without math libs. We can do nothing with that, but you can enable NuttX native math libraries support via CONFIG_ LIBM=y and still use RISC-V GCC provided by Ubuntu apt or pick another more mature toolchain

@pkarashchenko
Copy link
Contributor

Closing this. Please re-open if needed.

@yf13
Copy link
Contributor Author

yf13 commented Dec 8, 2023

@pkarashchenko thanks! I wasn't able to find an explanation in historical issues or documents, thus raised it here.
Just confirmed that CONFIG_LIBM works well.

@pkarashchenko
Copy link
Contributor

Yeah, it is not in docs since we are not managing tools created externally, but there was some discussion in one of the PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants