-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Configure option --with-cxx-main=/usr/bin/clang++ not working #93744
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
Comments
If you do |
This is a bug: explain why its not! I have raised a question on discourse and it was not answered! I am not complaining about |
I can reproduce the problem and confirm that it's a bug in our configure script.
|
Please remain calm and use a polite tone.
25 minutes ago. There is no guarenteed response time; we are all volunteers, trying to improve CPython in our free time. Once again, please use a polite tone. |
The discuss report 1 you linked has been answered by a core dev and the author claimed that by syncing with 3.12 it works and then you are saying that it has not been answered. Please remain calm so that our autoconf experts will take a look. Thanks Footnotes |
GCC's C++ compiler just warns about
|
AFAICS, no C++ is mentioned in PEP 11. However, @vstinner has recently pushed some changes to make the code base friendlier to C++ compilers. |
AFAIK Victor's work is on public headers, not Python itself. While you can use the C-API with C++, Python itself is written in C. Supporting ./configure with C++ seems rather pointless to me, is there a use case where you can't use the C compiler? |
Yes, correct. That's a related issue, but not directly relevant for this issue. |
See also the docs for the |
|
Here's my 2 cents: PEP 11 does not say anything about C++ compilers. The current option is broken with |
I guess the use case might have been ensuring that we can use a C++ compiler/linker with libpython? Anyway, if we do drop it, 3.12a0 is the perfect time. |
I never used it. I don't see the point of building the whole Python in C... but only the main() function with C++. Nowadays, most Linux distributions distribute a shared libpython library, so it's trivial to build your own main() function implemented in C++ which calls Py_BytesMain(). Each time I tried I suggest to remove this configure option. |
It would be nice to update PEP 11 to require the Python C API to be usable in C++, at least with C++11. Since Python 3.11, compatibility with C++11 is now tested. I recently added a test on C++03. |
On Fedora 36, I failed to build Python 3.10 with So I don't think that this issue is about fixing Python. It's like a "new feature". IMO Examples of g++ errors: Include/internal/pycore_atomic.h is incompatible C++:
putenv() error:
Many errors related to Py_BUILD_ASSERT_EXPR() used by Py_ARRAY_LENGTH():
|
I guess we could remove it under this ticket. Let's go 🚀 |
I wrote a large PR removing more than just |
Remove the "configure --with-cxx-main" build option: it didn't work for many years. Remove the MAINCC variable from configure and Makefile. The MAINCC variable was added by the issue gh-42471: commit 0f48d98. Previously, --with-cxx-main was named --with-cxx. Keep CXX and LDCXXSHARED variables, even if they are no longer used by Python build system.
Fixed by 398ed84 which removes the configure option. It's easy to embed Python in a C++ application: https://docs.python.org/dev/extending/embedding.html |
Thanks for the fix, Victor 😃 Closing this as fixed 🚀 |
Remove the "configure --with-cxx-main" build option: it didn't work for many years. Remove the MAINCC variable from configure and Makefile. The MAINCC variable was added by the issue pythongh-42471: commit 0f48d98. Previously, --with-cxx-main was named --with-cxx. Keep CXX and LDCXXSHARED variables, even if they are no longer used by Python build system.
Configure option --with-cxx-main=/usr/bin/clang++ not working
My environment
Latest 3.12.0.a0 tried on other but CC=/usr/bin/clang not working on those, so pointless to try
fedora 5.17.13-300.fc36.x86_64
Configure options
--with-cxx-main=/usr/bin/clang++ CC=/usr/bin/clang
runs and gives at end:
configure: creating Modules/Setup.local
configure: creating Makefile
configure:
Then:
make
/usr/bin/clang++ -c -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
clang-14: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
error: invalid argument '-std=c11' not allowed with 'C++'
make: *** [Makefile:1373: Programs/python.o] Error 1
See Discuss report
Tried configure with --with-cxx-main=/usr/bin/g++ CC=/usr/bin/gcc
then
make
cc1plus: warning: ‘-Werror=’ argument ‘-Werror=implicit-function-declaration’ is not valid for C++
cc1plus: warning: command-line option ‘-std=c11’ is valid for C/ObjC but not for C++
Shows source files being compiled and linked and actually builds python executable, so this works.
The text was updated successfully, but these errors were encountered: