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

clang: error: linker command failed with exit code 1 (use -v to see invocation) on m1 mac #91131

Closed
Battant mannequin opened this issue Mar 10, 2022 · 12 comments
Closed
Labels
3.11 only security fixes build The build process and cross-build OS-mac

Comments

@Battant
Copy link
Mannequin

Battant mannequin commented Mar 10, 2022

BPO 46975
Nosy @ronaldoussoren, @jaraco, @ned-deily, @akulakov

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2022-03-23.13:44:01.503>
created_at = <Date 2022-03-10.16:38:01.295>
labels = ['OS-mac', 'build', '3.11']
title = 'clang: error: linker command failed with exit code 1 (use -v to see invocation) on m1 mac'
updated_at = <Date 2022-03-23.13:46:53.164>
user = 'https://bugs.python.org/Battant'

bugs.python.org fields:

activity = <Date 2022-03-23.13:46:53.164>
actor = 'jaraco'
assignee = 'none'
closed = True
closed_date = <Date 2022-03-23.13:44:01.503>
closer = 'jaraco'
components = ['macOS']
creation = <Date 2022-03-10.16:38:01.295>
creator = 'Battant'
dependencies = []
files = []
hgrepos = []
issue_num = 46975
keywords = []
message_count = 12.0
messages = ['414859', '414873', '415183', '415831', '415832', '415835', '415836', '415840', '415871', '415873', '415874', '415875']
nosy_count = 5.0
nosy_names = ['ronaldoussoren', 'jaraco', 'ned.deily', 'andrei.avk', 'Battant']
pr_nums = []
priority = 'normal'
resolution = 'third party'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'compile error'
url = 'https://bugs.python.org/issue46975'
versions = ['Python 3.11']

@Battant
Copy link
Mannequin Author

Battant mannequin commented Mar 10, 2022

Hello,

Here is my configuration

mac os 12.2.1
mac m1 pro 2021

step to reproduce

  1. on mac m1, clone cpython repository main branch
    run
    ./confugure
    make
    Actual result :
    gcc -fno-semantic-interposition -fprofile-instr-generate -Wl,-stack_size,1000000 -framework CoreFoundation -o python.exe Programs/python.o libpython3.10d.a -ldl -framework CoreFoundation
    gcc -fno-semantic-interposition -fprofile-instr-generate -Wl,-stack_size,1000000 -framework CoreFoundation -o Programs/_testembed Programs/_testembed.o libpython3.10d.a -ldl -framework CoreFoundation
    Undefined symbols for architecture arm64:
    "_libintl_bindtextdomain", referenced from:
    Undefined symbols for architecture arm64:
    "_libintl_bindtextdomain", referenced from:
    __locale_bindtextdomain_impl in libpython3.10d.a(_localemodule.o)
    __locale_bindtextdomain_impl in libpython3.10d.a(_localemodule.o)
    "_libintl_dcgettext", referenced from:
    "_libintl_dcgettext", referenced from:
    __locale_dcgettext_impl in libpython3.10d.a(_localemodule.o)
    __locale_dcgettext_impl in libpython3.10d.a(_localemodule.o)
    "_libintl_dgettext", referenced from:
    "_libintl_dgettext", referenced from:
    __locale_dgettext_impl in libpython3.10d.a(_localemodule.o)
    __locale_dgettext_impl in libpython3.10d.a(_localemodule.o)
    "_libintl_gettext", referenced from:
    "_libintl_gettext", referenced from:
    __locale_gettext_impl in libpython3.10d.a(_localemodule.o)
    __locale_gettext_impl in libpython3.10d.a(_localemodule.o)
    "_libintl_setlocale", referenced from:
    "_libintl_setlocale", referenced from:
    __locale_setlocale_impl in libpython3.10d.a(_localemodule.o)
    _locale_decode_monetary in libpython3.10d.a(_localemodule.o)
    __locale_setlocale_impl in libpython3.10d.a(_localemodule.o)
    _locale_decode_monetary in libpython3.10d.a(_localemodule.o)
    "_libintl_textdomain", referenced from:
    "_libintl_textdomain", referenced from:
    __locale_textdomain_impl in libpython3.10d.a(_localemodule.o)
    __locale_textdomain_impl in libpython3.10d.a(_localemodule.o)
    ld: symbol(s) not found for architecture arm64
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[3]: *** [python.exe] Error 1
    make[3]: *** Waiting for unfinished jobs....
    make[3]: *** [Programs/_testembed] Error 1
    make[2]: *** [build_all_generate_profile] Error 2
    make[1]: *** [profile-gen-stamp] Error 2
    make: *** [profile-run-stamp] Error 2

Could you help me please to fix this issus ?

Best regards

Battant

@Battant Battant mannequin added 3.11 only security fixes OS-mac build The build process and cross-build labels Mar 10, 2022
@ned-deily
Copy link
Member

Without more details, this is only a guess but the messages seem to indicate that your build is detecting an installed version of the GNU gettext library, which is optional for Python builds and is not provided by default on macOS, and most likely that version is an Intel-only build of the package and its libintl shared library. Check whether you have an outdated version of gettext and libintl*.dylib installed somewhere, perhaps in /usr/local/, possibly via a third-party package manager like Homebrew or MacPorts, and either remove it or update it with a arm64 (or universal2 fat) build.

@akulakov
Copy link
Contributor

I've had the same issue and fixed it with:

brew remove --ignore-dependencies gettext

@ned thanks for help!

@jaraco
Copy link
Member

jaraco commented Mar 22, 2022

I ran into this same issue. I notice that gettext is a dependency of git, so a common dependency when developing. Is there perhaps a way that CPython could be made to ignore gettext on macos Silicon or to detect an incompatible platform and thus ignore it?

@jaraco jaraco reopened this Mar 22, 2022
@jaraco jaraco reopened this Mar 22, 2022
@ned-deily
Copy link
Member

There shouldn't be a problem as long as gettext is properly installed on an M1 Mac, i.e. with an arm64 arch or a universal build that includes arm64.

@jaraco
Copy link
Member

jaraco commented Mar 22, 2022

Well, I'm using a mac with gettext installed as part of brew install git with homebrew installed using the standard procedure.

Only after running brew remove --ignore-dependencies gettext and re-running configure/make did the command build, but doing so also broke features of git (I noticed that the branch name disappeared from my shell). I was able to reinstall git and gettext, but then configure/make failed.

Do you have any advice on how to "properly install" gettext using homebrew on an M1 mac?

@ned-deily
Copy link
Member

This also applies to any other third-party library that a cpython build may link to, like the OpenSSL libs. Some legacy tools that depend on them may work in Rosetta 2 Intel-64 emulation mode on an Apple Silicon Mac but eventually that will go away so it is important to move away from any inadvertent Rosetta dependencies.

I don't use Homebrew myself but a quick web search comes up with a number of hits on how to proceed. It looks like the general idea is to save your list of installed brew packages, reinstall the base homebrew to install Apple Silicon native versions, and then reinstall the top-level packages you had and want and you should be good to go from there on.

@jaraco
Copy link
Member

jaraco commented Mar 22, 2022

SG. Thanks for the advice. I'll dive in and experiment and report back when I have progress.

@jaraco jaraco reopened this Mar 22, 2022
@jaraco jaraco reopened this Mar 22, 2022
@jaraco
Copy link
Member

jaraco commented Mar 23, 2022

I did this search, which surfaced a few related results.

This article seemed promising, but the symptoms there are different than mine. I don't have any gettext libs showing up in /usr/local (only in /opt/homebrew as expected).

I noticed this comment reports the same issue I have, but no solution is present.

I saw a suggestion to set FLAGS, but I do that as a matter of course.

I don't have an x86 install of homebrew. This machine is less than a month old and has had ARM-based homebrew installed from the beginning.

I'll keep investigating.

@jaraco
Copy link
Member

jaraco commented Mar 23, 2022

As suggested, I uninstalled and reinstalled everything in homebrew:

$ brew list | xargs brew remove
$ brew install python@3.10 python-launcher python@3.9 python@3.8 gh git

Even after following those steps and setting LDFLAGS and CPPFLAGS to point to brew --prefix, the errors continue when running ./configure; make in a clean checkout.

@jaraco
Copy link
Member

jaraco commented Mar 23, 2022

Aha. If I configure/make without LDFLAGS or CPPFLAGS set, compilation works. Then I noticed for LDFLAGS, some users were using -L. I thought it was slightly odd that my recipe was using -I for both flags. How is it that this mistake hasn't caused me any grief until M1 build? No matter - correcting for that mistake and passing the correct LDFLAGS flag (-L) corrects for the issue.

@jaraco jaraco closed this as completed Mar 23, 2022
@jaraco jaraco closed this as completed Mar 23, 2022
@jaraco
Copy link
Member

jaraco commented Mar 23, 2022

It's possible my bad experience may have been avoided through bpo-35905.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes build The build process and cross-build OS-mac
Projects
None yet
Development

No branches or pull requests

3 participants