我无法弄清楚这个问题。我正在尝试构建Microchip XC32 PIC32微控制器GCC交叉编译器。
要自己尝试(这是我遇到的错误):
在Windows 10或Windows 11上:启用“开发人员模式”以允许符号链接。按下Windows键-->搜索“使用开发人员功能”,点击按钮(如下图中的蓝色按钮)将其打开: 克隆我的存储库:https://github.com/ElectricRCAircraftGuy/Microchip_XC32_Compiler 安装MSYS2,并打开MSYS2 UCRT64 shell。可选择按照我的完整MSYS2设置说明进行操作。
通过pacman安装依赖项,如下所示: 将整个代码块一次性复制粘贴到终端中:
# ============= 一次性安装所有依赖项! ============= # UCRT64 if [ "$MSYSTEM" != "UCRT64" ]; then echo "错误:您必须在MSYS2 ucrt64终端中运行此脚本!" exit 1 fi package_list=( "mingw-w64-ucrt-x86_64-gcc" # MSYS2 ucrt64的特定版本 "make" "binutils" "autoconf" "autogen" "bison" "dejagnu" "flex" "gawk" "gperf" "gzip" # "nsis" # 通用版本;必须是特定版本;因此以下行 "mingw-w64-ucrt-x86_64-nsis" # MSYS2 ucrt64的特定版本 "perl" "scons" "tcl" "texinfo" "wget" "zip" # "texlive" # 通用版本;必须是特定版本;因此以下行 "mingw-w64-ucrt-x86_64-texlive-core" # MSYS2 ucrt64的特定版本 # "texlive-extra-utils" # 通用版本;必须是特定版本;因此以下行 "mingw-w64-ucrt-x86_64-texlive-extra-utils" # MSYS2 ucrt64的特定版本 )
# 仅在尚未安装时安装软件包。 for package in "${package_list[@]}"; do if ! pacman -Qs $package > /dev/null; then echo -e "\n=== 未安装$package。正在安装... ===" pacman -S --noconfirm $package else echo -e "\n=== 已安装$package。 ===" fi done echo -e "\n=== 完成安装软件包! ===\n"
运行构建脚本:
time ./build-xc32-v4.35m.sh
大约进行到20分钟时,在编译gcc时失败,同时配置GMP。请注意,为了获得清晰的错误信息,您必须修改构建脚本,将第一行中的
time make -j$(nproc) all-gcc \ STAGE1_LIBS="-lexpat -lmchp -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic" \ CPPFLAGS="-I${hostinstalldir}/include -imacros host-defs.h" \ LDFLAGS=-L${hostinstalldir}/lib
make install-gcc
这是我的失败。当GMP在寻找
请注意,构建脚本在安装依赖项后在Ubuntu 22.04上完美运行,但在MSYS2中的Windows上无法正常工作。非常感谢任何帮助。这将帮助PIC32社区在不购买Microchip许可证的情况下使用GCC进行构建。交叉编译器采用GPL许可证。
我在这里留下了一条评论,提供了更多详细信息:https://github.com/JuliaLang/julia/issues/13206#issuecomment-1791823912。我不再认为符号链接是问题所在,因为我已经尝试直接复制数据到它们上面,但没有任何变化。
我在这里提供了自动生成的
我已经被困在这个问题上好几天了。希望能得到社区的支持。
如果有人想在MSYS2 MINGW64环境中尝试,以下是如何在该终端中安装这些依赖项的方法:
这是自动生成的Makefile代码块感兴趣的部分:
在构建脚本中转换为相对路径,使用
要自己尝试(这是我遇到的错误):
在Windows 10或Windows 11上:启用“开发人员模式”以允许符号链接。按下Windows键-->搜索“使用开发人员功能”,点击按钮(如下图中的蓝色按钮)将其打开: 克隆我的存储库:https://github.com/ElectricRCAircraftGuy/Microchip_XC32_Compiler 安装MSYS2,并打开MSYS2 UCRT64 shell。可选择按照我的完整MSYS2设置说明进行操作。
通过pacman安装依赖项,如下所示: 将整个代码块一次性复制粘贴到终端中:
# ============= 一次性安装所有依赖项! ============= # UCRT64 if [ "$MSYSTEM" != "UCRT64" ]; then echo "错误:您必须在MSYS2 ucrt64终端中运行此脚本!" exit 1 fi package_list=( "mingw-w64-ucrt-x86_64-gcc" # MSYS2 ucrt64的特定版本 "make" "binutils" "autoconf" "autogen" "bison" "dejagnu" "flex" "gawk" "gperf" "gzip" # "nsis" # 通用版本;必须是特定版本;因此以下行 "mingw-w64-ucrt-x86_64-nsis" # MSYS2 ucrt64的特定版本 "perl" "scons" "tcl" "texinfo" "wget" "zip" # "texlive" # 通用版本;必须是特定版本;因此以下行 "mingw-w64-ucrt-x86_64-texlive-core" # MSYS2 ucrt64的特定版本 # "texlive-extra-utils" # 通用版本;必须是特定版本;因此以下行 "mingw-w64-ucrt-x86_64-texlive-extra-utils" # MSYS2 ucrt64的特定版本 )
# 仅在尚未安装时安装软件包。 for package in "${package_list[@]}"; do if ! pacman -Qs $package > /dev/null; then echo -e "\n=== 未安装$package。正在安装... ===" pacman -S --noconfirm $package else echo -e "\n=== 已安装$package。 ===" fi done echo -e "\n=== 完成安装软件包! ===\n"
运行构建脚本:
build-xc32-v4.35m.sh
:time ./build-xc32-v4.35m.sh
大约进行到20分钟时,在编译gcc时失败,同时配置GMP。请注意,为了获得清晰的错误信息,您必须修改构建脚本,将第一行中的
-j$(nproc)
改为-j1
,否则终端中会出现多线程输出混乱的情况:time make -j$(nproc) all-gcc \ STAGE1_LIBS="-lexpat -lmchp -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic" \ CPPFLAGS="-I${hostinstalldir}/include -imacros host-defs.h" \ LDFLAGS=-L${hostinstalldir}/lib
make install-gcc
这是我的失败。当GMP在寻找
mp_limb_t
时,配置似乎失败了。我在下面用<====
标记了一些注释/行:checking for sysctl... no
checking for sysctlbyname... no
checking for times... no
checking for library containing clock_gettime... none required
checking for vsnprintf... yes
checking whether vsnprintf works... probably
configure: WARNING: cannot check for properly working vsnprintf when cross compiling, will assume it's ok
checking whether sscanf needs writable input... no
checking for struct pst_processor.psp_iticksperclktick... no
checking size of void *... 8
checking size of unsigned short... 2
checking size of unsigned... 4
checking size of unsigned long... 4
checking size of mp_limb_t... 0 <===== SIZE SHOULD BE 8
configure: error: Oops, mp_limb_t doesn't seem to work <===== ERROR
make: *** [Makefile:4701: configure-gmp] Error 1
real 3m27.324s
user 0m1.373s
sys 0m30.921s
Error: [gcc] failed to build!
real 3m27.510s
user 0m1.373s
请注意,构建脚本在安装依赖项后在Ubuntu 22.04上完美运行,但在MSYS2中的Windows上无法正常工作。非常感谢任何帮助。这将帮助PIC32社区在不购买Microchip许可证的情况下使用GCC进行构建。交叉编译器采用GPL许可证。
我在这里留下了一条评论,提供了更多详细信息:https://github.com/JuliaLang/julia/issues/13206#issuecomment-1791823912。我不再认为符号链接是问题所在,因为我已经尝试直接复制数据到它们上面,但没有任何变化。
我在这里提供了自动生成的
Makefile
和gcc/gmp/config.log
文件:https://github.com/ElectricRCAircraftGuy/Microchip_XC32_Compiler/tree/main/temp_debug_files。我在该目录的README.md文件中对它们进行了描述。我已经被困在这个问题上好几天了。希望能得到社区的支持。
如果有人想在MSYS2 MINGW64环境中尝试,以下是如何在该终端中安装这些依赖项的方法:
# ============= DO THIS TO INSTALL ALL DEPENDENCIES AT ONCE! =============
# mingw64
if [ "$MSYSTEM" != "MINGW64" ]; then
echo "ERROR: You must run this script in an MSYS2 mingw64 terminal!"
exit 1
fi
package_list=(
"mingw-w64-x86_64-gcc" # specific version for MSYS2 mingw64
"make"
"binutils"
"autoconf"
"autogen"
"bison"
"dejagnu"
"flex"
"gawk"
"gperf"
"gzip"
# "nsis" # generic; must be specific; hence the line below
"mingw-w64-x86_64-nsis" # specific version for MSYS2 mingw64
"perl"
"scons"
"tcl"
"texinfo"
"wget"
"zip"
# "texlive" # generic; must be specific; hence the line below
"mingw-w64-x86_64-texlive-core" # specific version for MSYS2 mingw64
# "texlive-extra-utils" # generic; must be specific; hence the line below
"mingw-w64-x86_64-texlive-extra-utils" # specific version for MSYS2 mingw64
)
# Only install packages if tHey are NOT already installed.
for package in "${package_list[@]}"; do
if ! pacman -Qs $package > /dev/null; then
echo -e "\n=== $package is not installed. Installing... ==="
pacman -S --noconfirm $package
else
echo -e "\n=== $package is already installed. ==="
fi
done
echo -e "\n=== Done installing packages! ===\n"
这是自动生成的Makefile代码块感兴趣的部分:
C:\Users\gabriel\GS\dev\Microchip_XC32_Compiler\xc32-v4.35-src\pic32m-build\gcc\Makefile
。.PHONY: configure-gmp maybe-configure-gmp
maybe-configure-gmp:
maybe-configure-gmp: configure-gmp
configure-gmp:
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
test ! -f $(HOST_SUBDIR)/gmp/Makefile || exit 0; \
$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/gmp; \
$(HOST_EXPORTS) \
echo Configuring in $(HOST_SUBDIR)/gmp; \
cd "$(HOST_SUBDIR)/gmp" || exit 1; \
case $(srcdir) in \
/* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
*) topdir=`echo $(HOST_SUBDIR)/gmp/ | \
sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
esac; \
module_srcdir=gmp; \
$(SHELL) \
$$s/$$module_srcdir/configure \
--srcdir=$${topdir}/$$module_srcdir \
$(HOST_CONFIGARGS) --build=${build_alias} --host=none-${host_vendor}-${host_os} \
--target=none-${host_vendor}-${host_os} --disable-shared LEX="touch lex.yy.c" \
|| exit 1
更多待跟进的潜在客户:
- https://www.google.com/search?q=bug%3A+msys2+doesnt+accept+absolute+paths+in+gcc&oq=bug%3A+msys2+doesnt+accept+absolute+paths+in+gcc&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg60gEJMTQ5NDNqMGo0qAIAsAIA&client=ms-android-google&sourceid=chrome-mobile&ie=UTF-8
- https://stackoverflow.com/a/39256699/4561887
- https://github.com/msys2/MINGW-packages/issues/6711#issuecomment-662982274
/
可能会被MSYS GCC解释为C:\
,这意味着/c/my/path
会被视为C:\c\my\path
而不是C:\my\path
。然而,这与MSYS终端的处理方式相反。真是个让人头疼的问题。研究一下上面的资源。在构建脚本中转换为相对路径,使用
realpath --relative-to
。同时更新我在Stack Overflow上的答案:https://dev59.com/yXVD5IYBdhLWcg3wL4cA#60157372。
#include "/c/Users/<...>/gcc/gmp/gmp-h.in"
看起来有点可疑,因为我认为 MinGW GCC(除了 Cygwin-ish 的/usr/bin/gcc
,你不应该使用)不理解 Linux 风格的路径。配置脚本可能需要修补,以避免生成绝对路径,或者将其转换为 Windows 风格的路径。 - undefinedbash
都会进行路径转换的魔法。编译器本身不会自动完成这个任务。 "请尝试克隆和构建" 我没有Windows机器,而且在虚拟机中可能需要很长时间。我也不知道是什么生成了那个路径... - undefinedC:\Users\gabriel\GS\dev\Microchip_XC32_Compiler\xc32-v4.35-src\pic32m-source\gcc\gmp\configure
:#include "$srcdir/gmp-h.in"
。我认为这是从配置脚本中生成的路径。conftest.c
文件是在configure
文件中生成的。并且从自动生成的主pic32m-build\gcc\Makefile
:--srcdir=$${topdir}/$$module_srcdir
- undefinedtopdir
设置为相对路径... - undefined.../configure
,没有选项和奇怪的环境变量)吗?如果这样可以工作,试着找出脚本在做什么方面有所不同。如果不行,你更有可能找到人来帮助你。另外,msys2有一个GMP包,你可以调整你的脚本来使用那个版本,而不是尝试构建另一个版本。 - undefined