MSYS 与 MinGW:内部环境变量
MSYS vs. MinGW: internal environment variables
MSYS2默认shell(bash)可以在三个启动器中选择启动,同时设置环境变量MSYSTEM
。具体来说:
msys2_shell.bat
将其设置为 MSYS
mingw64_shell.bat
将其设置为 MINGW64
和
mingw32_shell.bat
将其设置为 MINGW32
。
除了 shells 的提示外,可见的差异是:
- 导出了一个等效的 shell 变量
$MSYSTEM
;
uname
输出基于 $MSYSTEM
;
- 当
$MSYSTEM
为MINGW*
时,/mingw*/bin
为$PATH
中的第一个路径。
假设我们有 /usr/bin/gcc
、/mingw64/bin/gcc
、/mingw32/bin/gcc
,设置值 $MSYSTEM
的合理结果是我们将使用不同的编译器生成不同的二进制(POSIX 或本机 32/64)。
$MSYSTEM
值决定的其他显着差异是什么?
- 是否有特定使用此变量的二进制文件?
pacman
是否受子系统影响?
您应该查看 /etc/profile
(来自 this file on GitHub)。在那里你可以看到 MSYSTEM
影响:
PATH
PKG_CONFIG_PATH
ACLOCAL_PATH
MANPATH
MINGW_MOUNT_POINT
此外,还有一个 pull request 添加了 /etc/profile/msystem
,这将是一个根据 MSYSTEM
.
设置额外变量的脚本
三种选择背后的意图是让您可以选择两种不同的开发环境:
MinGW:用于开发本机 Windows 应用程序。这进一步分为:
- 用于生成 32 位可执行文件的 Mingw32,当然还有
- 用于生成 64 位可执行文件的 Mingw64
将这里视为您进行最终用户开发的地方。 MSYS2 环境本身通常不会 运行 的软件。
MSYS:旨在构建将在具有 FHS 样式文件系统命名的 posix-y 环境中运行的应用程序。将此视为您将在 Msys2 中实际 运行ning 的工具进行开发的地方。或者,您可以像对待 Cygwin 一样思考它。
您可以在 MSYS2 sourceforge 论坛的 this thread 中获得关于此主题的更多信息。
以下摘自 MinGW-w64 贡献者 Ray Donnelly 的 post。它启发了这个主题,是我的问题的重要序言。
There are 3 systems, MSYS2 and 32-bit and 64-bit Native Windows systems. Each system has its own repository of software packages in the MSYS2 distribution. [...] that is an important distinction between them. MSYS2 implements a POSIX-y FHS filesystem namespace and that's very important for lots of things.
[...]
The MinGW-w64 32-bit and 64-bit systems are Native Windows software which are rooted at /mingw32 and /mingw64 respectively. It's not like we replaced every Linux API call ourselves; most of the upstream projects do this work for us since they already provide Windows ports, but yes sometimes we have to do it. We also add special relocation patches to a lot of the software so that you are free to install the root the whole thing (e.g. C:\msys64) wherever you want. MSYS2 software doesn't need these patches (since the Native Windows location is a hidden installation detail) but MinGW-w64 software often does.
[F]rom an end user perspective, there's only 2 systems, MSYS2 and the XX-bit Native Windows one, and yes, some packages exist for both those systems. Specifically, MSYS2 exists to run development tools necessary to build Native Windows software, so if a build system needs an MSYS2 version of Python or Perl to operate correctly (because it assumes FHS or whatever) then we need to provide those packages. We never add MSYS2 packages without making sure there is a need for them. If you don't know that you need the MSYS2 version of something, then install the appropriate Native Windows one instead.
An example of when you will need MSYS2 Python is if you try to use Google's repo tools. This is because repo uses the fcntl Python module and that module only exists on POSIX-y systems. IMHO Python is doing a bad job of abstracting the OSes here and that's a fundamental thing that a scripting language should do, and fcntl (and pyWin32) should not exist, but I'm not the boss of Python.
Fortunately, Pacman has dependency management and will install the stuff needed for whatever packages you are actually interested in.
GNU Autotools will never work well except via a FHS compliant system with a POSIX shell, and this naturally leads to other tools needing to exist in the same filesystem namespace, such as make, perl, m4, bison, flex etc etc.
考虑到 Ray Donnelly post,构成系统的首要因素是 PATH
变量,因为根据目录优先级 Google 的回购工具将使用MSYS2 或 MinGW 包。
事实上,在 MSYS2 和 MinGW shell 之间切换的 shell
脚本导出环境变量 MSYSTEM
及其参数 mingw32|mingw64|msys
和来源 /etc/profile
。后者又根据 MSYSTEM
的值设置 PATH
。总的来说,对于 MSYS2,PATH
是
/usr/local/bin:/usr/bin:/bin
,而对于 MinGW 64,它是 /mingw64/bin:/usr/local/bin:/usr/bin:/bin
,因此 运行 gcc
编译器将相应地执行 MSYS2 或 MinGW 版本。
还有其他小环境。变量,例如 MANPATH
阅读正确的手册,一旦调用正确的二进制文件,或 PKG_CONFIG_PATH
阅读正确的 lib 文件,在构建时。
至于,pacman
@David Grayson 评论说它没有受到影响并不完全正确。
MSYS2 wiki 含糊地肯定:
Use msys2 shell for running pacman, makepkg, makepkg-mingw and for building POSIX-dependent software that you don't intend to distribute. Use mingw shells for building native software and other tasks.
Ray Donnelly 在另一个 post 中再次澄清了事情:
Generally speaking, you can use any shell for pacman, but you could run into some issues using mingw shells where depending on what packages you've installed into /mingw32 or /mingw64, the post install scripts of packages (which are arbitrary bash scripts) may end up running an unexpected mingw-w64 variant of a program. A concrete example of that would be 'sed'. So running pacman from msys2_shell.bat avoids a class of potential problems (though we'd try to fix any that are reported anyway).
总结:
$MSYSTEM
值决定的其他显着差异是什么?
直接的显着差异在于@David Grayson 确定的路径变量的相关值。
是否有特定使用此变量的二进制文件?
可以肯定的说,没有具体的二进制直接读取$MSYSTEM
,但是大量的软件use/read上面的路径变量都是基于$MSYSTEM
.
pacman
是否受子系统影响?
是的。
What are other significant differences determined by $MSYSTEM value?
郑重声明,python os.path.sep
不同,如下所述:https://github.com/msys2/MSYS2-packages/issues/1591#issuecomment-573336696
这意味着根据您使用的 shell,您的 python 路径中的路径将由 \
或 /
分隔。
MSYS2默认shell(bash)可以在三个启动器中选择启动,同时设置环境变量MSYSTEM
。具体来说:
msys2_shell.bat
将其设置为MSYS
mingw64_shell.bat
将其设置为MINGW64
和mingw32_shell.bat
将其设置为MINGW32
。
除了 shells 的提示外,可见的差异是:
- 导出了一个等效的 shell 变量
$MSYSTEM
; uname
输出基于$MSYSTEM
;- 当
$MSYSTEM
为MINGW*
时,/mingw*/bin
为$PATH
中的第一个路径。
假设我们有 /usr/bin/gcc
、/mingw64/bin/gcc
、/mingw32/bin/gcc
,设置值 $MSYSTEM
的合理结果是我们将使用不同的编译器生成不同的二进制(POSIX 或本机 32/64)。
$MSYSTEM
值决定的其他显着差异是什么?- 是否有特定使用此变量的二进制文件?
pacman
是否受子系统影响?
您应该查看 /etc/profile
(来自 this file on GitHub)。在那里你可以看到 MSYSTEM
影响:
PATH
PKG_CONFIG_PATH
ACLOCAL_PATH
MANPATH
MINGW_MOUNT_POINT
此外,还有一个 pull request 添加了 /etc/profile/msystem
,这将是一个根据 MSYSTEM
.
三种选择背后的意图是让您可以选择两种不同的开发环境:
MinGW:用于开发本机 Windows 应用程序。这进一步分为:
- 用于生成 32 位可执行文件的 Mingw32,当然还有
- 用于生成 64 位可执行文件的 Mingw64
将这里视为您进行最终用户开发的地方。 MSYS2 环境本身通常不会 运行 的软件。
MSYS:旨在构建将在具有 FHS 样式文件系统命名的 posix-y 环境中运行的应用程序。将此视为您将在 Msys2 中实际 运行ning 的工具进行开发的地方。或者,您可以像对待 Cygwin 一样思考它。
您可以在 MSYS2 sourceforge 论坛的 this thread 中获得关于此主题的更多信息。
以下摘自 MinGW-w64 贡献者 Ray Donnelly 的 post。它启发了这个主题,是我的问题的重要序言。
There are 3 systems, MSYS2 and 32-bit and 64-bit Native Windows systems. Each system has its own repository of software packages in the MSYS2 distribution. [...] that is an important distinction between them. MSYS2 implements a POSIX-y FHS filesystem namespace and that's very important for lots of things.
[...] The MinGW-w64 32-bit and 64-bit systems are Native Windows software which are rooted at /mingw32 and /mingw64 respectively. It's not like we replaced every Linux API call ourselves; most of the upstream projects do this work for us since they already provide Windows ports, but yes sometimes we have to do it. We also add special relocation patches to a lot of the software so that you are free to install the root the whole thing (e.g. C:\msys64) wherever you want. MSYS2 software doesn't need these patches (since the Native Windows location is a hidden installation detail) but MinGW-w64 software often does.
[F]rom an end user perspective, there's only 2 systems, MSYS2 and the XX-bit Native Windows one, and yes, some packages exist for both those systems. Specifically, MSYS2 exists to run development tools necessary to build Native Windows software, so if a build system needs an MSYS2 version of Python or Perl to operate correctly (because it assumes FHS or whatever) then we need to provide those packages. We never add MSYS2 packages without making sure there is a need for them. If you don't know that you need the MSYS2 version of something, then install the appropriate Native Windows one instead.
An example of when you will need MSYS2 Python is if you try to use Google's repo tools. This is because repo uses the fcntl Python module and that module only exists on POSIX-y systems. IMHO Python is doing a bad job of abstracting the OSes here and that's a fundamental thing that a scripting language should do, and fcntl (and pyWin32) should not exist, but I'm not the boss of Python.
Fortunately, Pacman has dependency management and will install the stuff needed for whatever packages you are actually interested in.
GNU Autotools will never work well except via a FHS compliant system with a POSIX shell, and this naturally leads to other tools needing to exist in the same filesystem namespace, such as make, perl, m4, bison, flex etc etc.
考虑到 Ray Donnelly post,构成系统的首要因素是 PATH
变量,因为根据目录优先级 Google 的回购工具将使用MSYS2 或 MinGW 包。
事实上,在 MSYS2 和 MinGW shell 之间切换的 shell
脚本导出环境变量 MSYSTEM
及其参数 mingw32|mingw64|msys
和来源 /etc/profile
。后者又根据 MSYSTEM
的值设置 PATH
。总的来说,对于 MSYS2,PATH
是
/usr/local/bin:/usr/bin:/bin
,而对于 MinGW 64,它是 /mingw64/bin:/usr/local/bin:/usr/bin:/bin
,因此 运行 gcc
编译器将相应地执行 MSYS2 或 MinGW 版本。
还有其他小环境。变量,例如 MANPATH
阅读正确的手册,一旦调用正确的二进制文件,或 PKG_CONFIG_PATH
阅读正确的 lib 文件,在构建时。
至于,pacman
@David Grayson 评论说它没有受到影响并不完全正确。
MSYS2 wiki 含糊地肯定:
Use msys2 shell for running pacman, makepkg, makepkg-mingw and for building POSIX-dependent software that you don't intend to distribute. Use mingw shells for building native software and other tasks.
Ray Donnelly 在另一个 post 中再次澄清了事情:
Generally speaking, you can use any shell for pacman, but you could run into some issues using mingw shells where depending on what packages you've installed into /mingw32 or /mingw64, the post install scripts of packages (which are arbitrary bash scripts) may end up running an unexpected mingw-w64 variant of a program. A concrete example of that would be 'sed'. So running pacman from msys2_shell.bat avoids a class of potential problems (though we'd try to fix any that are reported anyway).
总结:
$MSYSTEM
值决定的其他显着差异是什么?
直接的显着差异在于@David Grayson 确定的路径变量的相关值。
是否有特定使用此变量的二进制文件?
可以肯定的说,没有具体的二进制直接读取$MSYSTEM
,但是大量的软件use/read上面的路径变量都是基于$MSYSTEM
.
pacman
是否受子系统影响?
是的。
What are other significant differences determined by $MSYSTEM value?
郑重声明,python os.path.sep
不同,如下所述:https://github.com/msys2/MSYS2-packages/issues/1591#issuecomment-573336696
这意味着根据您使用的 shell,您的 python 路径中的路径将由 \
或 /
分隔。