GNOME Bugzilla – Bug 773803
Fails to build on Mac OS due to -stack_size linker option
Last modified: 2017-05-22 04:26:39 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.
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.
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)
Based on http://blog.tim-smith.us/2015/09/python-extension-modules-os-x/ we should also use "-undefined dynamic_lookup" on OSX.
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!
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
These fixes are only in master/3.25.1
Doh! Sorry for the noise