infra icon indicating copy to clipboard operation
infra copied to clipboard

m68k support

Open ggnkua opened this issue 6 years ago • 17 comments

(Cross linking from https://github.com/mattgodbolt/compiler-explorer/issues/271)

Hi,

So after spending a bit of time fixing up my build script for m68k compilers I thought I'd take a look and see how it could be added to this repository. I have a few initial questions:

  1. From what I've seen from the other cross compiler build scripts (like for example gcc-cross\build\msp430-gcc453) only the compiler is being built without libraries. My script also builds quite a few libs - are those not needed? I'm asking this because if only the barebones compilers are required then the build script gets significantly smaller.
  2. I also asked this in the compiler-explorer issue - from what I understand the compilers are being installed in /opt - what would an accepted naming scheme be? @RabsRincon suggested gcc-x-x-x-68k, by default the compilers are named m68k-x-x-x-elf fwiw.
  3. Can anyone help me figuring out how docker works? For my build I require a few versions of gcc to be present (4 through 7), the usual GMP/MPFR/MPC and a couple of others like flex and bison (if the libraries are being built). From what I understand there's a repository of docker packages one can get and use the built-in tools but this is just dark arts for me right now :)

Feedback welcome! George

ggnkua avatar Feb 15 '18 09:02 ggnkua

Hi! I'm so so sorry this took so long to get answered. I thought I had done it! I can't answer 1, but I'll cc @mattgodbolt 2) gcc68k-X.Y.Z is also a good idea, consistent with other, already installed, compilers And as for 3, I wish I could help, but I'l cc @mattgodbolt again 😄

Again, sorry this took so long, it should have not happened like this!

:)

AbrilRBS avatar Mar 06 '18 08:03 AbrilRBS

  1. If you're talking about libraries that ship with the compiler (libgcc et al), then I would like them built...and any help with ensuring they're available for other platforms (except the "barebones" compilers). My experience with cross-compilers is very limited, so any help gratefully received.
  2. Yup; agree with @RabsRincon :)
  3. Docker is more like a VM - it isn't a package manager as such. There are many "source images" you can start with (E.g. Ubuntu 18.04..) but then it's up to you to configure them. Usually this is pretty easy - a few apt-get install type things. These go in a Dockerfile e.g. https://github.com/mattgodbolt/compiler-explorer-image/blob/master/gcc/Dockerfile). Once that docker image is built you can run commands in it to build the application. If you have trouble getting docker working, just get your scripts running and let me know what you need in the build environment; then I can set up the docker magic. Thanks so much!

mattgodbolt avatar Mar 06 '18 14:03 mattgodbolt

Hi,

  1. In a nutshell:
  • libgcc is very easy in terms of scripting
  • libc is a bit more difficult since it's partly system specific. For the Atari ST series the standard modern library is MiNTlib (https://github.com/freemint/mintlib). The library itself is a bit problematic to compile (in my experience at least) due to the forked binutils the team uses. However this is all handled automatically in my build script (using an older version of the lib since it does not matter much to me to keep bleeding edge).
  • libstdc++ is even more challenging since we need to turn exceptions and some other stuff off and patch a few things in order to build. However this is again handled by my build script.

So, to summarise: these can all be built but they'll be locked to one platform. Other machines like the Amiga, Mac, x68k etc will have to be handled by others. If that's ok with you then my build script is at your service!

  1. Easy to do, no worries!

  2. Ok, that makes a lot of sense, thanks for the clarifications! My script is live on bibucket already (https://bitbucket.org/ggnkua/bigbrownbuild) but I'll need to make some modifications to it. Nothing major though, just the naming and output folders. A couple of weeks ago I managed to build it in ubuntu 17.10 but I got a lot of Internal Compiler Errors while building some versions of gcc, so I went into super pedantic mode and used the same major version of gcc to build the respective cross gcc.

By the way, if you can tell me how to trigger a docker build (just the command lines to do it, I suppose I can change the dockerfile you linked to suit my needs) I can try it on my machines.

Thanks for the response so far! Let me know what you think on the above points and I'll get started.

ggnkua avatar Mar 06 '18 17:03 ggnkua

Sorry I didn't reply earlier! This got lost...apologies.

Makes sense about the platforms. Anything we have is an upgrade from the nothing currently, so whatever you can contribute would be great.

Docker builds aren't triggered as such. Do you mean the "build of the docker container" or the "running a docker container to build a compiler" ? The former is docker build -t <name> <dockerdir>, the latter is something like docker run --rm <name> bash build.sh more args to the build here. Check the Makefile and the build_and_upload*.sh files.

I'll try and check out your build scripts, if the docker thing is bewildering (and I know it is...) I will find time to get them working in a docker build container.

mattgodbolt avatar Mar 14 '18 13:03 mattgodbolt

Hi!

No worries about being late with your reply as I've been kind of busy lately. But I did do some work on this yesterday - synchronicity!

So I've made a "compiler-explorer" branch on the repo (https://bitbucket.org/ggnkua/bigbrownbuild/src/6a8f91220c211623634fb43fedb38b67ea9c5573/?at=compiler-explorer). In theory you should be able to get the repo and run "bigbrownbuild.sh" as root. This will auto-fetch all dependencies and build the compilers in /opt/compiler/explorer without any interaction.

The requirements (for the dockerfile) are: gcc 4.8.5, GMP, MPFR, MPC, bison and flex.

Some things you might want to tune:

In line 43 I set the exact compiler name for each major version of cross compiler generated. Possibly you need to modify this. In line 55 I set the -j parameter for make, i.e. how many threads to allocate. Also modify to taste.

And that should be pretty much it I think. If time allows today I'll try to do a few tests with docker as it doesn't seem that complicated!

ggnkua avatar Mar 15 '18 06:03 ggnkua

Hi,

Just dropping a note here that I'm experimenting with docker a bit and I'm having some progress - hopefully I can have something working soon!

ggnkua avatar Mar 29 '18 05:03 ggnkua

Ok, it's still running here but it's looking good - so I'm attaching the dockerfile I created here: dockerfile.zip

In the Makefile I added $(DOCKER) build $(BUILD_OPT) -t mattgodbolt/gcc-cross-68k gcc-cross-68k in build-compiler-images target and I did make build-compiler-images (for speed reasons I commented out the other docker commands).

Apologies for not using a git pull request but I'm absolutely terrible with git :)

In any case hopefully @mattgodbolt will have a look at it and won't need eye bleach - this is my very first attempt at using Docker at all!

ggnkua avatar Mar 29 '18 12:03 ggnkua

Thanks so much! I'm sure I can get it working: I'm no Docker expert either :D I'm out for Easter, but will take a look early next week. Thanks again!

mattgodbolt avatar Mar 29 '18 15:03 mattgodbolt

I think it's safe to assume that this was forgotten. So I guess I'll give a slight bump for @mattgodbolt :).

ggnkua avatar Sep 03 '18 11:09 ggnkua

Sorry, this keeps slipping down my list of priorities. I'm working on the cross-compiler after some great pull requests to improve things from others, so hopefully I'll get this in too.

mattgodbolt avatar Nov 14 '18 15:11 mattgodbolt

No worries whatsoever - keep up the good work :)

ggnkua avatar Nov 14 '18 16:11 ggnkua

Ok, let's try this one more time!

Hi there!

Over the past few days I spent some time bringing the dockerfile up to speed with the build script and I've attached the result. I executed docker on my machine here with sudo docker build gcc-cross-68k and everything went smoothly - /opt/compiler-explorer was populated with folders gcc68k-*.

Sadly I couldn't get it to work with your Makefile system. I must admit that I was never fond of makefiles so I never know where to start! But other than this, the rest should be just running the dockerfile and it'll take care of the rest.

Hope to see it live some time :).

gcc-cross-68k.zip

ggnkua avatar Sep 16 '19 04:09 ggnkua

I guess last week was an unfortunate week to post an update to this since Matt was away at cppcon having fun, so let's try it once more. @mattgodbolt :)

ggnkua avatar Sep 28 '19 10:09 ggnkua

Would like to voice my support for m68k support in CE.

Im doing a bit of work with m68k at the moment, so this would be very handy to have.

So far I am getting by with compiling my code with debugging information and dumping the assembled source afterwards, CE would be a much more slick way to do things. :)

tomstorey avatar Sep 29 '20 10:09 tomstorey

@tomstorey If you need it right now, I do have an instance of compiler-explorer with m68k compilers running here: http://brownbot.mooo.com

ggnkua avatar Sep 29 '20 10:09 ggnkua

@ggnkua I will take a look later on, thanks!

Corporate firewall is sinkholing your site so I cant look at the moment.

tomstorey avatar Sep 29 '20 10:09 tomstorey

Bump for @mattgodbolt to pull this into Compiler Explorer. Thank you @ggnkua for creating an M68K version!

HarjitSi avatar Sep 12 '22 19:09 HarjitSi