编译报错
Huckies opened this issue · 9 comments
/Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: 找不到 -lprintfloat
/Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-closer.o): in function `.L0 ':
closer.c:(.text._close_r+0x12): 警告:_close is not implemented and will always fail
/Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-fstatr.o): in function `.L0 ':
fstatr.c:(.text._fstat_r+0x14): 警告:_fstat is not implemented and will always fail
/Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-isattyr.o): in function `.L0 ':
isattyr.c:(.text._isatty_r+0x12): 警告:_isatty is not implemented and will always fail
/Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-lseekr.o): in function `.L0 ':
lseekr.c:(.text._lseek_r+0x16): 警告:_lseek is not implemented and will always fail
/Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-readr.o): in function `.L0 ':
readr.c:(.text._read_r+0x16): 警告:_read is not implemented and will always fail
/Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-writer.o): in function `.L0 ':
writer.c:(.text._write_r+0x16): 警告:_write is not implemented and will always fail
collect2: error: ld returned 1 exit status
make[2]: *** [ch582-ninja.elf] Error 1
make[1]: *** [CMakeFiles/ch582-ninja.elf.dir/all] Error 2
make: *** [all] Error 2
https://blog.csdn.net/feizaopaoxyz/article/details/116451549与这篇文章中提到的错误类似,但不知如何解决,请指教。
我使用的是cmake -G"Eclipse CDT4 - Unix Makefiles",cmake阶段和make的编译阶段都正常,错误发生在链接阶段
/Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: 找不到 -lprintfloat /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-closer.o): in function `.L0 ': closer.c:(.text._close_r+0x12): 警告:_close is not implemented and will always fail /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-fstatr.o): in function `.L0 ': fstatr.c:(.text._fstat_r+0x14): 警告:_fstat is not implemented and will always fail /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-isattyr.o): in function `.L0 ': isattyr.c:(.text._isatty_r+0x12): 警告:_isatty is not implemented and will always fail /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-lseekr.o): in function `.L0 ': lseekr.c:(.text._lseek_r+0x16): 警告:_lseek is not implemented and will always fail /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-readr.o): in function `.L0 ': readr.c:(.text._read_r+0x16): 警告:_read is not implemented and will always fail /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /Users/huckies/riscv-gnu-toolchain/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/libc_nano.a(lib_a-writer.o): in function `.L0 ': writer.c:(.text._write_r+0x16): 警告:_write is not implemented and will always fail collect2: error: ld returned 1 exit status make[2]: *** [ch582-ninja.elf] Error 1 make[1]: *** [CMakeFiles/ch582-ninja.elf.dir/all] Error 2 make: *** [all] Error 2
https://blog.csdn.net/feizaopaoxyz/article/details/116451549与这篇文章中提到的错误类似,但不知如何解决,请指教。
请问你加入lprintfloat是否想打印浮点值呢?如果是的话,本仓库已经移植了printf.c,可直接使用,并且占用较小。
不是,我直接编的这个仓库里的工程,lprintfloat是在CMakeLists.txt里的,70行
能否提供下你的工具链下载地址?
https://github.com/riscv-collab/riscv-gnu-toolchain 该仓库最新的提交,编译安装
同时由于我是arm mac,编译之前注释掉了./riscv-gcc/gcc/config.host
的第96、97行
96 # out_host_hook_obj=host-darwin.o
97 # host_xmake_file="${host_xmake_file} x-darwin"
还有一个现象:若只使用makefile而不是用cmake,这些警告依然存在,却不会导致编译出错
makefile来自http://www.wch.cn/index.php/bbs/thread-74062-1.html,根据本仓库作了对应修改
经过测试,通过使用mrs提供的win和linux gcc工具链,都可以正常编译,建议你找沁恒要一下mac的工具链再进行尝试。
http://www.mounriver.com/download
感谢帮助,使用沁恒社区的makefile暂时能够编译成功,等评估板到了测试之后再决定是不是换系统吧
感谢你的努力,目前虽然只能跑在rosetta转译下但已经可以正常编译