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

Problem: how to customize linux kernel version and gcc version when compile a musl tool chain #123

Open
newthis opened this issue Apr 21, 2021 · 3 comments

Comments

@newthis
Copy link

newthis commented Apr 21, 2021

Hi, I meet the problem of compiling a musl cross compile tool chain for linux 4.1.17 and gcc 5, the new linux version is not fit for me. So I want to know how to change the compile script to include linux 4.1.17 and gcc 5 for musl.

@richfelker
Copy link
Owner

richfelker commented Apr 21, 2021

The Linux version here has nothing to do with the kernel version you intend to run. It's just the one to pull headers from, if you want your output toolchain to install Linux kernel headers (non-essential, but some important things folks tend to want to compile, like busybox, depend on having them). Versions earlier than the earliest version mcm still supports are not compatible with musl - they have both incompatibility with time_t/timeval/timespec not matching the kernel definition (affects all 32-bit archs now) and don't have all the needed __UAPI_* control macros to prevent the kernel headers from making declarations that conflict with the libc ones. There is nothing wrong with using these headers and running the software you build on a much older kernel, even back to 2.6.x.

As for GCC, 5.3.0 is still one of the versions we provide patches for, and it should just work. If you hit problems with it, please report them.

@test164c
Copy link

test164c commented Jun 3, 2021

Hi, I am facing a similar issue. Also trying to compile a cross-compiler for Linux kernel v4.1. In the Linux kernel source v4.1 include/linux folder, there are only gcc headers up to compiler-gcc5.h.

However, when the musl-cross-make cross compiler makes a call to compiler-gcc.h, it attempts to include config-gcc9.h, which doesn't exist in the include/linux folder of v4.1 source code. I have tried changing the gcc version in config.mak to 5.2.0 but the resulting cross-compile binary (the gcc itself) was the same (same md5sum) and still demanded compiler-gcc9.h. From my understanding, the gcc version in config.mak is the gcc version used to compile the toolchain, which in this case doesn't affect the output toolchain.

For now, I made an empty file named compiler-gcc9.h, but I am not sure if there will be issues later. Is there a way I can get musl-cross-make to use gcc5 and include compile-gcc5.h? Thank you!

@richfelker
Copy link
Owner

This was a known bug in Linux from that era, that it was not future-proof against compiling with GCC newer than the newest it knew about at the time. In case it has bugs (UB) that don't compile correctly with newer compilers, it might make sense to build it with an older one, but you can also just copy compiler-gcc5.h to compiler-gcc9.h and it should work. Making an empty file will not work.

. I have tried changing the gcc version in config.mak to 5.2.0 but the resulting cross-compile binary (the gcc itself) was the same (same md5sum) and still demanded compiler-gcc9.h

This sounds like you did not actually rebuild. If you change the config variables you should remove the directory the build was in and restart from scratch, or manually set a different BUILD_DIR for the different version.

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

No branches or pull requests

3 participants