Skip to content
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

ld: warning: object file libpython3.9.a was built for newer macOS version (12.0) than being linked (11.4) #408

Open
hakonhagland opened this issue Dec 14, 2021 · 1 comment

Comments

@hakonhagland
Copy link
Contributor

hakonhagland commented Dec 14, 2021

I am trying to build Inline::Python on macOS 12.0.1. I installed perl 5.34.0 with perlbrew before I upgraded my mac from 11.4 to 12.0, this can be seen by running

 $ perl -MData::Dumper -MConfig -E 'print Dumper (\%Config)' | grep macosx
          'ccflags' => '-fno-common -DPERL_DARWIN -mmacosx-version-min=11.4 -fno-strict-aliasing -pipe -fstack-protector-strong -DPERL_USE_SAFE_PUTENV',
          'cppflags' => '-fno-common -DPERL_DARWIN -mmacosx-version-min=11.4 -fno-strict-aliasing -pipe -fstack-protector-strong',
          'lddlflags' => ' -mmacosx-version-min=11.4 -bundle -undefined dynamic_lookup -fstack-protector-strong',
          'ldflags' => ' -mmacosx-version-min=11.4 -fstack-protector-strong',
          'ccflags_nolargefiles' => '-fno-common -DPERL_DARWIN -mmacosx-version-min=11.4 -fno-strict-aliasing -pipe -fstack-protector-strong -DPERL_USE_SAFE_PUTENV',
          'ldflags_nolargefiles' => ' -mmacosx-version-min=11.4 -fstack-protector-strong',

where -mmacosx-version-min=11.4 indicates that perl was built on macOS 11.4. I tried to figure out the meaning of this compiler flag but I could find no clear explanations on google. As I understand, it will trigger compiler warnings from clang if I am trying to link with a library that is built after macOS 11.4. But then again, why is the flag then not called -mmacosx-version-max ? I am confused.

Anyway, after upgrading my mac to 12.0, I installed a new python library with pyenv, and if I now try to build Inline::Python I get the following warnings from clang when running make:

[...]
LD_RUN_PATH="/Users/hakonhaegland/.pyenv/versions/3.9.7/lib/python3.9/config-3.9-darwin" cc -Wl,-rpath,"/Users/hakonhaegland/.pyenv/versions/3.9.7/lib/python3.9/config-3.9-darwin" -mmacosx-version-min=11.4 -bundle -undefined dynamic_lookup -fstack-protector-strong  Python.o py2pl.o perlmodule.o util.o  -o blib/arch/auto/Inline/Python/Python.bundle  \
	   -L/Users/hakonhaegland/.pyenv/versions/3.9.7/lib/python3.9/config-3.9-darwin -lpython3.9 -ldl -Wl,-framework -Wl,CoreFoundation   \

ld: warning: object file (/Users/hakonhaegland/.pyenv/versions/3.9.7/lib/python3.9/config-3.9-darwin/libpython3.9.a(boolobject.o)) was built for newer macOS version (12.0) than being linked (11.4)
ld: warning: object file (/Users/hakonhaegland/.pyenv/versions/3.9.7/lib/python3.9/config-3.9-darwin/libpython3.9.a(bytesobject.o)) was built for newer macOS version (12.0) than being linked (11.4)
ld: warning: object file (/Users/hakonhaegland/.pyenv/versions/3.9.7/lib/python3.9/config-3.9-darwin/libpython3.9.a(object.o)) was built for newer macOS version (12.0) than being linked (11.4)
ld: warning: object file (/Users/hakonhaegland/.pyenv/versions/3.9.7/lib/python3.9/config-3.9-darwin/libpython3.9.a(dictobject.o)) was built for newer macOS version (12.0) than being linked (11.4)
ld: warning: object file (/Users/hakonhaegland/.pyenv/versions/3.9.7/lib/python3.9/config-3.9-darwin/libpython3.9.a(errors.o)) was built for newer macOS version (12.0) than being linked (11.4)
[...]

What is the best approach to avoid this warning ? (The warning disappears if I remove -mmacosx-version-min=11.4 from the above cc command line, or if I change the flag to -mmacosx-version-min=12.0.) Is this something that should be changed in ExtUtils::MakeMaker or in the Makefile.PL of Inline::Python ?

@Leont
Copy link
Member

Leont commented Dec 16, 2021

Basically the linker is worried about the object files (in the libpython static library) using features that the linker doesn't support; even though it probably isn't. Typical Apple being difficult.

Is this something that should be changed in ExtUtils::MakeMaker or in the Makefile.PL of Inline::Python ?

The value comes from perl's configuration, MakeMaker is entirely right to use that. If something needs to be changed it's there, though I'm not sure if it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants