Solo5 / solo5

A sandboxed execution environment for unikernels
ISC License
883 stars 136 forks source link

Fetch `stdatomic.h` from system on FreeBSD #574

Open shym opened 2 months ago

shym commented 2 months ago

This PR adds stdatomic.h to the set of headers that must be copied over from /usr/include on FreeBSD because it is not included in the clang resources on that system.

stdatomic.h is not listed in the C standard as a freestanding header but many atomic operations (in particular all the atomic operations the OCaml runtime uses) are really compiler builtins.

hannesm commented 2 months ago

to me, this looks fine. I'm curious whether other systems need this as well? especially OpenBSD?

shym commented 2 months ago

I expected so too but, at least on OpenBSD 7.3, stdatomic.h is in the Clang resources and I could compile the OCaml 5.2 runtime which needs this header with the current solo5 package.

hannesm commented 2 months ago

The reason may be that the gen_headers.sh does a cd /usr/include and cc -M float.h stddef.h stdint.h stdbool.h stdarg.h to figure out all dependencies of these header files -- eventually an OpenBSD system includes atomic.h/stdatomic.h in these dependencies...

hannesm commented 2 months ago

hmm, on a OpenBSD 7.4 system I have access to, there's just no atomic.h, neither a stdatomic.h... but a sys/atomic.h -- and the cc -M doesn't show it up... well, I don't have insights into the OCaml configure, but if it works without copying stuff, that's fine :)

shym commented 2 months ago

On an OpenBSD 7.5, I see:

$ echo '#include <stdatomic.h>' > test.c
$ cc -H -c test.c
. /usr/lib/clang/16/include/stdatomic.h
[...]