-
Notifications
You must be signed in to change notification settings - Fork 122
Add cross-compilation support to Makefile #461
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
Conversation
|
I suppose I should also document this in README if the change is accepted. |
b59d444 to
f62c49d
Compare
| endif | ||
|
|
||
| OS = $(shell uname -s) | ||
| ARCH = $(shell uname -m) |
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.
This can return arm64 on macOS or aarch64 on Linux but clang seems happy with either in the target triple.
|
Having to gather all binaries for putting together a sysroot is a bit cumbersome. I was wondering if we could, perhaps, provide a Containerfile that would build |
|
My idea was to minimize build dependencies (i.e. it should be doable without any container runtime / virtualization solution). I first added this for FreeBSD on my branch where making a sysroot was as simple as downloading and unpacking base.txz. Maybe I could write a similar script for Linux. For example, it's possible to use skopeo and umoci to download and extract files from any OCI image. But I'm sure one could find Debian tarballs or something like that as well. |
|
Yep, you can just download these four deb packages, unpack with |
0c1863d to
c4dadf1
Compare
|
Ok, I updated the Makefile to generate a Debian sysroot automatically on macOS. These are downloaded and unpacked to This should ultimately simplify homebrew packaging of libkrun as well. |
slp
left a comment
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.
I've started using this patch with the homebrew package and works great. With just some minor changes we should be able to merge.
In addition to the inline comments, please reword the commit titles as "file: change in the file".
ded01df to
94a59cc
Compare
|
@slp Thanks for the review! I applied your suggestions. |
94a59cc to
f658fd5
Compare
…enerated sysroot Signed-off-by: Jan Noha <nohajc@gmail.com>
…iant Signed-off-by: Jan Noha <nohajc@gmail.com>
f658fd5 to
c153bbf
Compare
|
Tbh, I don't like this kind of indentation where you're mixing spaces and tabs (and tabs have special meaning). If you open the Makefile in VS Code, syntax highlighting actually reveals this. Also, it's already broken in couple of other places where a tab has been used by accident. |
Agreed, we should clean it up eventually. |
slp
left a comment
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.
LGTM, thanks!
At the moment, I'm porting
init.krunto FreeBSD (hoping to open that PR soon) and I thought it would be neat to have the option to compile on macOS without spinning up a VM if one so chooses.This relies on
clangandlld(the LLVM linker). Plus, you need to provide path to a suitable sysroot. I tested the build by copying/usr/include,/usr/lib/aarch64-linux-gnuand/usr/lib/gcc/aarch64-linux-gnufrom a Debian Bookworm system.Just wasn't sure if I should strip the binary or not. Right now it's configured to only strip
debug_info.