-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Making mono_inst_name less misleading #83570
Making mono_inst_name less misleading #83570
Conversation
@dotnet-policy-service agree |
Do I have to add |
src/mono/mono/mini/helpers.c
Outdated
#else | ||
g_error ("unknown opcode name for %d", op); | ||
g_assert_not_reached (); | ||
#endif | ||
} | ||
#endif |
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.
This whole #else
part can be removed
src/mono/mono/mini/mini.h
Outdated
#define mono_inst_name(op) _static_assert_disabled_logging(op) | ||
void _static_assert_disabled_logging(int op) __attribute__((error("mono_inst_name is not available when DISABLE_LOGGING is defined."))); | ||
#endif |
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.
This is an interesting idea. We don't only compile with gcc and clang, so we need to make some macros to make it workable. Also it's better to use __attribute__((unavailable))
when the compiler supports it, because then optimizations that remove a call won't remove the warning.
I did an example on godbolt that seems to work even with old versions of gcc and clang.
Add this to src/mono/mono/utils/mono-compiler.h
#if defined(__clang__)
#define MONO_FUNCTION_UNAVAILABLE(msg) __attribute__((unavailable(msg)))
#elif (__GNUC__ == 12 && __GNUC_MINOR__ >= 1)
#define MONO_FUNCTION_UNAVAILABLE(msg) __attribute__((unavailable(msg)))
#elif (__GNUC__ > 4) || (__GNUC__ >=4 && __GNUC_MINOR__ >= 4)
/* this might not warn if optimization removes a call, but it's better than nothing.
* disable inlining to encourage GCC not to eliminate the call
*/
#define MONO_FUNCTION_UNAVAILABLE(msg) __attribute__((noinline,error(msg)))
#else
#define MONO_FUNCTION_UNAVAILABLE(msg) /* empty */
#endif
And then do this in this header (the implementation in helpers.c
should be entirely within the #ifdef
with no #else
part):
#ifndef DISABLE_LOGGING
const char* mono_inst_name (int op);
#else
MONO_FUNCTION_UNAVAILABLE("mono_inst_name is not available when DISABLE_LOGGING is defined") const char *mono_inst_name (int op);
#endif
Yes, you'll need to update very place that calls |
I could not figure out why some test cases are failing. Besides src/mono/mono/mini/cfgdump.c I have enclosed with #ifndef DISABLE_LOGGING in every places where mono_inst_name is being used. I did not do so in cfdump.c because it was already checking if DISABLE_LOGGING is enabled in the start of the code. Is that the case why some test cases are failing? |
@sayeedkhannabil - please resolve conflict. That will trigger a new CI run. We can help you investigate the failures once we have a newer CI check run. |
@sayeedkhannabil is there anyway I could help you move forward with this PR? |
Hi. I am struggling with the CI/CD errors. Since I do not have any experience in that. If someone can help me figure out, how to work around with the CI/CD error, or give me some pointers how I can test this locally in my machine, that would be helpful for me. Thanks |
Sure, I will gladly help you out with that.
|
@sayeedkhannabil - if the PR isn't ready, consider marking as Draft PR. |
8d5e249
to
96c2e1d
Compare
Sorry for the late reply and delay on the submission. I got overwhelmed by
the large codebase and it took me a while to figure out how to run tests on
my local machine.
I have submitted a new pr, which passed all of the CI/CD. Please review it
when you have the time. Again, sorry it took such a long time.
Thanks,
Abu Sayeed Khan
…On Tue, Aug 22, 2023 at 9:40 AM Sam Patel ***@***.***> wrote:
@sayeedkhannabil <https://github.com/sayeedkhannabil> - if the PR isn't
ready, consider marking as Draft PR.
—
Reply to this email directly, view it on GitHub
<#83570 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG576V5WUGW4VE5HEOJ3L63XWTAFTANCNFSM6AAAAAAV6DQZCE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Wraping both declaration and definition in #ifndef DISABLE_LOGGING.
Fix #83545