- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone, currently I am developing mandelbrot plot using Nios II with custom hardware Floating point module FPH2 from Intel for my DE10-Nano broad. I try to build BSP library smallC for it as it is required. However, I cannot build it due to error related in Makefile:
```bash
/usr/bin/mkdir -p doc
gcc -g -g -O2 -o doc/makedoc.o -c /mnt/e/software/quartus-lite-23.1/fpga/nios2eds/bin/gnu/src/newlib-4.3.0/newlib/doc/makedoc.c
gcc -g -O2 -o doc/makedoc doc/makedoc.o
make "CC_FOR_BUILD=gcc" "CFLAGS=-g -Os -ffunction-sections -fdata-sections -mno-gpopt" "CCASFLAGS=-g -Os -ffunction-sections -fdata-sections -mno-gpopt" "CFLAGS_FOR_BUILD=-g -O2" "CFLAGS_FOR_TARGET=-g -Os -ffunction-sections -fdata-sections -mno-gpopt" "INSTALL=/usr/bin/install -c" "LDFLAGS=" "LIBCFLAGS=-g -Os -ffunction-sections -fdata-sections -mno-gpopt" "LIBCFLAGS_FOR_TARGET=-g -Os -ffunction-sections -fdata-sections -mno-gpopt" "MAKE=make" "MAKEINFO=makeinfo --split-size=5000000 " "PICFLAG=" "PICFLAG_FOR_TARGET=" "SHELL=/bin/bash" "EXPECT=expect" "RUNTEST=runtest" "RUNTESTFLAGS=" "exec_prefix=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib" "infodir=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib/share/info" "libdir=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib/lib" "prefix=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib" "tooldir=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib/nios2-elf" "top_toollibdir=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib/nios2-elf/lib" "AR=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib-build-tmp/build-newlib-stage-wrapper nios2-elf-ar.exe" "AS=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib-build-tmp/build-newlib-stage-wrapper nios2-elf-as.exe" "CC=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib-build-tmp/build-newlib-stage-wrapper nios2-elf-gcc.exe -B/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib-build-tmp/smallc/nios2-elf/newlib/ -isystem /mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib-build-tmp/smallc/nios2-elf/newlib/targ-include -isystem /mnt/e/software/quartus-lite-23.1/fpga/nios2eds/bin/gnu/src/newlib-4.3.0/newlib/libc/include -B/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib-build-tmp/smallc/nios2-elf/libgloss/nios2 -L/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib-build-tmp/smallc/nios2-elf/libgloss/libnosys -L/mnt/e/software/quartus-lite-23.1/fpga/nios2eds/bin/gnu/src/newlib-4.3.0/libgloss/nios2 " "LD=nios2-elf-ld.exe" "LIBCFLAGS=-g -Os -ffunction-sections -fdata-sections -mno-gpopt" "NM=nios2-elf-nm.exe" "PICFLAG=" "RANLIB=/mnt/d/software/verilog/NIOSII_HDMI/software/mandelbrot_plot_bsp/newlib-build-tmp/build-newlib-stage-wrapper nios2-elf-ranlib.exe" "DESTDIR=" DO=all multi-do # make
libc/argz/.deps/libc_a-argz_add.Po:1: *** target pattern contains no '%'. Stop.
make[4]: *** [Makefile:49062: all-multi] Error 2
make[3]: *** [Makefile:5078: all] Error 2
make[2]: *** [Makefile:8502: all-target-newlib] Error 2
nios2-newlib-gen: Unable to Compile smallc newlib
```
My environment is Win 11, WSL2, Quartus Lite 23.1, What should I do to fix this error?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @aikeu,
I don't think there is much difference between WSL1 and WSL2. I have built the Hello World example program for Nios II, and it worked. However, when I tried to built the example program for floating point program, it gave me error. I think there is problem with the Nios II build tool for generating the correct Makefile for building the library with custom nios floating point hardware instruction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi minhlee,
Probably can check out this forum post as it relates to the smallc compilation error:
Thanks.
Regards,
Aik Eu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi minhlee,
I will close the thread if no further question.
Thanks.
Regards,
Aik Eu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi minhlee,
As we do not receive any response from you on the previous question/reply/answer that we have provided. Please login to ‘https://supporttickets.intel.com/s/?language=en_US’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.
Thanks.
Regards,
Aik Eu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Minhlee, hi Aik Eu!
I have exactly the same issue. The smallc newlib compiles fine with Quartus 22.1 but not with Quartus 23.1
Configure smallc newlib -> COMPLETE.
Compiling newlib for a smallc C library...
nios2-newlib-gen: Unable to Compile smallc newlib
Makefile:803: recipe for target 'newlib' failed
make[1]: *** [newlib] Error 1
I have Windows 10, WSL1 and Quartus 23.1 Standard (same behavior with 23.1.1) installed.
It seems that my code does not use the newlib at all, because if the "newlib" folder is there (empty), make does not even try to compile the newlib and compile runs through without issues! This is a very strange behavior.
I tried to disable in BSP Editor the following points: enable_reduced_device_drivers, enable_small_c_library, enable_lightweight_device_driver_api but it still compiles the newlib!
BR
Erich
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@EGrub wrote:It seems that my code does not use the newlib at all, because if the "newlib" folder is there (empty), make does not even try to compile the newlib and compile runs through without issues! This is a very strange behavior.
Newlib only gets built if the newlib folder is NOT there.
This is some form of Makefile dependency.
Now when you link your application, it has multiple linker include paths, the first is the local newlib folder. If it happens to be empty, it will use the next include path, which if I recall correctly is this one: C:\intelFPGA_lite\23.1std\nios2eds\bin\gnu\H-x86_64-mingw32\nios2-elf\lib
You will see the newlib files being there, if you are curious, you could move this folder away and see if your application still links.
I have just created this test (by renaming lib to _lib at C:\intelFPGA_lite\23.1std\nios2eds\bin\gnu\H-x86_64-mingw32\nios2-elf) and I get the following errors:
c:/intelfpga_lite/23.1std/nios2eds/bin/gnu/h-x86_64-mingw32/bin/../lib/gcc/nios2-elf/12.3.1/../../../../../H-x86_64-mingw32/nios2-elf/bin/ld.exe: cannot find -lstdc++: No such file or directory
c:/intelfpga_lite/23.1std/nios2eds/bin/gnu/h-x86_64-mingw32/bin/../lib/gcc/nios2-elf/12.3.1/../../../../../H-x86_64-mingw32/nios2-elf/bin/ld.exe: cannot find -lm: No such file or directory
c:/intelfpga_lite/23.1std/nios2eds/bin/gnu/h-x86_64-mingw32/bin/../lib/gcc/nios2-elf/12.3.1/../../../../../H-x86_64-mingw32/nios2-elf/bin/ld.exe: cannot find -lsmallc: No such file or directory
c:/intelfpga_lite/23.1std/nios2eds/bin/gnu/h-x86_64-mingw32/bin/../lib/gcc/nios2-elf/12.3.1/../../../../../H-x86_64-mingw32/nios2-elf/bin/ld.exe: cannot find -lm: No such file or directory
collect2.exe: error: ld returned 1 exit status
Normally my self compiled newlib folder would contain:
crt0.o
libc.a
libg.a
libm.a
libnosys.a
libsmallc.a
libsmallg.a
libstack.a
As you can see libm.a and libcmallc.a would have been taken from the local newlib folder, (if they would have been there)
So, yes it will work, but you won't get the hand tailored version of newlib which you have set up in your settings.bsp file
Regarding the issue, that newlib can not be built:
I have the very same issue, hence I landed here at this topic.
It is a shame, that this has not been taken serious enough to have a fix for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did some further tests:
There seems to be a linker bug -> because if I just generate the newlib folder (empty) compilation runs through but at the first point it uses the newlib the processor reboots. This should not happen linker should throw an error that the newlib binaries are not available!!
If I copy the newlib binaries from a 22.1 compile everything works fine!
I then generated the hello world project (the normal one, not the small one) and it does not compile as well, it stops with the exact same error.
So my conclusion is that there is a bug in compilation of the newlib (I use the floating point hardware 2 as well) and a bug in linker because it should throw an error if the binary is not available!
@intel/Altera employees
How to continue with that? This is a major blocker for my project!
BR
Erich
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For anyone wondering for the solution, check my attached file
Please rename it to nios2-newlib-gen and overwrite the file at the location:
C:\intelFPGA_lite\23.1std\nios2eds\sdk2\bin
The change which has been done is adding the option:
--disable-dependency-tracking
to the configure call.
So instead:
/bin/sh "$SRCDIR/configure" --prefix="$LIBDIR" --target=$TARGET 2>&1 | tee -a "$LOGFILE" >&3
it is
/bin/sh "$SRCDIR/configure" --disable-dependency-tracking --prefix="$LIBDIR" --target=$TARGET 2>&1 | tee -a "$LOGFILE" >&3
For the ones curious to know why this is needed:
make (executable) is called in wsl, which understands linux paths.
the gcc toolchain is a windows native toolchain which is spawned from wsl make, the gcc toolchain therefore understands only windows paths. If you check your nios application Makefile carefully you will see this section:
ifdef WINDOWS_EXE
adjust-path = $(if $1,$(shell wslpath "$1"),)
adjust-path-mixed = $(if $(call eq,$(shell echo $1 | head -c 5),/mnt/),$(shell echo $1 | sed 's/\/mnt\///g;s/\//:\//1'),$1)
else # !WINDOWS_EXE
adjust-path = $1
adjust-path-mixed = $1
endif
Altera has provided a solution in the user project to adjsut the path between linux and windows, but the newlib code does not have such a thing, being this is some really strange setup to have mixed linux and windows calls.
Because the dependency tracking is enabled per default in newlib 4.3, the dependency files are being generated from windows gcc, which then can not be read by wsl make, and you get the error:
libc/argz/.deps/libc_a-argz_add.Po:1: *** target pattern contains no '%'. Stop.
My 2 cents would be:
I would have provided a linux native toolchain, placed in the folder here:
C:\intelFPGA_lite\23.1std\nios2eds\bin\gnu\H-x86_64-mingw32\bin
wsl make then would spawn linux gcc tools for building, which would end the confusion between linux and windows paths.
And I would still have provided a windows native nios2-elf-gdb.exe in order to be able to debug from windows eclipse.
Cheers!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page