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 containerized prebuilt toolchains #38

Merged
merged 7 commits into from
Jan 27, 2024

Conversation

jessicarod7
Copy link
Contributor

@jessicarod7 jessicarod7 commented Jan 25, 2024

This compiles each of the toolchains into a container image, and then uploads them to ghcr.io. It's a bit simpler than needing to install the dependencies and compile the toolchain, which can take a while.

I've successfully cross-compiled and ran a program on my Kobo. The workflow-generated images from those tests are in this package. If this PR gets merged, the Action can be manually dispatched to create a package owned by koreader, and would automatically run on future releases.


This change is Reviewable

@Frenzie
Copy link
Member

Frenzie commented Jan 25, 2024

Incidentally there is a GitHub action that provides compiled toolchains: https://github.com/koreader/koxtoolchain/releases/tag/2021.12 That's not an objection, but I am curious what about that you found lacking. :-)

@jessicarod7
Copy link
Contributor Author

Mainly to make it easier to use on Windows and Mac, where running the toolchain is a bit harder.

@NiLuJe
Copy link
Member

NiLuJe commented Jan 26, 2024

I don't do containers, so this is all Greek to me ;).

@Frenzie
Copy link
Member

Frenzie commented Jan 26, 2024

Mainly to make it easier to use on Windows and Mac, where running the toolchain is a bit harder.

That somewhat ties in with my other question relating to the full images which include everything including the tc.

@Frenzie
Copy link
Member

Frenzie commented Jan 26, 2024

Anyway, did you want to rebase it into a few tidier commits or shall I just squash it all?

@yparitcher
Copy link
Member

I also don't have much container experience/interest, but what is the advantage over our existing docker images? They also have the toolchain in a container. And if there is an advantage, should we use these instead?

@Frenzie
Copy link
Member

Frenzie commented Jan 26, 2024

I also don't have much container experience/interest, but what is the advantage over our existing docker images? They also have the toolchain in a container. And if there is an advantage, should we use these instead?

The way I interpret this is for using the tc outside of KOReader development… although realistically I'd say they don't have all that much extra baggage compared to what you'd stick in a generic development image anyway, give or take some extra LuaRocks stuff. build-essential, git, autoconf, etc., you want those anyway.

And if there is an advantage, should we use these instead?

There could potentially be an advantage to using something like as a base layer instead of compiling them in as an additional layer, but I'm inclined to think it's a difference without distinction.

@jessicarod7
Copy link
Contributor Author

Mainly to make it easier to use on Windows and Mac, where running the toolchain is a bit harder.

That somewhat ties in with my other question relating to the full images which include everything including the tc.

@Frenzie I had noticed that warning at the bottom about needing to use the crosstool-ng suggestions for macOS, and more challenges on Windows. Especially with the switch to Apple Silicon, I figured having the container with the necessary components would be simpler for users than setting up a VM.

Anyway, did you want to rebase it into a few tidier commits or shall I just squash it all?

Yeah, I can squash the commits. There were a couple permissions issues I realized weren't working properly so I just adjusted those last night.

The way I interpret this is for using the tc outside of KOReader development… although realistically I'd say they don't have all that much extra baggage compared to what you'd stick in a generic development image anyway, give or take some extra LuaRocks stuff. build-essential, git, autoconf, etc., you want those anyway.

This was my main inspiration, I was experimenting with cross-compiling for my Kobo. I was using Fedora so the largest difference was package names, and I put this together to make the process easier for myself.

The container also includes build-essentials and the other dependencies, so they're still available for the user (plus root access if additional packages are needed).

And if there is an advantage, should we use these instead?

There could potentially be an advantage to using something like as a base layer instead of compiling them in as an additional layer, but I'm inclined to think it's a difference without distinction.

I'm not familiar with the KOReader development process, but I don't think it would be a significant benefit there. There are some odd configs I've had to make (like entrypoint.sh) which work well enough for interactive use but would probably break in a CI.

@Frenzie
Copy link
Member

Frenzie commented Jan 26, 2024

Okay, but the point is https://github.com/koreader/virdevenv already exists and this is redundant. ;-)

@Frenzie
Copy link
Member

Frenzie commented Jan 26, 2024

@Frenzie I had noticed that warning at the bottom about needing to use the crosstool-ng suggestions for macOS, and more challenges on Windows. Especially with the switch to Apple Silicon, I figured having the container with the necessary components would be simpler for users than setting up a VM.

That is, this can be solved by a minor adjustment to that text down there. And Docker is a VM on Mac and Windows.

@Frenzie Frenzie merged commit 9ea3265 into koreader:master Jan 27, 2024
0 of 9 checks passed
@Frenzie
Copy link
Member

Frenzie commented Jan 27, 2024

@cam-rod I think they're being OOM-killed maybe?
https://github.com/koreader/koxtoolchain/actions/runs/7679060826/job/20929563935

@jessicarod7
Copy link
Contributor Author

Okay, but the point is https://github.com/koreader/virdevenv already exists and this is redundant. ;-)

That is, this can be solved by a minor adjustment to that text down there. And Docker is a VM on Mac and Windows.

Ah, I wasn't aware of that repo, thanks for pointing it out. If it makes more sense, I can add a couple notes pointing people to the other repo and how to use it for cross-compiling other apps.

@cam-rod I think they're being OOM-killed maybe? https://github.com/koreader/koxtoolchain/actions/runs/7679060826/job/20929563935

Actually it seems to be a GCC/C++17 error? Trimmed logs:

2024-01-27T14:03:52.4348862Z [ERROR]    /home/runner/work/koxtoolchain/koxtoolchain/build/nickel/.build/arm-nickel-linux-gnueabihf/src/gcc/gcc/reload1.c:89:24: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
2024-01-27T14:03:52.6724405Z [ERROR]    make[2]: *** [Makefile:1061: reload1.o] Error 1
2024-01-27T14:03:52.6725590Z [ERROR]    make[2]: *** Waiting for unfinished jobs....
2024-01-27T14:03:54.1655900Z [ERROR]    make[1]: *** [Makefile:3952: all-gcc] Error 2
2024-01-27T14:03:54.1699251Z [ERROR]  >>
2024-01-27T14:03:54.1710790Z [ERROR]  >>  Build failed in step 'Installing pass-1 core C gcc compiler'
2024-01-27T14:03:54.1721427Z [ERROR]  >>        called in step '(top-level)'
2024-01-27T14:03:54.1731674Z [ERROR]  >>
2024-01-27T14:03:54.1743237Z [ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@376]
2024-01-27T14:03:54.1754273Z [ERROR]  >>        called from: do_gcc_core_backend[scripts/build/cc/gcc.sh@745]
2024-01-27T14:03:54.1765815Z [ERROR]  >>        called from: do_cc_core_pass_1[scripts/build/cc/gcc.sh@209]
2024-01-27T14:03:54.1777071Z [ERROR]  >>        called from: main[scripts/crosstool-NG.sh@707]
2024-01-27T14:03:54.1799110Z [ERROR]  >>
2024-01-27T14:03:54.1813023Z [ERROR]  >>  For more info on this error, look at the file: 'build.log'
2024-01-27T14:03:54.1825421Z [ERROR]  >>  There is a list of known issues, some with workarounds, in:
2024-01-27T14:03:54.1838517Z [ERROR]  >>      https://crosstool-ng.github.io/docs/known-issues/
2024-01-27T14:03:54.1851510Z [ERROR]  >>
2024-01-27T14:03:54.1864793Z [ERROR]  >> NOTE: Your configuration includes features marked EXPERIMENTAL.
2024-01-27T14:03:54.1877909Z [ERROR]  >> Before submitting a bug report, try to reproduce it without enabling
2024-01-27T14:03:54.1891275Z [ERROR]  >> any experimental features. Otherwise, you'll need to debug it
2024-01-27T14:03:54.1904460Z [ERROR]  >> and present an explanation why it is a bug in crosstool-NG - or
2024-01-27T14:03:54.1916604Z [ERROR]  >> preferably, a fix.
2024-01-27T14:03:54.1929460Z [ERROR]  >>
2024-01-27T14:03:54.1942424Z [ERROR]  >>  If you feel this is a bug in crosstool-NG, report it at:
2024-01-27T14:03:54.1955465Z [ERROR]  >>      https://github.com/crosstool-ng/crosstool-ng/issues/
2024-01-27T14:03:54.1967525Z [ERROR]  >>
2024-01-27T14:03:54.1980590Z [ERROR]  >>  Make sure your report includes all the information pertinent to this issue.
2024-01-27T14:03:54.1993336Z [ERROR]  >>  Read the bug reporting guidelines here:
2024-01-27T14:03:54.2006924Z [ERROR]  >>      http://crosstool-ng.github.io/support/
2024-01-27T14:03:54.2018679Z [ERROR]  
2024-01-27T14:03:54.2096578Z [ERROR]  (elapsed: 8:30.74)
2024-01-27T14:03:54.2096915Z 
2024-01-27T14:03:54.2116844Z gmake: *** [/home/runner/work/koxtoolchain/koxtoolchain/build/CT_NG_BUILD/bin/ct-ng:261: build] Error 2
2024-01-27T14:03:54.2123800Z [08:32] / 
2024-01-27T14:03:54.2141572Z ##[error]Process completed with exit code 2.
2024-01-27T14:03:54.2227276Z Post job cleanup.
2024-01-27T14:03:54.3273552Z [command]/usr/bin/git version
2024-01-27T14:03:54.3330170Z git version 2.43.0
2024-01-27T14:03:54.3371655Z Temporarily overriding HOME='/home/runner/work/_temp/eff2ff97-5b10-41bd-9298-97dc4ad8f8e2' before making global git config changes
2024-01-27T14:03:54.3372765Z Adding repository directory to the temporary git global config as a safe directory
2024-01-27T14:03:54.3376960Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/koxtoolchain/koxtoolchain
2024-01-27T14:03:54.3420519Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2024-01-27T14:03:54.3464079Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2024-01-27T14:03:54.3716230Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2024-01-27T14:03:54.3750380Z http.https://github.com/.extraheader
2024-01-27T14:03:54.3760213Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2024-01-27T14:03:54.3801253Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2024-01-27T14:03:54.4331492Z Cleaning up orphan processes

It only affects the nickel build - I can also see the failure in my local container build, but gen-tc.sh didn't check the exit code so it failed silently. Crosstool added a flag in 1.26 (crosstool-ng/crosstool-ng#1551) to set the C++ version.

@Frenzie
Copy link
Member

Frenzie commented Jan 28, 2024

Ah, I wasn't aware of that repo, thanks for pointing it out. If it makes more sense, I can add a couple notes pointing people to the other repo and how to use it for cross-compiling other apps.

Ah, well, I'm fine reverting this in favor of a note, probably easier to maintain anyway. But I do appreciate the effort. 👍

@jessicarod7
Copy link
Contributor Author

alright np, I'll open a PR for that when I get the change

@NiLuJe
Copy link
Member

NiLuJe commented Jan 28, 2024

Yeah, the nickel TC is very very finicky ;).

@NiLuJe
Copy link
Member

NiLuJe commented Jan 28, 2024

And there are already containerized variants of it

Frenzie added a commit that referenced this pull request May 14, 2024
Frenzie added a commit that referenced this pull request Oct 9, 2024
Frenzie added a commit that referenced this pull request Oct 9, 2024
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.

4 participants