musl-cross-make
musl-cross-make copied to clipboard
Problem: how to customize linux kernel version and gcc version when compile a musl tool chain
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.
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.
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!
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.