-
Notifications
You must be signed in to change notification settings - Fork 986
Remove log_str()
functions and convert their log_signal()
users t…
#5211
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
Conversation
ddda340
to
ec3f384
Compare
@widlarizer would you mind taking a look at this? @rocallahan is with us. |
My idea around this is that we have a couple things to juggle at once. The core idea is that we don't want to ever touch anything like the weird caches/buffers, but we also have external plugin developers whose code we'd be breaking if we break the interface. @jix thoughts? |
I'm all for getting rid of raw I'd also be in favor of ditching printf style formatting entirely, using e.g. https://fmt.dev instead (or any other alternative that doesn't require much boilerplate when constructing log messages and supports formatting arbitrary types). This would mean all Yosys types could be used directly as format arguments with no need to manually convert them to strings. I don't think fixing the space leaks should be blocked on us deciding what exactly we're going to do here, so we should merge some form of this PR now. For that, I mostly agree with what @widlarizer wrote, i.e. I'd want to avoid a sudden breaking change without a deprecation period and I'd want to avoid having some What I wouldn't do right now, though, is deprecate the |
Yeah, I thought about this approach and mentioned it here:
produces no warnings; instead you get an exception at runtime. That would be a regression from the current situation where those strings are checked at compile time using the compiler's "printf format" attribute. (And I expect fixing that within the constraints of C++17 would be very hard... otherwise |
@rocallahan In C++20 fmt::printf does check the arguments so all you have to do is build Yosys in C++20 mode as another CI pass to get the compile time checks. That prevents users from having to actually upgrade to c++20 while keeping the codebase clean. That's what I did in OpenROAD to solve this problem. |
Are you sure about that? Because I'm not seeing it. (clang 20, fmt 11.1)
|
But it's a good idea anyhow... whether or not One question: would you want '%s' applied to a
The most critical leak is in |
I think you've used the wrong format specifier should be Ah I guess maybe I'm wrong it looks like the compile time checks only work on fmt::format and fmt::print not the printf function. |
See PR #5217. |
I hadn't considered using fmt for printf style formatting but was talking about migrating to its native formatting. If there's an easy way to use fmt to make the existing printf style formatting support There might be the occasional call that doesn't pass the output directly to a formatting function, so it would still be a breaking change to change the return types of Even if we can make the printf style formatting work with |
I don't know about "easy" but I've been working on this and I'm pretty sure it's possible. As @QuantamHD suggested, the static checking would only happen when compiling with Migrating all printf-style formatting to fmt-style formatting would be a huge change. I think it would be good to get rid of |
While we could go with this approach, what I gather is that we would be risking plugin breakage for an interim solution, right? I think we should save our firepower for internally converting to fmtlib (printf-style first) and marking current formatting functions deprecated. That seems like the most efficient way of going at this |
I'm not exactly sure what you mean by "current formatting functions" here. If you mean "deprecate I think the most important thing is to merge PR #5243 so that In this PR I would deprecate |
I meant a soft deprecation where we keep |
Ok. I think you should take PR #5243 because it provides most of the benefits of fmtlib immediately and without churn. |
@rocallahan, with your logging PRs merged (#5304 #5243), we should now be in a position where we can change the It shouldn't require any changes for the vast majority of uses as argument for logging or string formatting. Any use that already converted the This PR does need to be updated, though, since it still introduces (now unnecessary) calls to |
…o return `std::string` This is a small but easy step towards removing the `log_id_cache`. See issue YosysHQ#5210.
ec3f384
to
c7017f7
Compare
Right. Updated as requested. I'll fix the rest in another PR. |
…o return
std::string
What are the reasons/motivation for this change?
This is a small but easy step towards removing the
log_id_cache
. See issue #5210.Explain how this is achieved.
Use
std::string
instead ofchar*
to simplify lifetime issues.