在 Github Actions windows msys2 上,configure 找不到 icu

问题描述

windows-latest 上的 Github 操作中,我使用以下命令调用脚本:

C:\msys64\msys2_shell.cmd -mingw64 -defterm -here -full-path -no-start -shell bash scripts/cibw_before_all_windows.sh

我不明白所有标志的含义,所以可能是其中一个标志是错误的。 cibw_before_all_windows.sh 脚本如下:

pacman -S --noconfirm --needed  \
           bison  \
           flex  \
           icu-devel  \
           swig

export CPPFLAGS="-I/c/msys2/usr/include ${CPPFLAGS}"
export LDFLAGS="-L/c/msys2/usr/lib ${LDFLAGS}"
export PATH="/c/msys2/usr/bin/:${PATH}"
export PKG_CONfig_PATH="/c/msys2/usr/lib/pkgconfig:${PKG_CONfig_PATH}"


cd hfst_src/
autoreconf -fvi
./configure --with-unicode-handler=icu
make
make check V=1 VERBOSE=1
make install
cd ..

python setup.py build_ext

脚本在 ./configure --with-unicode-handler=icu 上失败,输出如下:

...
  checking for ld used by g++... C:/msys64/mingw64/x86_64-w64-mingw32/bin/ld.exe
  checking if the linker (C:/msys64/mingw64/x86_64-w64-mingw32/bin/ld.exe) is GNU ld... yes
  checking whether the g++ linker (C:/msys64/mingw64/x86_64-w64-mingw32/bin/ld.exe) supports shared libraries... yes
  checking for g++ option to produce PIC... -DDLL_EXPORT -DPIC
  checking if g++ PIC flag -DDLL_EXPORT -DPIC works... yes
  checking if g++ static flag -static works... yes
  checking if g++ supports -c -o file.o... yes
  checking if g++ supports -c -o file.o... (cached) yes
  checking whether the g++ linker (C:/msys64/mingw64/x86_64-w64-mingw32/bin/ld.exe) supports shared libraries... yes
  checking dynamic linker characteristics... Win32 ld.exe
  checking how to hardcode library paths into programs... immediate
  checking for gawk... (cached) gawk
  checking how to run the C preprocessor... gcc -E
  checking for bison... bison -y
  checking for flex... flex
  checking for lex output file root... lex.yy
  checking for lex library... none needed
  checking for library containing yywrap... no
  checking whether yytext is a pointer... yes
  checking for getopts... false
  checking for a Python interpreter with version >= 3.0... python
  checking for python... /mingw64/bin/python
  checking for python version... 3.8
  checking for python platform... win32
  checking for python script directory... ${prefix}/lib/python3.8/site-packages
  checking for python extension module directory... ${exec_prefix}/lib/python3.8/site-packages
  configure: WARNING: Building hfst successfully requires flex newer than 2.5.33 on some platforms. Unless you are building with pre-flex-generated sources,building will probably fail.
  checking whether ln -s works... no,using cp -pR
  checking whether make sets $(MAKE)... (cached) yes
  checking for doxygen... no
  checking for main in -ldl... no
  checking for main in -lpthread... yes
  checking for main in -lm... yes
  checking for ncurses.h... no
  checking for curses.h... no
  checking for termcap.h... yes
  checking for tgetent in -ltermcap... yes
  checking for icu-config... /usr/bin/icu-config
  checking for pkg-config... /mingw64/bin/pkg-config
  ### icu-config: Can't find /usr/lib/msys-icuuc68.dll - ICU prefix is wrong.
  ###      Try the --prefix= option 
  ###      or --detect-prefix
  ###      (If you want to disable this check,use  the --noverify option)
  ### icu-config: Exitting.
  expr: Syntax error: unexpected argument '50'
  configure: error: in `/d/a/hfst-python/hfst-python/hfst_src':
  configure: error: --with-unicode-handler=icu requested but icu>=50 not found
  See `config.log' for more details
  Error: Command C:\msys64\msys2_shell.cmd -mingw64 -defterm -here -full-path -no-start -shell bash scripts/cibw_before_all_windows.sh Failed with code 1. None

输出来看,configure 似乎找不到我全新安装的 flexbisonicu。如何让 configure 查看来自 pacman 的安装?有没有更好的方法解决一般问题?

编辑

pacman 安装的版本是...

bison-3.7.4-1
flex-2.6.4-1
icu-devel-68.2-1
swig-4.0.2-1

我说它看不到我的 flexbison 的原因是它抱怨 configure: WARNING: Building hfst successfully requires flex newer than 2.5.33 on some platforms. Unless you are building with pre-flex-generated sources,building will probably fail.。由于 pacman 的 flex 版本是 flex-2.6.4-1,我假设 configure 在系统的其他地方找到了不同的版本。这让我怀疑它也没有找到任何其他依赖项的 pacman 版本。

解决方法

pacman 为这些包安装 .pc 文件的位置添加到环境变量 PKG_CONFIG_PATH

,

从输出看来,configure 找不到我的新 安装 flex、bison 和 icu。

不,这看起来根本不是问题。 configure 输出显示它看到了 Flex、Bison 和 ICU:

checking for bison... bison -y
checking for flex... flex

[...]

checking for icu-config... /usr/bin/icu-config

诊断输出包含来自 icu-configconfigure 的消息:

### icu-config: Can't find /usr/lib/msys-icuuc68.dll - ICU prefix is wrong.
###      Try the --prefix= option 
###      or --detect-prefix
###      (If you want to disable this check,use  the --noverify option)
### icu-config: Exitting.
expr: syntax error: unexpected argument '50'
configure: error: in `/d/a/hfst-python/hfst-python/hfst_src':
configure: error: --with-unicode-handler=icu requested but icu>=50 not found
See `config.log' for more details

关键问题似乎是您的 ICU 安装已损坏,这可能是您安装它的 (pacman) 软件包的问题。 icu-config 程序应该属于那个包,如果它没有找到或不能识别其他包组件,那么它要么是扁平化的,要么是与包的其余部分不匹配。更直接地在您的控制下对 msys2 安装进行验证是值得的,但假设您可以这样做,这应该作为打包错误提出。我想那会转到 msys2 项目。

来自 configure 的诊断看起来像是 icu-config 失败的后续结果,可能本身并不是问题。

如何获取配置以查看 从 pacman 安装?

它看到了他们。它们只是坏了(无论如何,icu-devel 包是坏的)。

有没有更好的方法来处理 一般问题?

我认为您的方法总体上很好。我建议您在将本地 msys2 安装设置为 GitHub 操作之前对其进行测试。您目前面临的问题的一种可能解决方法是向 pacman 询问每个软件包的特定已知良好版本,而不是让它选择最新的可用版本。由于这样做会使您的构建更具可重复性,您可能会认为这是对您的方法的改进。

或者,icu-config 输出建议了其他一些可能性,尤其是将 --detect-prefix 选项或 --noverify 选项添加到 icu-config 命令行。这将在 configure 中完成,如果它实际上解决了问题,那么它可能比等待通过 msys2 的过程解决问题更快(不反对 msys2;只是这些事情需要时间)。