Forum Discussion
EricMunYew_C_Intel
Frequent Contributor
5 years agocan you try below:
Modify <installation location>/nios2eds/sdk/bin/nios2-newlib-gen:
include the following on the top of the script, before "usage()"
uname=$(uname -r | tr A-Z a-z)
if [[ $uname =~ "microsoft" ]]; then
windows_exe=.exe
fi
tommmy
New Contributor
4 years agoI had tried before, not work.
I am pretty sure, the function build_newlib() in this script file is not right. the STAGE_WRAPPER file not generated correctly.
STAGE_WRAPPER=$BLDDIR/build-newlib-stage-wrapper
in file " build-newlib-stage-wrapper"
#!/bin/bash
#
# A script to intercept and short-circuit the --print-multi-lib option
#
ORIGINAL_ARGS=$(echo $* | sed -e 's,/cygdrive/\([a-zA-Z]\)/,\1:/,g')
CUSTOM=
if [ "x$1" = "xnios2-elf-gcc" ]
then
CUSTOM=" -O3 -g -Wall -mno-hw-div -mhw-mul -mno-hw-mulx -mgpopt=global -fno-math-errno -mcustom-fabss=224 -mcustom-fadds=253 -mcustom-fcmpeqs=227 -mcustom-fcmpges=228 -mcustom-fcmpgts=229 -mcustom-fcmples=230 -mcustom-fcmplts=231 -mcustom-fcmpnes=226 -mcustom-fdivs=255 -mcustom-fixsi=249 -mcustom-floatis=250 -mcustom-fmuls=252 -mcustom-fnegs=225 -mcustom-fsubs=254 "
fi
while [ $# -gt 0 ]
do
case "$1" in
--print-multi-lib)
echo ".;"
exit 0
;;
*)
;;
esac
shift
done
eval $ORIGINAL_ARGS $CUSTOM
#
# A script to intercept and short-circuit the --print-multi-lib option
#
ORIGINAL_ARGS=$(echo $* | sed -e 's,/cygdrive/\([a-zA-Z]\)/,\1:/,g')
CUSTOM=
if [ "x$1" = "xnios2-elf-gcc" ]
then
CUSTOM=" -O3 -g -Wall -mno-hw-div -mhw-mul -mno-hw-mulx -mgpopt=global -fno-math-errno -mcustom-fabss=224 -mcustom-fadds=253 -mcustom-fcmpeqs=227 -mcustom-fcmpges=228 -mcustom-fcmpgts=229 -mcustom-fcmples=230 -mcustom-fcmplts=231 -mcustom-fcmpnes=226 -mcustom-fdivs=255 -mcustom-fixsi=249 -mcustom-floatis=250 -mcustom-fmuls=252 -mcustom-fnegs=225 -mcustom-fsubs=254 "
fi
while [ $# -gt 0 ]
do
case "$1" in
--print-multi-lib)
echo ".;"
exit 0
;;
*)
;;
esac
shift
done
eval $ORIGINAL_ARGS $CUSTOM
error log :
[my private path]/newlib-build-tmp/build-newlib-stage-wrapper: line 23: nios2-elf-cc: command not found
it shows that the suffix is missing in build-newlib-stage-wrapper, when use command "STAGE_WRAPPER {cmd}"
but if I change the var ORIGINAL_ARGS and add suffix ".exe" in file "nios2-newlib-gen"
##add suffix for WSL
uname=$(uname -r)
uname=$(echo ${uname} | tr 'A-Z' 'a-z')
if [[ "${uname}" =~ "microsoft" ]]
then
cat >>"$STAGE_WRAPPER" <<"EOF"
echo "ORIGINAL_ARGS = ${ORIGINAL_ARGS}"
#ORIGINAL_ARGS=$(echo ${ORIGINAL_ARGS} | sed -e "s,-B, -B,g")
#ORIGINAL_ARGS=$(echo ${ORIGINAL_ARGS} | sed -e "s,-i, -i,g")
#ORIGINAL_ARGS=$(echo ${ORIGINAL_ARGS} | sed -e "s,^nios2-elf-cc,nios2-elf-gcc,g")
echo "ORIGINAL_ARGS = ${ORIGINAL_ARGS}"
cmd=$(echo $ORIGINAL_ARGS | awk 'NR==1{print $1}')
echo "cmd = $cmd"
ORIGINAL_ARGS=$(echo ${ORIGINAL_ARGS} | sed -e "s,^$cmd,$cmd.exe,g")
EOF
fi
it still not work. in newlib tmporary config.log shows that it still not add suffix .exe when configure call nios2-elf-gcc
So, it is complicated to fix script bugs to compile newlib in wsl by using mingw32 tool chain because newlib configure not add suffix for command even throught add suffix in STAGE_WRAPPER file!
I doubt! Why Quartus not just migrate tool chain for linux platform and just remove mingw32 tool chain which has annoying suffix ".exe" because of using WSL , nearly a real linux enviroment!!!!!
So, I copy tool chain "H-x86_64-pc-linux-gnu" from linux platform
and edit "niso2_command_shell.sh" like this:
# if grep -q Microsoft /proc/version; then
if [ -d "${SOPC_KIT_NIOS2}/bin/gnu/H-x86_64-mingw32/bin" ]; then
env_var_prepend ${SOPC_KIT_NIOS2}/bin/gnu/H-x86_64-mingw32/bin
else
env_var_prepend ${SOPC_KIT_NIOS2}/bin/gnu/H-i686-mingw32/bin
fi
# else
if [ -d "${SOPC_KIT_NIOS2}/bin/gnu/H-x86_64-pc-linux-gnu/bin" ]; then
env_var_prepend ${SOPC_KIT_NIOS2}/bin/gnu/H-x86_64-pc-linux-gnu/bin
else
env_var_prepend ${SOPC_KIT_NIOS2}/bin/gnu/H-i686-pc-linux-gnu/bin
fi
# fi
comment if-else-if
and doses not need edit any thing in "nios2-newlib-gen"
Be brief:
there are two methods to solve these issues caused by wsl enviroment:
1. just use nios2eds with Qurtus 18.1 pro, which use cygwin shell enviroment, works perfect on windows platform.
2. copy tool chain "H-x86_64-pc-linux-gnu" form linux version's Quartus Pro to directory "niso2eds/bin/gnu/", so in makefile, use tool chain "H-x86_64-mingw32" and when compile newlib, use "H-x86_64-pc-linux-gnu" by itself.
[Advice]:
it is too complicated to use var WINDOWS_EXE,
If you really want try WSL or WLS2, WHY NOT JUST MINGRATE LINUX TOOL CHAIN AND ERVERY RELATED SCRIPT to WSL enviroment and DISCARD "H-x86_64-mingw32" TOOL CHAIN!!!!!!!!
OR
rollback to use cygwin!
these issues had been existed for three years since you discarded cygwin and started to use WSL. CAN ANYBODY FIX IT ?