-
Notifications
You must be signed in to change notification settings - Fork 30
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
Support of OCaml 5.0 (cleaned version) #124
Conversation
It's probably a better way to add libraries when we link objects from OCaml. With these options, we allow the linker to resolve all symbols regardless the order of these libraries. Indeed, the linker will repeatly lookup on these libraries until all symbols are resolved. However, it seems that these options can have an impact about performances of the linker. If we need to improve this situation, we must recalculate a topological order of libraries. But for our purpose, that's probably fine. Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
`sed -i` is not POSIX, it's better to generate a `*.sed` file and move it to the real destination. Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
With OCaml 5, the pattern was updated and has $$PTHREAD_LIB. We update accordingly. Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
…efile Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Currently, OCaml 5.0 wants to create 128 domains which requires a big allocation. We decided to allow the usage of only 1 domain. Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
…file) Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Initially, we used NULL and it seems that these values are used by GMP. We probably break something here if NULL <> 0 but conventionally, NULL = 0. Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
IMHO this is far from ready, we didn't really review much, we just got it to work. |
A precision about words used in my message:
|
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
3c569e2
to
a196317
Compare
From the cirrus CI, there is one warning and one error:
Would be great if someone more into TLS could take a look at the TLS issue (I suspect this is due to usage of clang/llvm both as compiler and as linker). |
Indeed the
It's interesting that the error was already spotted in Solo5 in https://github.com/Solo5/solo5/blob/7ba74eb9f645e07570cd35a833eddec4918eaf64/tests/test_tls/test_tls.c. And the test is deactivated when compiled with lld. The check in lld seems to be https://github.com/llvm-mirror/lld/blob/64b024a57c56c3528d6be3d14be5e3da42614a6f/ELF/Symbols.cpp#L112. |
a196317
to
62ea86c
Compare
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
Co-authored-by: Pierre Alain <[email protected]> Co-authored-by: Kate <[email protected]> Co-authored-by: Christiano Haesbaert <[email protected]>
78ad3c1
to
9c45880
Compare
Thanks for all the work @palainp @kit-ty-kate @dinosaure @haesbaert About the thread-local storage, I see some issues:
I started to read https://maskray.me/blog/2021-02-14-all-about-thread-local-storage to get a better understanding of thread local storage, but won't have much time this month to work on a more thorough review or patches. |
Co-authored-by: Pierre Alain <[email protected]>
…port) Co-authored-by: Pierre Alain <[email protected]>
c67e1f0
to
d5ef317
Compare
EDIT: The following was due to a faulting linker script. This is now fixed with the latest release. Along with the solo5 PR (Solo5/solo5#542), I tried to correctly use the TLS variant II for my processor (https://github.com/Solo5/solo5/blob/8c3a744f998b9977cfc6cd29e0cc40ae2efba167/tests/test_tls/test_tls.c#L52 TLS point to an address after the area) on OpenBSD. And it works (at least a few steps further)! However I still have a page fault error:
The
The top instruction is related to stack protection and for all other function I inspected it uses a
I don't understand why for that specific function the behavior has changed :( |
I'm curious, now that solo5 0.8 hit the release road, what is the status of this PR? Does it work on some (all?) platforms? Should we proceed (with review, more testing) in order to get MirageOS working with OCaml 5? A brief message would be welcome, maybe @palainp knows the details (since he was involved in the most recent commits). Thanks a lot. |
Thanks @hannesm for the reminder. |
Hi, thank you again for this work ! Using this proof of concept I've been able to test solo5-hvt with ocaml 5 / eio and didn't encounter any issue. |
Great to hear. From my point of view, we should first review this PR, test it thoroughly and release it (without switching the effective layer in MirageOS), also evaluate performance etc. I understand that developing the cool new stuff is exciting, but if nobody cares about upstreaming and pushing the PR to something that we're happy to maintain, there'll be all these vendoring / pin to random branches (that are a nightmare to update). So, TL;DR: my approach is still "upstream first". Since I'm a bit short on time (and my OCaml 5 knowledge is barely existant), I asked whether there are others (including you :) that would go through the code and thoroughly review it. :) |
@@ -22,7 +22,7 @@ depends: [ | |||
"conf-which" {build} | |||
"ocamlfind" {build} # needed by dune context (for tests) | |||
"ocaml-src" {build} | |||
"ocaml" {>= "4.12.1" & < "4.15.0"} | |||
"ocaml" {>= "5.0" & < "5.1"} | |||
"solo5" {>= "0.7.0"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "solo5" {>= "0.8.0"}
.
@@ -21,7 +21,7 @@ depends: [ | |||
"conf-which" {build} | |||
"ocamlfind" {build} # needed by dune context (for tests) | |||
"ocaml-src" {build} | |||
"ocaml" {>= "4.12.1" & < "4.15.0"} | |||
"ocaml" {>= "5.0" & < "5.1"} | |||
"solo5" {>= "0.7.0"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "solo5" {>= "0.8.0"}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shym and I have reviewed this PR and it looks good to us, with a few minor suggestions. Although we only tested it with toy examples.
We also have a couple of questions:
- Why not use only one
sed
command per file in theMakefile
to improve readability and to avoid multiple command executions and temporary files? - Shouldn't a comment be added to
nolibc/stubs.c
to explain the choice between preferring one ofSTUB_ABORT
,STUB_IGNORE
,STUB_WARN_ONCE
?
We think it would be interesting to target OCaml 5.1.1 directly, as it brings bug and performance fixes. The build system has also changed a lot since then, which would make it difficult to support both 5.0.0 and 5.1.1.
We are considering working on this, but would be eager to hear your opinion before starting.
|
||
test-headers: $(TEST_H_OBJS) | ||
test-headers: test-include/sys/ $(TEST_H_OBJS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test-headers: test-include/sys/ $(TEST_H_OBJS) | |
test-headers: $(TEST_H_OBJS) | test-include/sys/ |
The dependency on test-include/sys/
is order only.
* The following definitions are not required by the OCaml runtime, but are | ||
* needed to build the freestanding version of GMP used by Mirage. | ||
* For OCaml 5.0.0, it's not totally true. SIG_{BLOCK,SETMASK,IGN,DFL) are | ||
* needed by the OCaml runtime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The following definitions are not required by the OCaml runtime, but are | |
* needed to build the freestanding version of GMP used by Mirage. | |
* For OCaml 5.0.0, it's not totally true. SIG_{BLOCK,SETMASK,IGN,DFL) are | |
* needed by the OCaml runtime. | |
* The following definitions are required to build the freestanding version of GMP used by Mirage. | |
OCaml 5.0.0 also required the SIG_{BLOCK,SETMASK,IGN,DFL) definition. |
We rephrased part of the comment that was outdated by OCaml 5.0.0 support.
@@ -11,7 +11,10 @@ struct stat { | |||
#define S_IFMT 0 | |||
#define S_IFREG 0 | |||
#define S_ISREG(x) (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define S_ISREG(x) (0) | |
#define S_ISREG(x) 0 |
Nitpick, the parentheses were not useful here.
@fabbing @shym, thank you for the review! I'm only speaking for myself, but I totally approve if the building could be reworked (even if it doesn't work with 5.0.0, as it doesn't seem possible to deal with both 4.14.1 and 5+, it doesn't matter if 5.0 is skipped in the process). One thing that still needs work is the current absence of |
The advantage of having several seds is that you can contextualise them in relation to their commits and the PRs that have integrated them. These modifications can be difficult to understand in their current form, and historical information helps us to better understand the ins and outs of these arbitrary choices.
More comments is better 👍.
This PR is always set aside because these versions (5.0 and 5.1) lack compaction. The unikernels we are developing are mainly services. We therefore need a runtime capable of using memory that can be defragmented (and that the GC compacts) in order to provide these services for as long as possible. As @palainp pointed out, we may need to test allocation logic other than We will be delighted to have an extension of this PR with OCaml 5.2. And I'd be delighted to see more details of a possibility to experiment with OCaml 5 while keeping OCaml 4.14 support (I'll be more available for February). |
your review is highly welcome. I do agree with @dinosaure that likely we should target OCaml 5.2 (which allows compaction), and skip 5.0, 5.1 series. What I'm curious about is that we have some review comments in #122 (or are they all addressed?) -- would be great if you could take a look at them (and comment those which are resolved, maybe re-raise them here if they are not yet resolved). And then there is #129 -- If I understand correctly, that's mostly additional mmap stuff. In the end, it would be nice to agree on a single PR (this one?), and put the mmap changes here as well. In terms of ocaml-solo5 and OCaml 4 / OCaml 5 support: I don't think it is worth to have ocaml-solo5 that supports both versions of OCaml at the same time, so we should move the OCaml 4 support to a dedicated branch (in order to keep it up to date when OCaml upstream changes), and support only OCaml 5 in the main branch. |
This is the cleaned version of #122. From what I saw, I have some questions:
exportstubusleep
but we don't implement it. We should probably implement it when Solo5 has a function to sleep (seesolo5_yield
)qsort
) but no implementation are needed - at least, at this level of our usual compilation path. I wonder what happens to these functions. If they are exported, is it because they are required? By whom? For what?Finally, this PR only offers something that compiles. The project has not yet tested with a unikernel. It should be reconfirmed that qubes-firewall works and if we can get
This would be very good to confirm that this PR can be merged and that the MirageOS world can move to OCaml 5.