-
Notifications
You must be signed in to change notification settings - Fork 544
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
Fix 'experimental/coroutine' file not found on macOS (#5030) #5031
base: master
Are you sure you want to change the base?
Conversation
#_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++20) | ||
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only require C++20, there's a later test for what's needed for coroutines - so should be added there presumably,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason c++20 std is not enabled by default? If there is, this check can go under AC_MSG_CHECKING([whether coroutines are supported by $CXX])
I guess?
If not this shouldn't cause any problems with older stdlibs/compilers as far as I can tell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still want older compilers to work, and because choosing a std that does not match glibc often makes compiling break. Ideally you wouldn't need that flag to use coroutines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since they moved it from experimental/coroutine to coroutine without enabling c++20 std does not include coroutines. If we switch to c++17 we need "experimental/coroutine" but updated versions of the compiler does not have that.
So I don't see a simple way to make it work with both new and old compilers without enabling c++20. If there is any check I can make before enabling it (if we are going to enable it) let me know, I am not familiar with autoconf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try instead adding this to the later section
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_COROUTINES,-std=c++20)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added that to coroutine checks, enables c++20 with clang 17.0.6. Tested with multiple modules, seems like it's working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above we cannot change NEWEST, please try the other flag suggested. Also would really like a config fest instead of looking for a magic clang version which is likely fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above we cannot change NEWEST, please try the other flag suggested. Also would really like a config fest instead of looking for a magic clang version which is likely fragile.
We tried _MY_CXX_CHECK_SET(CFG_CXXFLAGS_COROUTINES,-std=c++20)
, caused some gcc tests to fail. What should we test to enable c++20?
b6026d6
to
c1b2918
Compare
Tests failing. Maybe we should have a configure check instead to try both includes. |
Bump on this -- encountering this issue as well, would be great to have this merged! Thanks all :) |
This reverts commit 093d0d5.
In the meantime I added the fork to my homebrew tap and reverted the commit that breaks gcc tests. You can use |
I encounter the same problem with clang 17 on Arch Linux. Thanks for your patch now it can compile, but it gives another warning.
It looks like recent clang does not like this pragma. May you consider remove it? |
@selimsandal (or other) could you please update the patch to use configure.ac to properly discover the include and flags? Then we should be solid for all versions. |
Is this good to merge? |
Not ready, see review comments and please update the patch to use configure.ac to properly discover the include and flags? Then we should be solid for all versions. |
Not sure if you saw my message since it was posted to a closed issue. Reposting here. wsynder: Note #5031 still needs changes to check using configure.ac (see the ticket), perhaps you can help that. mxg: I'm happy to help, but I need to figure out what you expect. The PR has code in configure.ac to check for and changes in verilated_timing.h. I'm not an autoconf expert, but if you could help me with what you're looking for, I can do the heavy lifting. |
Thanks for looking into this. Here's some existing code in configure.ac that compiles a program to see if it works: Line 361 in 19cccd1
You'd want to try the non-experimental, then if fails try the experimental and set a define as to which is found, e.g. set HAVE_COROUTINES in addition to HAVE_EXPERIMENTAL_COROUTINES, then in the verilated/ include files do an #ifdef on HAVE_EXPERIMENTAL_COROUTINES to pull in the appropriate include. |
I'm also having this issue:
|
Still waiting on a pull that uses configure.ac. |
I also encountered a homebrew (?) error while trying to use the tap (
|
@ethanuppal I didn't change the formula but I think it started failing this week after a brew update. I tried removing unnecessary fields from the formula and reverting the fork to a working version I tried before, but those didn't help. About your laptop getting hot, I hardcoded the formula to use all cores instead of homebrew's env vars, no need to worry it'll throttle itself if necessary. Even if Homebrew shows that error it installs verilator as far as I can tell, I'll update you if I find a fix. P.S: For everyone looking for a temporary fix |
Forgive me if this is inappropriate but could I suggest that instead of making the choice of include file dependent on the compiler version, # ifdef __has_include
# if __has_include(<coroutine>)
# include <coroutine>
# elif __has_include(<experimental/coroutine>)
# include <experimental/coroutine>
namespace std {
using namespace experimental; // Bring std::experimental into the std namespace
}
# endif
# endif This has the advantage that we’re checking the standard library headers directly rather than inferring it from the compiler version. C++20 is still required by <coroutine>, of course. |
That's a good idea. Will also need the #else for when no has_include. Can you create a pull with that? |
Dear Selim, this reply might not add much but I came across exactly this issue when trying to build the verilator simulation executable for the chipyard RocketConfig Default Example, see: https://chipyard.readthedocs.io/en/1.11.0/Simulation/Software-RTL-Simulation.html#sw-rtl-sim-intro. The system I am running is Sonoma 14.5 with Apple clang version 15.0.0 (clang-1500.3.9.4) and Xcode version: 15.3.0.0.1.1708646388. These appear to be the latest stable updates at time of writing this post. After some dabbling, I managed to successfully compile the test executable after rebuilding verilator from master while commenting in: -#_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=gnu++20)
-#_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++20)
+_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=gnu++20)
+_MY_CXX_CHECK_SET(CFG_CXXFLAGS_STD_NEWEST,-std=c++20) in #include <vector>
+// Added by Frank Zeyda
+# undef _LIBCPP_VERSION
+
// clang-format off
// Some preprocessor magic to support both Clang and GCC coroutines with both libc++ and libstdc++
#if defined _LIBCPP_VERSION // libc++ in PS: It appears that a robust solution for this issue is still pending—I would be happy to test that once merged into master and greatly appreciate if this problem could be addressed sooner than later (for us MacOS users of verilator ;-). Thanks a lot! |
Enables stdc++20, includes coroutine as
include <coroutine>
if clang_major >= 15 || clang_major == 14 && clang_minor >= 0 && clang_patchlevel >= 6