pyobjc icon indicating copy to clipboard operation
pyobjc copied to clipboard

Cannot build `pyobjc-core` with Xcode 13.3

Open maxbelanger opened this issue 3 years ago • 2 comments

We've been field testing the upcoming Xcode 13.3, and we're seeing a build error due to a new warning (unused-but-set-variable). In addition, the way that setup.py is set up, setting the CFLAGS environment variable (which is how we integrate building Python extensions with our build system) does not allow us to silence this warning.

Example:

>> CFLAGS="-Wno-error=unused-but-set-variable" python3 setup.py build
running build
running build_py
Overriding build_packages to copy PyObjCTest
package init file 'Lib/PyObjCTools/__init__.py' not found (or not a regular file)
running build_ext
building 'objc._objc' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wno-error=unused-but-set-variable -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/tcl-tk/include -I/opt/homebrew/Cellar/[email protected]/3.8.12_1/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c Modules/objc/objc-object.m -o build/temp.macosx-12-arm64-3.8/Modules/objc/objc-object.o -g -fexceptions -fno-objc-arc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wformat=2 -W -Wpointer-arith -Wmissing-declarations -Wnested-externs -W -Wno-import -Wno-unknown-pragmas -Wshorten-64-to-32 -Werror -I/usr/include/ffi -fvisibility=hidden -g -O3 -flto -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -DPyObjC_BUILD_RELEASE=1203
Modules/objc/objc-object.m:339:16: error: variable 'res' set but not used [-Werror,-Wunused-but-set-variable]
    PyObject*  res;
               ^
Modules/objc/objc-object.m:424:16: error: variable 'res' set but not used [-Werror,-Wunused-but-set-variable]
    PyObject*  res;
               ^
2 errors generated.
error: command 'clang' failed with exit status 1

maxbelanger avatar Feb 14 '22 19:02 maxbelanger

Sigh, I guess I'll have to bite the bullet and tweak setup.py to not use -Werror by default.

Adding a "--warnings-are-errors" option to "python setup.py build_ext" is easy enough, but actually using that option in my testing scripts is harder than I'd like. That's caused by using "pip install" to install the to be tested packages.

  • [x] Add --warnings-are-errors to setup.py/pyobjc_setup.py
  • [x] Use this option in the Makefile in pyobjc-core
  • [ ] Use this option in the script in development-support

The last item is the hardest:

  • run-testsuite and _install_tool.py use "pip install" to install packages, and that doesn't allow passing options to build_ext
  • adding a custom install command doesn't work either, a subclass of install.install with user_options causes an exception in setuptools :-(

I'll probably fall back to a magic environment variable for this.

ronaldoussoren avatar Feb 15 '22 16:02 ronaldoussoren

The build problems should be fixed in PyObjC 8.3, which I've just tagged and uploaded to PyPI.

I'm leaving this issue open to find a solution to enabling "-Werror" during development, but not in releases.

ronaldoussoren avatar Feb 24 '22 08:02 ronaldoussoren