-
Notifications
You must be signed in to change notification settings - Fork 116
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
Apply patches when used in radare2 #569
Conversation
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.
Thank you! I left a couple of comments.
cutils.c
Outdated
@@ -1129,7 +1129,7 @@ void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque) | |||
|
|||
/*---- Portable time functions ----*/ | |||
|
|||
#if defined(_MSC_VER) | |||
#if defined(_MSC_VER) || __MINGW32__ |
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.
Why is this necessary? Is it to support the old mingw32 aka not mingw-w64?
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.
Probably yea, that's @trufae's commit, here:
radareorg/radare2@86529d7
and sheesh its failing all the mingw checks, idk why :/
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.
Mingw32 is really old and no longer maintained AFAIK, mingw-w64 (which also has a 32bit version, despite the name) has been the de facto MinGW for a while I think.
@trufae ?
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.
Can either of you confirm which version of MinGW you're using?
My fear is we'd break mingw32 support since we don't run tests on it.
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.
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.
That's mingw-w64 which we already support, I don't think those changes are necessary.
Any chance you can try to build radare without them?
quickjs.c
Outdated
@@ -34561,7 +34561,7 @@ static JSString *JS_ReadString(BCReaderState *s) | |||
} | |||
#ifdef DUMP_READ_OBJECT | |||
if (check_dump_flag(s->ctx->rt, DUMP_READ_OBJECT)) { | |||
bc_read_trace(s, ""); // hex dump and indentation | |||
bc_read_trace(s, "%s", ""); // hex dump and indentation |
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.
Ha, nice! Can you please remove the silencer flag I added to CMake then?
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.
sure
Done, maybe this time mingw-w64 will pass, I added a check for only mingw32, excluding w64 🙏 |
Btw, thanks a lot for being so responsive, it is really motivating! |
@@ -1710,6 +1710,11 @@ static int __bf_div(bf_t *r, const bf_t *a, const bf_t *b, limb_t prec, | |||
slimb_t d; | |||
|
|||
na = n + nb; | |||
|
|||
if (na >= (SIZE_MAX / sizeof(limb_t)) - 1) { |
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 fails on Windows, since IIRC the limb bits are fewer there.
D:/a/quickjs/quickjs/libbf.c:1714:16: error: comparison is always false due to limited range of data type [-Werror=type-limits]
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.
Huh, that's rough, will try to play with it more
cutils.c
Outdated
@@ -1129,7 +1129,7 @@ void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque) | |||
|
|||
/*---- Portable time functions ----*/ | |||
|
|||
#if defined(_MSC_VER) | |||
#if defined(_MSC_VER) || (__MINGW32__ && !defined(__MINGW64__)) |
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.
Come to think of it, we could use this everywhere on windows, perhaps that's a simpler thing, let's try it please.
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.
Yea I need to find a macro that distinguish mingw32 from Mingw-w64
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.
I was thinking on the opposite direction, as in, to use this implementation also in MinGW, if possible.
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.
Ooh, allright, I could try
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.
Btw can you plz give me any hint about the limb bits on windows?
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.
See
Line 34 in 1eb9608
#if INTPTR_MAX >= INT64_MAX && !defined(_WIN32) && !defined(__TINYC__) |
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.
Thanks a lot, I will try this today as well as your __MINGW32__
idea
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.
👍
Done, letme know if that's what you expected. Sorry for pushing it so late 😓 |
libbf.c
Outdated
@@ -1710,6 +1710,11 @@ static int __bf_div(bf_t *r, const bf_t *a, const bf_t *b, limb_t prec, | |||
slimb_t d; | |||
|
|||
na = n + nb; | |||
|
|||
if (na >= (SIZE_MAX / sizeof(limb_t)) - 1) && !defined(_WIN32) { |
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.
I think this check should be surrounded by some ifdef sizeof (limb_t) > sizeof(uint64_t) instead
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.
W8, I haven't closed the brackets here, that's why its all failing, sorry. I will fix it
cutils.c
Outdated
@@ -1129,7 +1129,7 @@ void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque) | |||
|
|||
/*---- Portable time functions ----*/ | |||
|
|||
#if defined(_MSC_VER) | |||
#if defined(_MSC_VER) || __MINGW32__ |
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.
Can either of you confirm which version of MinGW you're using?
My fear is we'd break mingw32 support since we don't run tests on it.
Chck now, sry for this obv mistake I've made |
Allright, some checks are still failing, I think that changing this comparison back to a simple |
I think so too! |
Ok, letsee how it goes ❗ |
Ah I thought you meant something else. I think what you want to check for then is if LIMB_LOG2_BITS is 6 or not. |
Oh, ok so I'd check for if Thanks for the quick review btw 😃 |
Another thing is that I should check if |
I'd rather see it gone. I think it's not necessary since both us and radars are using mingw-w64. |
Sounds good! |
OK done, hopefully nothing will break 🙏 |
Looks good! Let's see if the CI is green! |
Hmm, seems I have to put this limb thing inside |
Ok done, chck it now |
Squash - rebased them and landed! #582 |
Thanks for persevering! ❤️ |
I've made a PR that fixes all the issues we found in r2 as I said I would do in issue #559
Based on the following commits: