Skip to content
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 on Minix3 #7365

Closed
vicuna opened this issue Sep 22, 2016 · 7 comments
Closed

Support on Minix3 #7365

vicuna opened this issue Sep 22, 2016 · 7 comments

Comments

@vicuna
Copy link

vicuna commented Sep 22, 2016

Original bug ID: 7365
Reporter: pmetras
Assigned to: @shindere
Status: assigned (set by @damiendoligez on 2017-02-27T15:20:09Z)
Resolution: open
Priority: normal
Severity: feature
Platform: i386
OS: Minix3
OS Version: 3.4.0
Category: platform support (windows, cross-compilation, etc)
Monitored by: @gasche

Bug description

This patch adds support for Minix3 to OCaml distribution.

Since around 1985, Minix has always been an environment for learning and trying system programming, offering a clean and simple Unix-like operating system, originally written by Andrew S. Tanenbaum. Adding OCaml support on that environment helps both Minix and OCaml enthusiasts offering new tools to play with. And a few years ago, the messages passing architecture of Minix was proven sound by a OCaml program...

You can learn more about Minix on http://www.minix3.org.

Additional information

What's in the patch?

  • i386 assembly generation. ARM support has not been tested.
  • Disable tests related to systhreads (not implemented in Minix) and use VM threads instead.
  • Include missing files in Makefile
  • Issue a warning at compilation/raise exception in otherlibs/bigarray because msync() is not implemented yet.
  • Raise OCaml exception when trying to use Bigarray.map_file in shared mode as shared mmap are not implemented yet.
  • Minix3 has an incomplete IP stack and does no routing. Local host IP 127.0.0.1 is not defined. We bind to the first available IP address in testsuite lib-threads. It should work with other OS too...

File attachments

@vicuna
Copy link
Author

vicuna commented Sep 28, 2016

Comment author: @damiendoligez

Looks good in general but I have a few questions:

  • About the addition of instrtrace.o in Makefile.common: why is this
    needed? AFAIK instrtrace.o is only used in debug mode and it is
    added explicitly in the definition of DOBJS. What is the Minix-specific
    feature that makes this change necessary?

  • About msync, could you get rid of the #if nesting? Also, you should
    remove the "To be removed" part from the actual failure message.

  • In Unix, the loopback address is just a line in /etc/hosts. I'm surprised
    that Minix cannot do the same thing.

@vicuna
Copy link
Author

vicuna commented Sep 28, 2016

Comment author: pmetras

  • About the addition of instrtrace.o in Makefile.common: why is this
    needed? AFAIK instrtrace.o is only used in debug mode and it is
    added explicitly in the definition of DOBJS. What is the Minix-specific
    feature that makes this change necessary?
    I found it was missing when I tried to compile the instrumented compiler. From my notes, I was using the configure command:
    $ ./configure -cc 'clang -DDEBUG' -as 'clang -c' -aspp 'clang -c' -with-debug-runtime
    I was not able to compile a debug environment (moreover gcc is not available...) and perhaps this part of the patch is remaining from my tests. Also the byterun/.depend file was not updated as some files are generated for the debug compiler. I stopped that path after a few days...
    Is there a documentation explaining how to produce the debug environment? I can try to recreate it and see if it works under Minix3.

  • About msync, could you get rid of the #if nesting? Also, you should
    remove the "To be removed" part from the actual failure message.
    OK, I'll look at it. Currently, Minix3 is a half-baked OS mostly for education and research, and perhaps secured embedded systems. It tries to support the full POSIX specification but some system calls are partially implemented or some features are missing (see http://wiki.minix3.org/doku.php?id=roadmap). We can expect to see shared-writable file mappings supported sooner or later.
    Initially, the message was a C compiler warning, but the new Makefile consider all warnings as errors and I changed it to a runtime exception.

  • In Unix, the loopback address is just a line in /etc/hosts. I'm surprised
    that Minix cannot do the same thing.
    Yes, this was so obvious that it bugged me a few days before I discover the real cause. Extract from Minix3 Developper's Guide (http://wiki.minix3.org/en/DevelopersGuide/PortingGuide):
    "Because there is no dedicated loopback device, it is not possible to have a server listening on localhost (127.0.0.1). If you encounter that problem, you can listen on INADDR_ANY instead; but, note that it works only if there is a network connection (note that, for example, the X Window System cannot be started without one). Also, think through the security implications of accepting non-local connections."
    The INADDR_ANY address can't be used in that case. I've tried to use the Config module to detect that the test is running on Minix3 but it adds too much dependency for a simple regression test. I also tried to use exceptions if it was not possible to bind to 127.0.0.1 but it made the code really more complex. My solution is a bit of a hack and it could fail on other platforms...

@vicuna
Copy link
Author

vicuna commented Sep 28, 2016

Comment author: pmetras

For the last point, here is the result of the ifconfig command:

ifconfig

/dev/ip: address 10.0.2.15 netmask 255.255.255.0 mtu 1500

@vicuna
Copy link
Author

vicuna commented Sep 29, 2016

Comment author: pmetras

Typo in previous note: "gcc is not available" should have been "gdb is not available".

@vicuna
Copy link
Author

vicuna commented Oct 5, 2016

Comment author: @damiendoligez

./configure -cc 'clang -DDEBUG' -as 'clang -c' -aspp 'clang -c' -with-debug-runtime

To build the debug runtime you simply need to give the -with-debug-runtime to configure. It will build and install the debug runtime in addition to the normal one. Your mistake is here: -cc 'clang -DDEBUG' this will try to compile both runtimes with the -DDEBUG option, which fails for the normal runtime.

For the loopback thing I don't think it's worth the trouble (and potential breakage) of changing the tests. You should just skip them when the loopback interface is not available (as you do for signal2.ml), have a new variable (HAS_LOOPBACK_ADDRESS) in config/Makefile, and add a few lines to configure to set this variable correctly (Minix -> false, anything else -> true).

BTW your usage of ifdef is incorrect. Instead of
ifdef $(SYSTHREAD_SUPPORT)
you should write
ifdef SYSTHREAD_SUPPORT
.

Do you have a GitHub account? It would be easier to discuss this in a GitHub PR.

@vicuna
Copy link
Author

vicuna commented Feb 16, 2017

Comment author: @xavierleroy

Pushing to "later" as this isn't ready to go in 4.05.

I'm not sure this port is something we want to integrate in the core distribution (as opposed to having the Minix people package a modified version of OCaml). At any rate, I object to changing the test suite to work around Minix limitations, and especially ot substituting VMthreads for systhreads, because as #7366 shows the substitution doesn't work.

@mshinwell
Copy link
Contributor

There didn't seem to be much enthusiasm for this back in 2017, and there was no response from the author to the latest review comments, so I'm going to close this. If there is demand for Minix support in the future we can always reevaluate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants