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

bpo-26317: Build Problem with GCC + Macintosh OS X 10.11 El Capitain #13306

Closed
wants to merge 10 commits into from

Conversation

websurfer5
Copy link
Contributor

@websurfer5 websurfer5 commented May 14, 2019

Add support to the configure script for OBJC and OBJCXX command line options so that the MacOSX builds can use the clang compiler for the MacOSX-specific Objective C source files. This allows the GNU compiler to be used to build the rest of the project since some of the Objective C system header files are not compilable by the GNU compiler.

Also, _scproxy.o is built outside of setup.py so that we can force the use of the OBJC compiler when the CC compiler is different. The Makefile builds _scproxy.o and the setup.py script takes care of using the object file to create the _scproxy module instead of compiling the file itself. This approach is taken because setup.py is designed to use a single compiler for everything. Adding support for a second alternative compiler would require re-plumbing distutils, which is complicated and unnecessary because setup.py allows module definitions to specify object files without any .c source files.

This fixes the PythonLauncher build when CC is set to the GNU C compiler. In this case, OBJC can be set explicitly to "clang", or it can be left out and the configure script will automatically discover the clang compiler as the Objective C compiler. For example, a system that used brew to install the GNU C compiler as gcc-8 can specify CC=gcc-8 and the configure script will discover and use the clang compiler as if OBJC=gcc had been specified on the command line. The same behavior applies to the OBJCXX and CXX options.

https://bugs.python.org/issue26317

websurfer5 added 2 commits May 12, 2019
command line options so that the MacOSX builds can use the clang
compiler for the MacOSX-specific Objective C source files. This allows
the GNU compiler to be used to build the rest of the project since some
of the Objective C system header files are not compilable with the GNU
compiler.
…e can force

the use of the OBJC compiler when the CC compiler is different. For
example, it allows _scproxy.c to be compiled using the clang compiler
while the rest of the project uses the GNU C compiler.
@tonybaloney
Copy link
Contributor

tonybaloney commented May 14, 2019

Requesting review from @ned-deily @terryjreedy

auvipy
auvipy approved these changes May 31, 2019
@ned-deily
Copy link
Member

ned-deily commented Jul 21, 2019

Thanks for the PR. It looks good in principle but I need to more thoroughly review and test in various configurations before accepting for 3.9. If not before, I will do so during the development sprint in early September.

@matrixise
Copy link
Member

matrixise commented Sep 13, 2019

@ned-deily ;-) small reminder ;-)

@terryjreedy
Copy link
Member

terryjreedy commented Sep 14, 2019

I believe configure is a generated file and needs to be regenerated again, as well as updating to current master.

@terryjreedy
Copy link
Member

terryjreedy commented Jan 13, 2020

The configure conflict was simple. Apparently, 'PROFILE_TASK' was added after this PR, which adds OBJ* lines in the same place (in 2 places in the file). My fix was to remove the conflict markers, leaving both new entries, with the OBJ* group first.

The What's New 3.8 fix was to remove the now incorrect new entry for this PR. Such entries should be added by the committer when the PR is otherwise ready to commit. If this is a bugfix, this should not get a What's New entry anyway. In any case, tests are running again.

Copy link
Member

@corona10 corona10 left a comment

@terryjreedy

LGTM with build issue.
But I got another issue with the gcc on mac.
This is out of the scope of this issue.

test test_gdb failed
2 tests failed again:
    test_cmath test_gdb

== Tests result: FAILURE then FAILURE ==

397 tests OK.

2 tests failed:
    test_cmath test_gdb

21 tests skipped:
    test_devpoll test_epoll test_idle test_ioctl test_msilib
    test_multiprocessing_fork test_ossaudiodev test_smtpnet test_spwd
    test_ssl test_startfile test_tcl test_tix test_tk test_ttk_guionly
    test_ttk_textonly test_turtle test_winconsoleio test_winreg
    test_winsound test_zipfile64

2 re-run tests:
    test_cmath test_gdb

@ned-deily
Copy link
Member

ned-deily commented Jan 15, 2020

@corona10

But I got another issue with the gcc on mac.
This is out of the scope of this issue.

You are right, it is out of scope :). And we would need more information to help with the various test failures and skips. If you want to pursue this, you should probably ask for help on the general Python list or elsewhere. But be aware that we do not normally test building Python with current GNU gcc releases on macOS and generally recommend that you use the latest Apple-supplied compilers from the most-up-to-date Command Line Tools or Xcode release for the version of macOS in use. If you don't really need GNU gcc for building Python, you should be able to override the compiler selection with something like:

./configure ... CC=clang

@ax3l
Copy link

ax3l commented Apr 22, 2020

Just a quick question, shouldn't _scproxy.c also be renamed to _scproxy.m? libuv just had the exact same error: libuv/libuv#2808

ax3l added a commit to ax3l/cpython that referenced this pull request Apr 22, 2020
This file includes an objective C header from macOS.

See python#13306
ax3l added a commit to ax3l/cpython that referenced this pull request Apr 23, 2020
This file includes an objective C header from macOS.

See python#13306
@ax3l
Copy link

ax3l commented Apr 23, 2020

@corona10 @ned-deily @terryjreedy just a gentle ping, do you think this can be merged?

Fixing this (silent) compile error with GCC on macOS would be wonderful. In the current state without the patch, an install of CPython will be generated but it will just not work, as the _scproxy module is missing.

@ned-deily
Copy link
Member

ned-deily commented Apr 23, 2020

Sorry about the delay. To be honest, we don't really support or test building on macOS with anything other than the latest Apple-provided developer tools for a particular macOS release. There are too many options that won't work and our testing resources are limited so this is a really low priority item. Despite that, I do plan to review, test, and decide on it prior to 3.9.0b1; it's nearing the top of my list :)

@ax3l
Copy link

ax3l commented Apr 23, 2020

@corona10
Copy link
Member

corona10 commented Apr 23, 2020

I can provide a short GitHub action script for CI that runs macOS+GCC on PRs

Please open the sperate issue for this if you want :)

@ned-deily
Copy link
Member

ned-deily commented Apr 23, 2020

No need. We already build some branches with gcc in the Travis CI. But thanks!

@ax3l
Copy link

ax3l commented Apr 23, 2020

@ax3l
Copy link

ax3l commented Apr 23, 2020

I checked the Travis-CI scripts and they run GCC on Linux. The exact corner case here is GCC on macOS consuming Objective-C files that are only enabled on Darwin platform builds (not covered yet) :)

Just in case, please see: #19681 free testing resources for macOS.

@ned-deily
Copy link
Member

ned-deily commented May 18, 2020

Thanks for all the work on this @websurfer5, the merge update @terryjreedy, and the reviews and comments! With the feature code cutoff for 3.9.0 approaching rapidly, I took the liberty of creating a new PR, #20176, based on this one to avoid any last-minute hangups. The code is unchanged but I did make a few wording changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants