Skip to content

macOS builds expose stack_size option in LINKEDFOORSHARED and pyconfig #79141

Closed

Description

@xzcvczx
mannequin
BPO 34960
Nosy @ronaldoussoren, @ned-deily

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 = None
created_at = <Date 2018-10-11.18:11:21.238>
labels = ['OS-mac', '3.8', 'type-bug', '3.7']
title = 'macOS builds expose stack_size option in LINKEDFOORSHARED and pyconfig'
updated_at = <Date 2018-10-11.20:24:38.766>
user = 'https://bugs.python.org/xzcvczx'

bugs.python.org fields:

activity = <Date 2018-10-11.20:24:38.766>
actor = 'xzcvczx'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['macOS']
creation = <Date 2018-10-11.18:11:21.238>
creator = 'xzcvczx'
dependencies = []
files = []
hgrepos = []
issue_num = 34960
keywords = []
message_count = 7.0
messages = ['327545', '327546', '327548', '327549', '327550', '327551', '327552']
nosy_count = 3.0
nosy_names = ['ronaldoussoren', 'ned.deily', 'xzcvczx']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue34960'
versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

Activity

  1. xzcvczx commented on Oct 11, 2018

    xzcvczxmannequin
    MannequinAuthor

    if you didn't build python as a framework it adds sysconfig.get_config_vars('LINKFORSHARED') when you run 'python-config --ldflags' this resolves to

    >>> sysconfig.get_config_var('LINKFORSHARED')
    '-Wl,-stack_size,1000000  -framework CoreFoundation /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Python'

    the '-Wl,-stack_size' ldflag causes issues for clang with the error

    "ld: -stack_size option can only be used when linking a main executable"

  2. added
    3.7 (EOL)
    type-bug
    on Oct 11, 2018
  3. ned-deily commented on Oct 11, 2018

    @ned-deily
    Member

    Sorry, I can't reproduce that behavior. What's more, that LINKFORSHARED value does not appear to be correct. Have you tried doing a build from a clean build dicectory while rerunning ./configure? What does your ./configure look like and do have any relevant env variables set?

    >>> sysconfig.get_config_var('LINKFORSHARED')
    '-Wl,-stack_size,1000000  -framework CoreFoundation'
  4. xzcvczx commented on Oct 11, 2018

    xzcvczxmannequin
    MannequinAuthor

    with a fresh 3.7.0 download

    ./configure --prefix=... --enable-shared
    make -j5
    make install

    path/to/python3-config --ldflags
    -lpython3.7m -ldl -framework CoreFoundation -Wl,-stack_size,1000000 -framework CoreFoundation

  5. ned-deily commented on Oct 11, 2018

    @ned-deily
    Member

    Oh, you didn't mention --enable-shared! But still it's not clear to me what problem your last results shows. The value of python3-config --ldflags looks fine (ignore the repeated -framework CoreFoundation). Are you still getting the "ld: -stack_size option can ...' message when you built the second time? An installed --enable-shared build for me works just fine when using a non-standard prefix, i.e. a location where there is not already a Python3 installed. So I still can't reproduce a problem.

    By the way, I always recommend to avoid using the --enable-shared option for macOS builds; I know there are cases in the past where there *has* been build issues when building shared and there is already a Python installed at that prefix. If possible, stick either a "plain Unix" build (no --enable-shared, no --enable-framework) or a framework build. You're less likely to run into at first glance head-scratching building and linking issues.

  6. xzcvczx commented on Oct 11, 2018

    xzcvczxmannequin
    MannequinAuthor

    ah ok, sorry i wasn't clear at first, the issue isn't when building python its when building a library which depends on python in this case libxml2, which when given the --enable-python stuff uses "PYTHON_LIBS=python$PYTHON_VERSION-config --ldflags" and therefore is being given the -Wl,stack_size linker option which is not valid for non main executables according to the error produced from clang

  7. ned-deily commented on Oct 11, 2018

    @ned-deily
    Member

    OK, now I finally get it, thanks, my fault. Yes, we probably shouldn't be passing stack_size through to applications trying to embed Python in LINkFORSHARED and pyconfig. That's an area that we don't test very well nor have tests for, AFAIK. Would it possible for you to provide a simple example of building libxml2 that would allow us to more easily test this?

    https://docs.python.org/3/extending/embedding.html#compiling-and-linking-under-unix-like-systems

  8. changed the title [-]python-config bad ldflags on macOS[/-] [+]macOS builds expose stack_size option in LINKEDFOORSHARED and pyconfig[/+] on Oct 11, 2018
  9. xzcvczx commented on Oct 11, 2018

    xzcvczxmannequin
    MannequinAuthor

    oh the rabbit hole...

    as i have other builds of python3.7 on my system i wanted to ensure it used the correct python and python-config (python 3.7 was built and installed into $HOME/Projects/python/inst/) as such its a rather convoluted configure command for libxml2

    LDFLAGS="-L$HOME/Projects/python/inst/lib" PATH=/Users/simon/Projects/python/inst/bin/:$PATH ./configure --prefix=/Users/simon/Projects/python/inst/ --with-python=/Users/simon/Projects/python/inst/bin/python3 --with-python-install-dir=/Users/simon/Projects/python/inst/lib/python3.7/site-packages

    the LDFLAGS envvar was required as python-config --ldflags also does not provide -L for the python libary

    $make
    ld: library not found for -lpython3.7m

    in config.log for libxml2 (PYTHON_LIBS which is the output of $HOME/Projects/python/python3-config --ldflags)
    PYTHON_LIBS='-lpython3.7m -ldl -framework CoreFoundation -Wl,-stack_size,1000000 -framework CoreFoundation'

    after LDFLAGS="..." is added

    $make
    ...
    CCLD libxml2mod.la
    ld: -stack_size option can only be used when linking a main executable
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    if you want more log lines please let me know but those should be the only relevant ones

  10. transferred this issue fromon Apr 10, 2022
  11. ronaldoussoren commented on Dec 7, 2023

    @ronaldoussoren
    Contributor

    This issue appears to be out of date: python3.x-config --ldflags and python3.x-config --ldflags --embed no longer include -stack_size.

    The LINKFORSHARED configvar does include that option, but that's correct as the variable is meant to be used for linking the python executable.

    I intent to close this issue.

  12. added
    pending
    on Dec 7, 2023
  13. removed
    pending
    on Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)3.8 (EOL)OS-mactype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions