Skip to content

Commit 44527ad

Browse files
agattidpgeorge
authored andcommitted
unix/main: Fix GCC builds for RISC-V 64 bits.
This contains a workaround to silence a possibly incorrect warning when building the Unix port with GCC targeting RISC-V 64 bits. Fixes issue micropython#12838. Signed-off-by: Alessandro Gatti <[email protected]>
1 parent 594c422 commit 44527ad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ports/unix/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,12 @@ MP_NOINLINE int main_(int argc, char **argv) {
562562
// First entry is empty. We've already added an empty entry to sys.path, so skip it.
563563
++path;
564564
}
565-
bool path_remaining = *path;
565+
// GCC targeting RISC-V 64 reports a warning about `path_remaining` being clobbered by
566+
// either setjmp or vfork if that variable it is allocated on the stack. This may
567+
// probably be a compiler error as it occurs on a few recent GCC releases (up to 14.1.0)
568+
// but LLVM doesn't report any warnings.
569+
static bool path_remaining;
570+
path_remaining = *path;
566571
while (path_remaining) {
567572
char *path_entry_end = strchr(path, PATHLIST_SEP_CHAR);
568573
if (path_entry_end == NULL) {

0 commit comments

Comments
 (0)