After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 773803 - Fails to build on Mac OS due to -stack_size linker option
Fails to build on Mac OS due to -stack_size linker option
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
Git master
Other Mac OS
: Normal major
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 774453
 
 
Reported: 2016-11-02 05:36 UTC by Philip Chimento
Modified: 2017-05-22 04:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
build: Don't use extra Python ldflags in shared lib (2.19 KB, patch)
2016-11-02 05:37 UTC, Philip Chimento
none Details | Review
testhelper: only link against libpython on Windows (1.47 KB, patch)
2017-03-23 21:43 UTC, Christoph Reiter (lazka)
none Details | Review

Description Philip Chimento 2016-11-02 05:36:41 UTC
Building pygobject on Mac OS (10.12.1) from JHBuild fails:

       GEN      testhelper.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)

The -Wl,-stack_size,1000000 comes from "python3-config --ldflags" which is called by AM_CHECK_PYTHON_LIBS in configure.ac. I am pretty sure that when building a shared library like testhelper the output of "python3-config --libs" should be used instead. Here is a patch that completes the build for me.
Comment 1 Philip Chimento 2016-11-02 05:37:01 UTC
Created attachment 338927 [details] [review]
build: Don't use extra Python ldflags in shared lib

`python3-config --ldflags` includes a "-Wl,-stack_size,1000000" flag
on Mac OS 10.12.1 which should not be passed to the linker when building
a shared library like testhelper. Instead use `python3-config --libs`.

The configure.ac code is adapted from the source of AM_CHECK_PYTHON_LIBS.
Comment 2 Christoph Reiter (lazka) 2017-03-23 21:43:51 UTC
Created attachment 348609 [details] [review]
testhelper: only link against libpython on Windows

Thanks. Looks like we don't need to link against libpython at all, except on Windows. Does removing "-no-undefined $(PYTHON_LIBS)" help?

(The patch here is against master, which will not apply cleanly on previous releases)
Comment 3 Christoph Reiter (lazka) 2017-03-23 21:49:01 UTC
Based on http://blog.tim-smith.us/2015/09/python-extension-modules-os-x/ we should also use "-undefined dynamic_lookup" on OSX.
Comment 4 Christoph Reiter (lazka) 2017-03-23 23:09:35 UTC
Turns out this is what autotools does anyway if one uses "-module".
Pushed to master (with some related cleanup in configure.ac)

https://git.gnome.org/browse/pygobject/commit/?id=b0476e2db4577e12b52caa3163ccb69575221d6c

Thanks!
Comment 5 Philip Chimento 2017-05-21 18:44:27 UTC
I finally got around to rebuilding the world and testing this, but I still need my original patch, at least on gnome-3-24. Otherwise, without linking to libpython, testhelper can't find any Python symbols:

  GEN      testhelper.la
Undefined symbols for architecture x86_64:
  "_PyArg_ParseTuple", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
      __wrap_connectcallbacks in testhelper_la-testhelpermodule.o
      __wrap_test_value in testhelper_la-testhelpermodule.o
      __wrap_test_value_array in testhelper_la-testhelpermodule.o
      __wrap_test_gerror_exception in testhelper_la-testhelpermodule.o
  "_PyArg_ParseTupleAndKeywords", referenced from:
      __wrap_test_interface_iface_method in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__do_iface_method in testhelper_la-testhelpermodule.o
  "_PyCFunction_Type", referenced from:
      ___TestInterface__interface_init in testhelper_la-testhelpermodule.o
  "_PyCapsule_GetPointer", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_PyCapsule_Type", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_PyErr_Clear", referenced from:
      ___TestInterface__interface_init in testhelper_la-testhelpermodule.o
  "_PyErr_Fetch", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_PyErr_Format", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_PyErr_Occurred", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyErr_Print", referenced from:
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyErr_SetObject", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_PyErr_SetString", referenced from:
      _pyglib_testhelper_module_create in testhelper_la-testhelpermodule.o
      _pygobject_init in testhelper_la-testhelpermodule.o
      __wrap_test_value in testhelper_la-testhelpermodule.o
      __wrap_test_value_array in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__do_iface_method in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyExc_ImportError", referenced from:
      _pyglib_testhelper_module_create in testhelper_la-testhelpermodule.o
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_PyExc_NotImplementedError", referenced from:
      __wrap_TestInterface__do_iface_method in testhelper_la-testhelpermodule.o
  "_PyExc_TypeError", referenced from:
      __wrap_test_value in testhelper_la-testhelpermodule.o
      __wrap_test_value_array in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyGILState_Ensure", referenced from:
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyGILState_Release", referenced from:
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyImport_ImportModule", referenced from:
      _pyglib_testhelper_module_create in testhelper_la-testhelpermodule.o
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_PyList_Append", referenced from:
      __wrap_test_owned_by_library_get_instance_list in testhelper_la-testhelpermodule.o
      __wrap_test_floating_and_sunk_get_instance_list in testhelper_la-testhelpermodule.o
  "_PyList_New", referenced from:
      __wrap_test_owned_by_library_get_instance_list in testhelper_la-testhelpermodule.o
      __wrap_test_floating_and_sunk_get_instance_list in testhelper_la-testhelpermodule.o
  "_PyLong_FromLong", referenced from:
      __wrap_test_g_object_new in testhelper_la-testhelpermodule.o
  "_PyModule_Create2", referenced from:
      _pyglib_testhelper_module_create in testhelper_la-testhelpermodule.o
  "_PyModule_GetDict", referenced from:
      _pyglib_testhelper_module_create in testhelper_la-testhelpermodule.o
  "_PyObject_CallObject", referenced from:
      __wrap_test_gerror_exception in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyObject_GetAttrString", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
      ___TestInterface__interface_init in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyObject_Repr", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_PyTuple_New", referenced from:
      __wrap_test_gerror_exception in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
  "_PyType_IsSubtype", referenced from:
      ___TestInterface__interface_init in testhelper_la-testhelpermodule.o
  "_PyUnicode_FromFormat", referenced from:
      _pygobject_init in testhelper_la-testhelpermodule.o
  "_Py_BuildValue", referenced from:
      _pyglib_testhelper_module_create in testhelper_la-testhelpermodule.o
  "__Py_NoneStruct", referenced from:
      __wrap_connectcallbacks in testhelper_la-testhelpermodule.o
      __wrap_test_gerror_exception in testhelper_la-testhelpermodule.o
      __wrap_test_interface_iface_method in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__do_iface_method in testhelper_la-testhelpermodule.o
      __wrap_TestInterface__proxy_do_iface_method in testhelper_la-testhelpermodule.o
      __wrap_test_owned_by_library_release in testhelper_la-testhelpermodule.o
      __wrap_test_floating_and_sunk_release in testhelper_la-testhelpermodule.o
      ...
ld: symbol(s) not found for architecture x86_64
Comment 6 Christoph Reiter (lazka) 2017-05-22 04:22:32 UTC
These fixes are only in master/3.25.1
Comment 7 Philip Chimento 2017-05-22 04:26:39 UTC
Doh! Sorry for the noise