Opened 3 years ago

Closed 3 years ago

#17566 closed bug (no change required)

compiling sbcl fails to compile on nightlies after ~hrev55650

Reported by: hoanga Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System Version: R1/beta3
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

sometime between (but not including) hrev55602 and hrev55640 one of the changes was introduced that won't allow sbcl to bootstrap compile itself successfully anymore. i checked with an older version (hrev55602) that i was able to revive and confirmed that sbcl was able to bootstrap compile on this revision. the cause of the compilation failure appears to be a set of c extensions that are compiled as part of the sbcl bootstrap.

after some comparisons of the changes in the versions, i believe the change that is associated with sbcl no longer able to compile is when the version of gcc was updated from 8 to 11. i have also tested with the most recent nightly (hrev55845) and this problem still appears to be present.

Attachments (1)

foo.c (117.2 KB ) - added by hoanga 3 years ago.
Example C file that cannot compile on more recent nightlies

Download all attachments as: .zip

Change History (5)

by hoanga, 3 years ago

Attachment: foo.c added

Example C file that cannot compile on more recent nightlies

comment:1 by hoanga, 3 years ago

after some investigation into the bootstrap compilation process, i was able to find an example C file that is part of the bootstrap process (might be auto-generated) that no longer compiles after the update to gcc 11.2.0. below is an example of it compiling on an earlier nightlies of haiku (pre gcc11.2.0)

~> uname -a
Haiku shredder 1 hrev55602 Oct 29 2021 07:10:38 x86_64 x86_64 Haiku
~> gcc -c foo.c
~>

below is an example showing the same file unable to compile on more recent versions of nightlies

~> uname -a
Haiku shredder 1 hrev55845 Feb  5 2022 07:44:37 x86_64 x86_64 Haiku

~> gcc -c foo.c 
foo.c: In function 'main':
foo.c:1387:48: error: invalid application of 'sizeof' to incomplete type 'char[]'
 1387 |     fprintf(out, "  %ld)\n", CAST_SIGNED(sizeof(t.d_name)));
      |                                                ^
foo.c:27:33: note: in definition of macro 'CAST_SIGNED'
   27 | #define CAST_SIGNED(x) ((sizeof(x) == 4)? (long) (int) (x): (x))
      |                                 ^
foo.c:1387:48: error: invalid application of 'sizeof' to incomplete type 'char[]'
 1387 |     fprintf(out, "  %ld)\n", CAST_SIGNED(sizeof(t.d_name)));
      |                                                ^
foo.c:27:57: note: in definition of macro 'CAST_SIGNED'
   27 | #define CAST_SIGNED(x) ((sizeof(x) == 4)? (long) (int) (x): (x))
      |                                                         ^
foo.c:1387:48: error: invalid application of 'sizeof' to incomplete type 'char[]'
 1387 |     fprintf(out, "  %ld)\n", CAST_SIGNED(sizeof(t.d_name)));
      |                                                ^
foo.c:27:62: note: in definition of macro 'CAST_SIGNED'
   27 | #define CAST_SIGNED(x) ((sizeof(x) == 4)? (long) (int) (x): (x))
      |                                                              ^

comment:2 by waddlesplash, 3 years ago

{ struct dirent t;
	    fprintf(out, "  %ld)\n", CAST_SIGNED(sizeof(t.d_name)));
	}

Our d_name is a flexible-length array now (or, well, it always has been, but now is properly declared as such.) GCC seems to treat these, or at least GCC 11 does, as things which have no size, so it errors on sizeof() of them.

The correct and portable thing to do here, to get the length of d_name (before any FLA additions) is:

sizeof(struct dirent) - offsetof(struct dirent, d_name)

comment:3 by hoanga, 3 years ago

after a bit of experimentation i have been able to work around this issue in the sbcl port. there are some patches that should eventually make its way to upstream, i will try to incorporate a more proper patch for upstream that also handles the haiku case.

i think that this ticket can be closed for the time being. thanks!

comment:4 by waddlesplash, 3 years ago

Resolution: no change required
Status: newclosed

Thanks for the feedback!

Note: See TracTickets for help on using tickets.