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

Bootstrap on OpenBSD? #296

Closed
hosewiejacke opened this issue May 1, 2019 · 17 comments
Closed

Bootstrap on OpenBSD? #296

hosewiejacke opened this issue May 1, 2019 · 17 comments

Comments

@hosewiejacke
Copy link

hosewiejacke commented May 1, 2019

I'd like to try MLton on OpenBSD.

However, in order to compile mlton I need a compiled mlton :)
Sourceforge has only binaries for Darwin and Linux.

Any idea how to proceed?

@hosewiejacke hosewiejacke changed the title Bootstrap on OpenBSD Bootstrap on OpenBSD? May 1, 2019
@AlexanderAA
Copy link
Contributor

AlexanderAA commented May 1, 2019

A working but unfinished MLton port for OpenBSD 5.9 can be found here: https://github.com/extensibl/ports

The mlton-bootstrap README in the above repository contains notes on how to bootstrap the older version of MLton. However, the port is not completed exactly because there were difficulties bootstrapping MLton in offline mode with just MLton sources available.

@hosewiejacke
Copy link
Author

Thanks! I'm not sure I have the skills to finish the port, though.
Do you know if it's possible to cross compile it on Linux?

@AlexanderAA
Copy link
Contributor

I would suggest to try and get it done the right way from the start, both OpenBSD and MLton are many commits ahead, so it might just work.

There are some instructions in the MLton documentation and wiki.

Cross-compilation notes for the older version of MLton are here, as well as the resulting files, needed to bootstrap the compiler on OpenBSD: https://github.com/extensibl/ports/blob/master/mlton-bootstrap/bootstrap/

@MatthewFluet
Copy link
Member

It should be possible to either actually cross-compile on Linux (i.e., produce OpenBSD binaries on a Linux machine) or to indirectly cross-compile on Linux (i.e., use the Linux machine to produce the bootstrap files that will then be compiled on the OpenBSD machine).

See http://mlton.org/PortingMLton for some details, especially the Bootstrap section.

@hosewiejacke
Copy link
Author

hosewiejacke commented May 10, 2019 via email

@MatthewFluet
Copy link
Member

One problem with keeping the generated .c files on MacOS with -target self is that you may have embedded libc constants from MacOSX that don't make sense on OpenBSD. You really need to build the runtime system and the constants file on the OpenBSD system.

@hosewiejacke
Copy link
Author

hosewiejacke commented May 10, 2019 via email

@MatthewFluet
Copy link
Member

The essential steps (albeit, cribbed together from different pages) is

  1. Use bin/add-cross to build the runtime and constants on a target machine and pull those files back to the host machine. Although the script is named add-cross, you don't actually need gcc cross-compiling tools to do this.
  2. Use bin/save-bootstrap-source to build the bootstrap .c files on the host machine, but using -target amd64-openbsd; this will use the constants gathered on the target machine.
  3. Now copy the bootstrap .c files over to the target machine to compile and link with gcc.

Essentially, this is the Bootstrap section of http://mlton.org/PortingMLton, but with the additional initial step of running bin/add-cross (which was mentioned in the previous Running the regressions with a cross compiler section of that page)

@hosewiejacke
Copy link
Author

hosewiejacke commented Jun 1, 2019 via email

@hosewiejacke
Copy link
Author

bin/add-cross fails in line 160 with

.../mlton/build/bin/mlton: No such file or directory

If I replace the path with /usr/bin/mlton it says

invalid target: amd64-pc-openbsd

Is it correct that there should be a binary in .../mlton/build/bin?

PS: The tar archive, that gets copied to the target, doesn't include the Makefile.config. I copied it by hand to make ./bin/mmake happy.

@MatthewFluet
Copy link
Member

I think that bin/add-cross assumes that you have already done make all on the local machine; that will create the binary in mlton/build/bin.

Yes, Makefile.config should be included in the archive sent to the remote machine.

@hosewiejacke
Copy link
Author

hosewiejacke commented Jul 12, 2019 via email

@MatthewFluet
Copy link
Member

Can you tell where in add-cross that complaint is coming from?

@hosewiejacke
Copy link
Author

hosewiejacke commented Jul 12, 2019 via email

@MatthewFluet
Copy link
Member

Then something went wrong earlier in the script with either building the runtime on the target system or copying files from the target system back to the host system. On the host, you should have a ./build/lib/mlton/targets/amd64-pc-openbsd directory that is populated with at least arch, os, sizes, and some lib*.a files.

@MatthewFluet
Copy link
Member

Maybe no longer of interest, but #380 has streamlined bootstrapping MLton on new platforms. With it, I was able to bootstrap on amd64-openbsd; the resulting amd64-openbsd binary release file is at: https://downloads.sourceforge.net/project/mlton/mlton/experimental/20200523/mlton-20200523.150430-gb1b624ad3-1.amd64-openbsd.tgz

@barracuda156
Copy link
Contributor

@MatthewFluet I consider using OpenBSD as a second system on my PowerPC hardware, if that works, I will be interested to build mlton there too. (Not sure if OpenBSD has it presently though.)

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

No branches or pull requests

4 participants