-
Notifications
You must be signed in to change notification settings - Fork 29
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
ocaml-freestading 0.6.6 failing to compile on OpenBSD (7.0 Current) #101
Comments
That weird because I believed that this PR (included into 6.6) fixed the error: #99 can you check with |
@dinosaure whats the best way to pin |
So if you have EDIT: I will try to reproduce on my side. |
ps off to bed now, will check back over the weekend |
Ok, the error persist on OpenBSD so. I will try to figure out why. Thanks. |
Ok it seems that
I will try to figure out why |
The
The question is simple, why OpenBSD has a different behavior than Debian. One use |
NOTE: I suspect that the next release of |
In solo5 (bindings/GNUmakefile) I see:
Are these fine with OpenBSD's current system? Have they been renamed recently? Is there need for such a condition in freestanding? What I wonder is that solo5 compiles and test run fine on OpenBSD. Maybe time to setup an OpenBSD VM. |
Yes those look correct, I haven’t heard of them changing! (see __stack_smash_handler search of the OpenBSD code on GitHub) we do need these flags for OpenBSD on solo5
after reading hannesm post a few times, I expect we would need a condition like that. edited: remove my response after not reading the whole thread, added too |
I looked a bit deeper into this issue, and encountered the following:
The configure and build process we are doing in ocaml-freestanding is basically cross-compilation, but OCaml:
Now, Attempts to fix this:
Result is the same on OpenBSD. (b) let's remove
Same on FreeBSD and OpenBSD. so the actual error is now exposed (and on all these systems now openlibm is used, not libm) --> maybe our
But how to fix this situation now? Should we avoid the (not-really-cross-compilation-safe) OCaml configure script? Should we attempt to snitch in an object that defines the stack protector symbols? Should we patch OCaml's configure to behave slightly differently? Somehow, we need to convince configure to use crt.o for its cc invocations -- the crt.o from solo5 bindings/crt.c... But I'm not sure how to do this. At least the above investigation shows how to reproduce the (very valid) error on Linux systems. |
Unfortunately, the problem persists with Solo5/solo5#506 and #92. I will try to find a good solution from these PRs - we are close to make a release of them. Thanks for your feedback @hannesm, we should indeed be aware about The older |
OCaml's configure script tries to link with libm (-lm). This results in configure linking with the system libm which hides some missing symbol errors, and only results on OpenBSD issues (see mirage#101). This renames the openlibm.a to libm.a, and results in configure failing on all platforms.
In #102, the ldflags are passed through. This results in OCaml's configure (conftest) attempting to link an executable, and missing the |
I updated #102 which works fine for me on FreeBSD (I only tested ocaml-freestanding, not to compile a unikernel) -- does this also work on OpenBSD and Linux? Does it allow to assemble unikernels that work? The "trick" is to define a weak solo5_app_main symbol in sysdeps_solo5.c, and OCaml's configure is able to generate executables :) |
On my side, I found a solution for OpenBSD 7 and the new Solo5 toolchain (and #92), this is the diff (mostly inspired from your patch): diff --git a/Makefile b/Makefile
index a305dca..4220a8a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,8 @@ all: openlibm/libopenlibm.a nolibc/libnolibc.a ocaml ocaml-freestanding.pc frees
TOP=$(abspath .)
# CFLAGS used to build nolibc / openlibm / ocaml runtime
-LOCAL_CFLAGS=$(MAKECONF_CFLAGS) -I$(TOP)/nolibc/include -include _freestanding/overrides.h
+LOCAL_CFLAGS=$(MAKECONF_CFLAGS) -I$(TOP)/nolibc/include -include _freestanding/overrides.h \
+ -L$(TOP)/openlibm/ -lopenlibm
# CFLAGS used by the OCaml compiler to build C stubs
GLOBAL_CFLAGS=$(MAKECONF_CFLAGS) -I$(MAKECONF_PREFIX)/freestanding-sysroot/include/nolibc/ -include _freestanding/overrides.h
# LIBS used by the OCaml compiler to link executables The error is a bit different that I will try your PR @hannesm to produce an unikernel and if it's working, we will cut a release. Then, I will integrate my fragile patch into #92 and we will be ready to cut Solo5.0.7.0 and ocaml-freestanding.0.7.0 🎉 ! EDIT: that mostly means that we have two errors:
|
According to git, this is the case at least since OCaml 4.08 (when the switch to autoconf happened). So, my suggestion here is to carry in freestanding a patch for OCaml's configure to remove |
@adamsteen with a deep look on Solo5/ocaml-freestanding with @hannesm, we agreed that the current toolchain proposed by Solo5 and used by The problem triggered by OpenBSD 7 is about the The initial problem is the We were disturb for a long time by the GNU's linker which seems "smarter"/"unpredictable" than If we go further on this way and be sure to use So, if we go further, we should add some option at the link time for any programs needed for the OCaml's Now, we got an other problem. So, finally, for the only purpose to be able to compile some C programs to help the If I spent my time to explain all of this, it's to say that the next release of Solo5.0.7.0 will fix the problem via a new toolchain which is able to provide a fake underlying layer for us and specially for the OCaml's Finally, given this description, the way to fix it and the current situation: we are not able to spend more times on So what do you think @adamsteen about this solution? |
Indeed, #102 is a hacky solution for this issue in MirageOS 3 land -- unclear whether it is worth to go down this path. In MirageOS 4 land (with solo5 Solo5/solo5#506) and the instructions on https://next.mirage.io/docs/mirage-4 (plus an "opam pin add ocaml-freestanding.0.7.0 git+https://github.com/hannesm/ocaml-freestanding.git#cross-compiler-take3" which adds #104), this should now work on OpenBSD 7.0 :) Since MirageOS 4 is close to a release, and we would like to deprecate MirageOS 3, I think it is best to focus on MirageOS 4 and get that out of the door (including OpenBSD support) rather sooner than later. |
@dinosaure and @hannesm i don’t think it worth fixing this for mirage 3, I don’t use it for production and I expect I am the only one using it on OpenBSD. I will test ocaml-freestanding 0.7.0 (as above) as soon as I have a few moments! just so I am clear, this is a real bug not just a OpenBSD being different? |
No, it is an actual issue that is (for some reason) only exposed on OpenBSD: OCaml's configure script inserts a Which sets the With MirageOS 4, the OCaml configure will use a cross toolchain that is able to link executables (maybe even execute them) - solo5 )0.7.0 - not yet released) provides a stub target for this. With the released ocaml-freestanding, as the cross-chain is incomplete, the fix is more involved (also trying to build complete executables with solo5 ldflags, and providing missing symbols). |
I tried to compile as above, but was getting unable to resolve dependency errors, not built with dune, probably user error, will try again in the coming days and report back! |
I am unable to test this atm, as when I try make depends with the mirage next instructions, |
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
The specific toolchain allow the proper detection of the math library
if there is anything else you need or i can help with please let me know
The text was updated successfully, but these errors were encountered: