-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defaults for Meson build options, linking issues with MSVC #381
Comments
Thanks for getting to the bottom of this! I agree that (1) is not ideal. I think we should do (2) indeed, set it to
I'm fairly sure that dynamic linking is the default for both |
These posts contain relevant information: mesonbuild/meson#10808 I particular:
|
I did some testing with SciPy, and there are no extra failures with |
Switch from debug=false, optimization=2 to buildtype=release. Despite what the Meson documentation says, the former does not change the default buildtype=debug, which undesired effects on other settings derived from the value of the buildtype option. Whit the default b_vscrt=from_buildtype option, Meson instructs the MSVC compiler to use the debug version of the VS runtime library when buildtype=debug. This causes the linker look for the debug build of all the linked DLLs. The Python distribution for Windows does not contain a debug version of the python.dll and linking fails. To avoid this issue when the user explicitly asks for a debug build, also set b_vscrt=mt. The b_ndebug=if-release option set by meson-python also looks at the value of the buildtype and not to the value of the debug options. Setting buildtype=release has the desired effect of disabling assertions. The prefix, python.purelibdir, and python.platlibdir build options are no more necessary after the heuristic for determining the location where installed files need to be placer from their installation location has been removed in mesonbuild#280. Remove them. Fixes mesonbuild#381.
Switch from debug=false, optimization=2 to buildtype=release. Despite what the Meson documentation says, the former does not change the default buildtype=debug, which undesired effects on other settings derived from the value of the buildtype option. Whit the default b_vscrt=from_buildtype option, Meson instructs the MSVC compiler to use the debug version of the VS runtime library when buildtype=debug. This causes the linker look for the debug build of all the linked DLLs. The Python distribution for Windows does not contain a debug version of the python.dll and linking fails. To avoid this issue when the user explicitly asks for a debug build, also set b_vscrt=mt. The b_ndebug=if-release option set by meson-python also looks at the value of the buildtype and not to the value of the debug options. Setting buildtype=release has the desired effect of disabling assertions. The prefix, python.purelibdir, and python.platlibdir build options are no more necessary after the heuristic for determining the location where installed files need to be placer from their installation location has been removed in mesonbuild#280. Remove them. Fixes mesonbuild#381.
Wow, read those blog posts now, that is .... not good. |
Switch from debug=false, optimization=2 to buildtype=release. Despite what the Meson documentation says, the former does not change the default buildtype=debug, which undesired effects on other settings derived from the value of the buildtype option. Whit the default b_vscrt=from_buildtype option, Meson instructs the MSVC compiler to use the debug version of the VS runtime library when buildtype=debug. This causes the linker look for the debug build of all the linked DLLs. The Python distribution for Windows does not contain a debug version of the python.dll and linking fails. To avoid this issue when the user explicitly asks for a debug build, also set b_vscrt=mt. The b_ndebug=if-release option set by meson-python also looks at the value of the buildtype and not to the value of the debug options. Setting buildtype=release has the desired effect of disabling assertions. The prefix, python.purelibdir, and python.platlibdir build options are no more necessary after the heuristic for determining the location where installed files need to be placer from their installation location has been removed in mesonbuild#280. Remove them. Fixes mesonbuild#381.
Switch from debug=false, optimization=2 to buildtype=release. Despite what the Meson documentation says, the former does not change the default buildtype=debug, which undesired effects on other settings derived from the value of the buildtype option. Whit the default b_vscrt=from_buildtype option, Meson instructs the MSVC compiler to use the debug version of the VS runtime library when buildtype=debug. This causes the linker look for the debug build of all the linked DLLs. The Python distribution for Windows does not contain a debug version of the python.dll and linking fails. To avoid this issue when the user explicitly asks for a debug build, also set b_vscrt=mt. The b_ndebug=if-release option set by meson-python also looks at the value of the buildtype and not to the value of the debug options. Setting buildtype=release has the desired effect of disabling assertions. The prefix, python.purelibdir, and python.platlibdir build options are no more necessary after the heuristic for determining the location where installed files need to be placer from their installation location has been removed in #280. Remove them. Fixes #381.
Meson native default build options set
buildtype=debug
https://mesonbuild.com/Builtin-options.html#core-options This impliesdebug=true
,optimization=0
https://mesonbuild.com/Builtin-options.html#details-for-buildtypemeson-python sets
debug=false
,optimization=2
. This was understood to result in a "release" kind of build. Note thatbuildtype=release
would setoptimization=3
thus is not exactly the same. Also note that, despite what the Meson documentation says, settingdebug
andoptimization
separately has no effect on thebuildtype
configured for the build.However, these settings do not result in the
buildtype
to change. Therefore, other build options whose values are derived frombuildtype
are set as for adebug
build.In particular, the default value for the
b_vscrt
build option https://mesonbuild.com/Builtin-options.html#base-options in particular isfrom_buildtype
which means that on adebug
build the MSVC compiler will link with the debug version of the VS runtime library, which in turn will make the linker look for the debug build of all the linked DLLs. This is problematic because the regular Python distribution for Windows does not contain a debug version ofpython.dll
and linking fails. This was the reason for build issues in #371 and most likely for other build issue reported in unrelated issues.This also result in the
b_ndebug
option that meson-python sets toif-release
to do not work as intended (or, at least, not as I understood it was intended to work):buildtype
different fromrelease
impliesb_ndebug=false
independent of the value assigned to thedebug
option. This is demonstrated in #379.There may be other behavior of Meson that depends on the value assigned to
buildtype
regardless to the value assigned to the separatedebug
andoptimization
options.While the
-DNDEBUG
issue is not critical and other consequences of havingbuildtype=debug
may at worst be not-so-well optimized builds, theb_vscrt
issue results in build failures and should be addressed somehow.If we focus the attention to the
b_vscrt
option only, there are a few possible solutions:buildtype
to something different fromdebug
so thatb_vscrt
gets the correct value. This incurs in the minor issue that Meson emits a warning whendebug
oroptimization
in combination withbuildtype
.b_vscrt
to do the right thing regardless of the value ofbuildtype
.I don't think that (1) goes in the spirit of the defaults adopted for meson-python so far.
Solution (2) seems a bit heavy handed, but for most things there is no much of a practical difference between setting
debug=false
,optimization=2
and settingbuildtype=release
. Another option could be to setbuildtype=debugoptimized
,debug=false
, but this still presents theb_ndebug
issue and having a debug build without debug symbols seems paradoxical.Because setting the from VS runtime library compilation flags results in a link failure on most systems, maybe we should do (3) regardless. However, I'm not sure about what the right value for that option would be: does Python require a dynamically or statically linked VS runtime?
The text was updated successfully, but these errors were encountered: