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

-std=c++11 breaks clang builds #78

Closed
jobovy opened this issue Jun 3, 2022 · 10 comments
Closed

-std=c++11 breaks clang builds #78

jobovy opened this issue Jun 3, 2022 · 10 comments

Comments

@jobovy
Copy link
Contributor

jobovy commented Jun 3, 2022

The fix from #75 breaks the build process on Macs with clang (the default compiler), because clang doesn't allow the -std=c++11 flag when compiling C code. So ideally, you'd only want to have this flag on for the *.cpp files, but not for the *.c files. However, this seems quite difficult to do, as distutils tries hard to use the same flags for all files. The easiest solution might just be to make this an optional flag that can be turned off or detecting that this flag doesn't work and turning it off automatically. Note that the current way of checking the compiler flags doesn't detect this issue, because it compiles a C++ file and for that the flag is fine. You could do the check with a C file, but I'm not sure that that doesn't lead to other issues.

@beckermr
Copy link
Contributor

beckermr commented Jan 8, 2023

See this diff for a potential fix:

--- setup.py.orig	2023-01-08 06:55:28
+++ setup.py	2023-01-08 06:55:49
@@ -123,7 +123,8 @@
     cflags = extra_compile_args
     lflags = extra_link_args
 
-    cflags += ["-std=c++11"]
+    if platform.system() != "Darwin":
+        cflags += ["-std=c++11"]
 
     if platform.system() == "Darwin":
         # Usually Macs need this, but they might not, so try it, and only add

@jobovy
Copy link
Contributor Author

jobovy commented Jan 8, 2023

I don’t think this will work, because you need the -std=c++11 flag with clang too, just only for the C compiler.

@jobovy
Copy link
Contributor Author

jobovy commented Jan 8, 2023

Or maybe you don't need the flag currently, although eventually you might need it. It's been a while since I opened this issue and haven't checked recently.

@beckermr
Copy link
Contributor

beckermr commented Jan 8, 2023

The builds on conda-forge worked just fine.

@beckermr
Copy link
Contributor

beckermr commented Jan 8, 2023

the default in clang is past c++11 now

@jobovy
Copy link
Contributor Author

jobovy commented Jan 9, 2023

the default in clang is past c++11 now

Yes, it does seem to work to just not set the -std flag with clang, I can't really figure out why, because as you say, the default standard in clang is beyond c+11 now.

Checking if platform.system() != "Darwin": might not be the best way, because if somebody is using gcc 11 on a Mac, they would probably need the -std=c++11 flag? A better option might be to check whether the compiler supports the flag and if not, drop it (using similar code as is in the setup.py file already).

@MacDaddy1660B
Copy link

Confirmed: commenting line #cflags += ["-std=c++11"] on Darwin systems results in a successful build.

@esheldon
Copy link
Owner

esheldon commented Aug 2, 2023

I'm happy to take a PR on this

@esheldon
Copy link
Owner

where are we on this?

@jobovy
Copy link
Contributor Author

jobovy commented Aug 22, 2023

I can take a look and see whether I can fix this quickly. Still having the issue locally...

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

No branches or pull requests

4 participants