darwin: make sure MACOSX_DEPLOYMENT_TARGET has a minor component (#28926)

This commit is contained in:
Seth R. Johnson 2022-02-15 00:50:22 -05:00 committed by GitHub
parent 9165e3fb86
commit 08cad7d0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,4 +60,13 @@ def setup_platform_environment(self, pkg, env):
"""
os = self.operating_sys[pkg.spec.os]
env.set('MACOSX_DEPLOYMENT_TARGET', str(os.version))
version = os.version
if len(version) == 1:
# Version has only one component: add a minor version to prevent
# potential errors with `ld`,
# which fails with `-macosx_version_min 11`
# but succeeds with `-macosx_version_min 11.0`.
# Most compilers seem to perform this translation automatically,
# but older GCC does not.
version = str(version) + '.0'
env.set('MACOSX_DEPLOYMENT_TARGET', str(version))