-
Notifications
You must be signed in to change notification settings - Fork 75
BUG: honor MACOSX_DEPLOYMENT_TARGET #153
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
Conversation
Signed-off-by: Filipe Laíns <[email protected]>
Should we also fallback to |
This will prevent the duplicated MACOSX_DEPLOYMENT_TARGET message. Signed-off-by: Filipe Laíns <[email protected]>
@rgommers thoughts on this? I am unsure about the implications. |
I was just looking at it. I think this is correct as is. I do not think we need to use |
Alright, thanks! |
Let me try to play with this a bit locally. I want to make sure that I understand where the original input comes from. |
Okay. After looking into it a bit more, I think we only have to mimic Meson's behavior though. |
Ah I see, right now we start from >>> sysconfig.get_platform()
'macosx-11.0-arm64' The logic should probably be:
Otherwise we get strange issues when we different Python interpreters are built for different targets. What needs checking first though is how Meson makes its choices. Because in the end the tags need to match what the packaged extension modules are actually built for. |
We could potentially just set |
This is a little nontrivial, we should add to the docs how this works. We discussed this previously in https://github.com/FFY00/meson-python/issues/91#issuecomment-1175477386. There is more to it though.
On modern macOS systems, Clang is the default and is what the majority of folks are going to be building with. Extra complication: Clang has no good Fortran compiler, so we often end up with
if [ "${MACOSX_DEPLOYMENT_TARGET:-0}" != "0" ]; then
CPPFLAGS_USED="$CPPFLAGS_USED -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
fi
_CMAKE_ARGS="${_CMAKE_ARGS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" I don't know why it only adds So I think that we cannot know for sure what will happen when What the deployment target for the Python interpreter was at the time that that interpreter was built should not be relevant at all for us. That |
Given what I wrote above about how |
I'm still not sure if we should be doing that though. At that point, it becomes impossible to build a wheel only for the current OS version - which is what should be fastest and most performant. If you build for yourself, you don't want to have compat shims or older versions of functions linked in for you. The right design I think is to build for the current OS version, and redistributors should explicitly target the minimum OS they want or can support. We already had problems with what |
For |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is a clear improvement as is. We can merge it in its current form, and the rest can be done as a follow up in Meson, and a docs PR.
IIRC from my previous research about this, clang did used to honor
I don't follow, we can set this env var before running Meson.
Agreed.
Given that GCC already does respect it, and if I am correct older Clang versions too, I think if we want to do this, we can start doing it right now. I think If Meson doesn't handle this correctly, this PR itself will be problematic. |
Why not? Older version should be compatible with newer ones AFAIK. |
Activation scripts are run on environment activation, not each time the binary for the compiler is called.
It's extra overhead and compile flags, and possibly lower performance. It's also not good design from first principles. If I'm building on my system, for my OS, and not for redistribution (which is the vast majority of builds I think), a packaging library should not force me to target an older OS version.
Yes, I agree. I need to verify with a non-conda Python/environment. We need it to be correct and consistent for at least python.org installers, system Python, conda and Homebrew.
This PR does improve things (it will fix things for conda-forge and probably also for Homebrew clang), but yes it's still wrong. |
Did some testing: # Homebrew clang was already installed; can be done with `brew install llvm`
% export MACOSX_DEPLOYMENT_TARGET=11.4
% export CC=/opt/homebrew/Cellar/llvm/14.0.6_1/bin/clang
% export CXX=/opt/homebrew/Cellar/llvm/14.0.6_1/bin/clang++
% /opt/homebrew/Cellar/[email protected]/3.10.6_2/bin/pip3 install ninja
% cd ~/code/meson/test cases/osx/1 basic
% meson setup build Then searching # This is the build file for project "osx fundamentals"
# It is autogenerated by the Meson build system.
# Do not edit by hand.
ninja_required_version = 1.8.2
# Rules for module scanning.
# Rules for compiling.
rule c_COMPILER
command = /opt/homebrew/Cellar/llvm/14.0.6_1/bin/clang $ARGS -MD -MQ $out -MF $DEPFILE -o $out -c $in
deps = gcc
depfile = $DEPFILE_UNQUOTED
description = Compiling C object $out
# Rules for linking.
rule c_LINKER
command = /opt/homebrew/Cellar/llvm/14.0.6_1/bin/clang $ARGS -o $out $in $LINK_ARGS
description = Linking target $out
# Other rules
rule CUSTOM_COMMAND
command = $COMMAND
description = $DESC
restat = 1
rule REGENERATE_BUILD
command = /Users/rgommers/mambaforge/bin/meson --internal regenerate '/Users/rgommers/code/meson/test$ cases/osx/1$ basic' '/Users/rgommers/code/meson/test$ cases/osx/1$ basic/build'
description = Regenerating build files.
generator = 1
# Phony build target, always out of date
build PHONY: phony
# Build rules for targets
build prog.p/main.c.o: c_COMPILER ../main.c
DEPFILE = prog.p/main.c.o.d
DEPFILE_UNQUOTED = prog.p/main.c.o.d
ARGS = -Iprog.p -I. -I.. -fcolor-diagnostics -Wall -Winvalid-pch -O0 -g
build prog: c_LINKER prog.p/main.c.o
LINK_ARGS = -Wl,-dead_strip_dylibs -Wl,-headerpad_max_install_names -Wl,-undefined,error
# Test rules
build test: phony meson-internal__test
build meson-internal__test: CUSTOM_COMMAND all PHONY
COMMAND = /Users/rgommers/mambaforge/bin/meson test --no-rebuild --print-errorlogs
DESC = Running$ all$ tests.
pool = console
build benchmark: phony meson-internal__benchmark
build meson-internal__benchmark: CUSTOM_COMMAND all PHONY
COMMAND = /Users/rgommers/mambaforge/bin/meson test --benchmark --logbase benchmarklog --num-processes=1 --no-rebuild
DESC = Running$ benchmark$ suite.
pool = console
# Install rules
build install: phony meson-internal__install
build meson-internal__install: CUSTOM_COMMAND PHONY | all
DESC = Installing$ files.
COMMAND = /Users/rgommers/mambaforge/bin/meson install --no-rebuild
pool = console
build dist: phony meson-internal__dist
build meson-internal__dist: CUSTOM_COMMAND PHONY
DESC = Creating$ source$ packages
COMMAND = /Users/rgommers/mambaforge/bin/meson dist
pool = console
# Suffix
build ctags: phony meson-internal__ctags
build meson-internal__ctags: CUSTOM_COMMAND PHONY
COMMAND = /Users/rgommers/mambaforge/bin/meson --internal tags ctags '/Users/rgommers/code/meson/test$ cases/osx/1$ basic'
pool = console
build uninstall: phony meson-internal__uninstall
build meson-internal__uninstall: CUSTOM_COMMAND PHONY
COMMAND = /Users/rgommers/mambaforge/bin/meson --internal uninstall
pool = console
build all: phony meson-test-prereq meson-benchmark-prereq prog
build meson-test-prereq: phony prog
build meson-benchmark-prereq: phony
build clean: phony meson-internal__clean
build meson-internal__clean: CUSTOM_COMMAND PHONY
COMMAND = /opt/homebrew/bin/ninja -t clean
description = Cleaning
build build.ninja: REGENERATE_BUILD ../meson.build meson-private/coredata.dat
pool = console
build reconfigure: REGENERATE_BUILD PHONY
pool = console
build ../meson.build meson-private/coredata.dat: phony
default all Now what I can't check is if the produced binary works on an older OS version. It shouldn't though. |
I guess a pain point is that Having every project reinvent the wheel by passing a compiler flag is not a reasonable thing to do I think. So it has to be handled somewhere, somehow. Argh .... |
There are no hits in Meson for xref https://cibuildwheel.readthedocs.io/en/stable/cpp_standards/#macos-and-deployment-target-versions for some useful info |
The |
Signed-off-by: Filipe Laíns [email protected]