cloudius-systems / osv

OSv, a new operating system for the cloud.
osv.io
Other
4.12k stars 605 forks source link

Fix build for Fedora 38 #1257

Closed nyh closed 1 year ago

nyh commented 1 year ago

This this small series we fix what needs to be fixed to build OSv on Fedora 38:

  1. Update setup.py to allow Fedora 38
  2. Add two stub functions that new libstdc++ started to need (but it's fine that they are stub)
  3. Add a missing include directive

After this patch, the OSv kernel builds and also some images (e.g., "rogue"). The default (Lua shell) build builds but doesn't run and will need to be fixed later.

Fixes #1238.

wkozaczuk commented 1 year ago

I did approve your PR because it looks good. But when I try to compile it on my Fedora 37 I get this compilation error:

  CXX bsd/sys/kern/kern_mbuf.cc
  CXX bsd/sys/kern/uipc_mbuf.cc
  CXX bsd/sys/kern/uipc_mbuf2.cc
  CXX bsd/sys/kern/uipc_domain.cc
  CXX bsd/sys/kern/uipc_sockbuf.cc
In file included from /usr/include/c++/12/cstdlib:75,
                 from /usr/include/c++/12/stdlib.h:36,
                 from ./bsd/porting/netport.h:14,
                 from bsd/x64/machine/in_cksum.cc:42:
include/api/stdlib.h:25:1: error: ‘_Float128’ does not name a type; did you mean ‘__float128’?
   25 | _Float128 strtof128 (const char *__restrict, char **__restrict);
      | ^~~~~~~~~
      | __float128
include/api/stdlib.h:35:68: error: ‘_Float128’ has not been declared
   35 | int strfromf128 (char *__restrict, size_t, const char *__restrict, _Float128);
      |                                                                    ^~~~~~~~~
make: *** [Makefile:389: build/release.x64/bsd/x64/machine/in_cksum.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from /usr/include/c++/12/cstdlib:75,
                 from /usr/include/c++/12/stdlib.h:36,
                 from ./libc/internal/locale_impl.h:5,
                 from include/glibc-compat/locale.h:11,
                 from /usr/include/c++/12/clocale:42,
                 from /usr/include/c++/12/x86_64-redhat-linux/bits/c++locale.h:41,
                 from /usr/include/c++/12/bits/localefwd.h:40,
                 from /usr/include/c++/12/ios:41,
                 from /usr/include/c++/12/ostream:38,
                 from /usr/include/c++/12/iostream:39,
                 from include/osv/debug.hh:11,
                 from bsd/net.cc:8:
include/api/stdlib.h:25:1: error: ‘_Float128’ does not name a type; did you mean ‘__float128’?
   25 | _Float128 strtof128 (const char *__restrict, char **__restrict);
      | ^~~~~~~~~
      | __float128
include/api/stdlib.h:35:68: error: ‘_Float128’ has not been declared
   35 | int strfromf128 (char *__restrict, size_t, const char *__restrict, _Float128);
      |                                                                    ^~~~~~~~~
make: *** [Makefile:389: build/release.x64/bsd/net.o] Error 1
In file included from /usr/include/c++/12/cstdlib:75,
                 from /usr/include/c++/12/stdlib.h:36,
                 from ./bsd/porting/netport.h:14,
                 from bsd/sys/kern/kern_mbuf.cc:28:
include/api/stdlib.h:25:1: error: ‘_Float128’ does not name a type; did you mean ‘__float128’?
   25 | _Float128 strtof128 (const char *__restrict, char **__restrict);
      | ^~~~~~~~~
      | __float128
include/api/stdlib.h:35:68: error: ‘_Float128’ has not been declared
   35 | int strfromf128 (char *__restrict, size_t, const char *__restrict, _Float128);
      |                                                                    ^~~~~~~~~
make: *** [Makefile:389: build/release.x64/bsd/sys/kern/kern_mbuf.o] Error 1
In file included from /usr/include/c++/12/cstdlib:75,
                 from /usr/include/c++/12/stdlib.h:36,
                 from ./bsd/porting/netport.h:14,
                 from bsd/sys/kern/uipc_mbuf2.cc:63:

On stack overflow I found this comment: "… In order to use _Float128, float128, and ibm128 on PowerPC Linux systems, you must use the -mfloat128 option. It is expected in future versions of GCC that _Float128 and __float128 will be enabled automatically…"

I believe it is from here. Do we need to add some explicit compiler option for this?

nyh commented 1 year ago

Thanks. As the errors suggested, "__float128" would work on earlier compilers, and I checked it also works on the new one (it seems to be an alias for _Float128, or vice versa). I am pushing a new version that works on Fedora 38, please check on Fedora 37 as well (I no longer have access to one...).

I also added a fix for the latest named posix feature, that has a warning on the new compiler.