diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index abad5ec3..3266652f 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -79,6 +79,7 @@ This is release version ``0.5.0-dev`` of Nuclei SDK. - Add extra ``-fomit-frame-pointer -fno-shrink-wrap-separate`` options for Zc extension to enable zcmp instruction generation - Extra CPU_SERIES macro is passed such (200/300/600/900) during compiling for benchmark examples - When you want to select different nmsis library arch, please use **NMSIS_LIB_ARCH** make variable, see demo_dsp as example + - When using libncrt library, this is no need to link with other libgcc library, c library or math library, such as gcc libgcc library(``-lgcc``), newlib c library(``-lc/-lc_nano``) and math library(``-lm``), the c and math features are also provided in libncrt library. * Tools diff --git a/doc/source/develop/buildsystem.rst b/doc/source/develop/buildsystem.rst index 7d35a6ea..7745e7f8 100644 --- a/doc/source/develop/buildsystem.rst +++ b/doc/source/develop/buildsystem.rst @@ -1117,8 +1117,9 @@ can provided smaller code size and highly optimized floating point support compa * About Newlib and Newlib nano difference, please check https://github.com/riscv-collab/riscv-newlib/blob/riscv-newlib-3.2.0/newlib/README - * About Nuclei C runtime library, it didn't provided all the features that - newlib can do, it is highly optimized for deeply embedded scenery + * About Nuclei C runtime library, it provided basic libgcc, c library and math library feature, but + it didn't provided all the features that newlib can do, it is highly optimized for deeply embedded scenery, + user no need to link with ``-lm`` when using libncrt library when math library is needed. * Nuclei C runtime library is only available in Nuclei GNU Toolchain released after Nov 2021, about how to use this library, please follow doc located in ``gcc\share\pdf``, changes need to be done in startup code, linker script, stub code, and compiler options, you can check commit @@ -1665,10 +1666,10 @@ LDFLAGS ~~~~~~~ This **LDFLAGS** is used to pass extra linker flags, for example, -if you want to link extra math library, you can add a newline -``LDFLAGS += -lm`` in you application Makefile. +if you want to use standard system libraries when linking, you can add a newline +``LDFLAGS += -nodefaultlibs`` in you application Makefile. -Libraries (-lfoo) could also be added to the LDLIBS variable instead. +If you want to link with other libraries, please use ``LDLIBS`` and ``LIBDIRS`` variables. .. _develop_buildsystem_var_ldlibs: @@ -1678,7 +1679,7 @@ LDLIBS This **LDLIBS** variable is library flags or names given to compilers when they are supposed to invoke the linker. -Non-library linker flags, such as -L, should go in the **LDFLAGS** variable. +Non-library linker flags, such as -L, should go in the **LIBDIRS** or **LDFLAGS** variable. .. _develop_buildsystem_var_libdirs: diff --git a/doc/source/faq.rst b/doc/source/faq.rst index 7be6502e..b3fc17dd 100644 --- a/doc/source/faq.rst +++ b/doc/source/faq.rst @@ -187,5 +187,27 @@ This `mtune` option is introduced in Nuclei SDK 0.3.5, used to select optimized for Nuclei RISC-V Core series such as 200/300/600/900 series, and this feature required Nuclei GNU Toolchain 2022.01, please upgrade to this version or later ones. +undefined reference to __errno when using libncrt library +--------------------------------------------------------- + +When you are using libncrt library, and linked with ``-lm``, you may face below issues + +.. code-block:: console + + /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/bin/ld: /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/lib/rv32imafdc/ilp32d/libm.a(libm_a-w_exp.o): in function `.L1': + w_exp.c:(.text.exp+0x4a): undefined reference to `__errno' + /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/bin/ld: /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/lib/rv32imafdc/ilp32d/libm.a(libm_a-w_exp.o): in function `.L0 ': + w_exp.c:(.text.exp+0x6e): undefined reference to `__errno' + /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/bin/ld: /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/lib/rv32imafdc/ilp32d/libm.a(libm_a-w_log.o): in function `log': + w_log.c:(.text.log+0x28): undefined reference to `__errno' + /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/bin/ld: w_log.c:(.text.log+0x46): undefined reference to `__errno' + /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/bin/ld: /home/share/devtools/toolchain/nuclei_gnu/linux64/newlibc/2023.10.14/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/lib/rv32imafdc/ilp32d/libm.a(libm_a-math_err.o): in function `with_errno': + math_err.c:(.text.with_errno+0x12): undefined reference to `__errno' + collect2: error: ld returned 1 exit status + +You can fix it by not link ``-lm`` library, since libncrt library already provided math library feature, so +no need to link this math library. + + .. _debugger kit manual: https://www.nucleisys.com/theme/package/Nuclei_FPGA_DebugKit_Intro.pdf .. _ftdi_device_desc: http://openocd.org/doc/html/Debug-Adapter-Configuration.html