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

Add generic cross-compile support #12

Merged
merged 4 commits into from
Mar 10, 2021

Conversation

CodingCellist
Copy link
Contributor

Having previously needed to cross-compile this for use in simulation (but used a native platform for compilation, then copied the files), I have made an attempt at making this cross-compile in general.

There are some problems with getting volrend's libtiff to cross-compile successfully, and I have been unable to resolve these. Any help would be greatly appreciated!

The `radiosity` and `volrend` benchmarks rely on some libraries. These
are now explicitly cleaned with `make clean` as well, since this was
causing issues with getting cross-compilation going.
By adding support for a `CROSS_COMPILE` environment variable (similar to
what the Linux kernel supports) the benchmarks should be
cross-compileable. However, the `volrend` benchmarks relies on `libtiff`
which I cannot get to successfully cross-compile. It's been commented
out for now.
@CodingCellist CodingCellist marked this pull request as draft March 8, 2021 10:32
@SakalisC
Copy link
Owner

SakalisC commented Mar 8, 2021

It might be possible to link with a system version of libtiff for volrend instead of using the bundled version, which might solve the compilation issues. We have been able to compile for ARM targets before, but I can't remember if we used the bundled version or the system one.

Regarding support for cross-compilation in general, CC is already a variable, so it's possible to replace it with any compiler, I don't think you need to use the CROSS_COMPILE prefix. Similarly, I think it makes more sense to make ar into a variable as well, so that it can be set to the correct binary for the target. Finally, I am fairly certain it is possible to link with dynamic libraries when cross-compiling, so why is the -static flag hardcoded when cross-compiling?

@CodingCellist
Copy link
Contributor Author

Compiling with the system version of libtiff unfortunately doesn't seem to work when cross-compiling (which I guess makes sense given that the shared library will have been compiled for the guest OS architecture). However, I did manage to get volrend to compile by downloading and cross-compiling libtiff from its website, so thank you very much for that idea!

The CROSS_COMPILE prefix, as far as I know, is there so that variables like CC, LD, AR, etc. can be conveniently prefixed with CROSS_COMPILE instead of having to export/define each one when wanting to use a different tool.
Regarding the -static flag: It is hardcoded because for simulations, it can be difficult to have all the right libraries and tools installed in the right place on the virtual disk. Or at least, I found it to be the simpler approach for something like gem5 full system simulations, as opposed to configuring something like buildroot.

@SakalisC
Copy link
Owner

SakalisC commented Mar 9, 2021

Alright, I guess it makes more sense to have a prefix instead of having to change all the different variables. I am nitpicking, but would it make sense to rename the CROSS_COMPILE variable to something a bit more generic and self-explanatory, such as TOOLCHAIN_PREFIX or something similar?

Regarding -static, it makes sense with gem5, but I don't think we should have it hardcoded in the Makefile, since the Makefile is not gem5 specific.

@CodingCellist
Copy link
Contributor Author

CodingCellist commented Mar 10, 2021

Yes, TOOLCHAIN_PREFIX works as well. I picked CROSS_COMPILE because that seems to be what the Linux kernel uses, but I agree that having one with a clearer meaning is a good idea.

I'll remove the -static.

Based on suggestions by SakalisC, use `TOOLCHAIN_PREFIX` instead of
`CROSS_COMPILE` for the prefix for a cross-compiling toolchain. This is
clearer and more self-explanatory.

The `-static` flag was also removed from `Makefile.config` as it is only
relevant when using gem5 or a similar simulator, not for the benchmarks
in general.
The `volrend` benchmark was commented out due to cross-compiling issues.
These relate to `libtiff` rather than the benchmark and using a
cross-compiled version of the library fixes the issue.
@CodingCellist CodingCellist changed the title WIP: Armv8 cross-compilation Add generic cross-compile support Mar 10, 2021
@CodingCellist CodingCellist marked this pull request as ready for review March 10, 2021 08:13
@SakalisC SakalisC merged commit 1eb9c74 into SakalisC:master Mar 10, 2021
@SakalisC
Copy link
Owner

Thank you,this should be useful for a lot of people.

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

Successfully merging this pull request may close these issues.

2 participants