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 compiling on MIPS #4037

Closed
rata opened this issue Sep 27, 2023 · 2 comments · Fixed by #4076
Closed

Support compiling on MIPS #4037

rata opened this issue Sep 27, 2023 · 2 comments · Fixed by #4076

Comments

@rata
Copy link
Member

rata commented Sep 27, 2023

Description

When re-working the cloned binary trick (#3987), we ended up doing this:

runc/cc_platform.mk

Lines 51 to 53 in 96a61d3

else
$(error Unsupported GOARCH $(GOARCH))
endif

This will make the compilation fail on architectures others than the listed there, like MIPS. Distros like debian are shipping the runc binary for those architectures already.

Steps to reproduce the issue

No response

Describe the results you received and expected

I'd expect runc compiles in the same architectures as before or a clear reasoning explaining to users why we dropped some is provided

I think adding support for other architectures is simple, so it is worth it. I think we need to change this:

runc/cc_platform.mk

Lines 51 to 53 in 96a61d3

else
$(error Unsupported GOARCH $(GOARCH))
endif

to just define the CFLAGS like "-DRUNC_USE_STDLIB" instead of error out.

and then in the file libct/dmz/Makefile provide a target for the arches that support nolibc, identical to the one we have today, and then another that doesn't add the flags to compile with nolibc (ie not add -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib -lgcc).

Then, the _dmz.c file can have something like:

#ifdef RUNC_USE_STDLIB
#include  <unistd.h>
#else 
#include "nolibc/nolibc.h"
#endif

And this should do the trick.

I'm going afk for a few weeks tomorrow, so I'm not opening a PR I won't be able to be active. But it would be great if someone does so :)

cc @AkihiroSuda @cyphar

What version of runc are you using?

runc main

Host OS information

No response

Host kernel information

No response

@cyphar
Copy link
Member

cyphar commented Sep 27, 2023

The stuff in cc_platform.mk you mention is related to cross-compilation, not nolibc usage. If you are on a MIPS machine, you already should be able to compile runc-dmz with your local compiler (well, aside from the lack of nolibc support 😉) because we don't do any of the platform stuff for the local architecture:

ifeq ($(GOARCH),$(shell GOARCH= $(GO) env GOARCH))
	# use the native CC and STRIP
	HOST :=
else # ...

So changing the $(error ...) line won't affect local compilation on MIPS (I don't know if Debian cross-compiles for MIPS). You probably need to rework cc_platform.mk a bit to make it work for both HOST configuration and detecting which platforms are supported by nolibc.

@rata
Copy link
Member Author

rata commented Sep 27, 2023

Oh, I looked at it quickly and missed that, thanks!

Then it is even simpler, we just need to look at the go arch and if nolibc is not supported, add a target that uses stdlib (using -DRUNC_USE_STDLIB as I said should do it).

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