Hi, I want to cross-build the
audit package on macos (aarch64-darwin). Currently, cross-compilation from macos to linux systems is somewhat broken but there is already a proposed fix in `pkgsCross.aarch64-multiplatform.gcc` is broken on `aarch64-darwin` · Issue #137877 · NixOS/nixpkgs · GitHub which I based my work on.
Just trying to cross-build the package obviously does not work because
darwin is not listed as one of the supported build platforms. So I tried to add it which does not work out-of-the-box. The difficulty lies in the fact that the build process generates some source files at build time, using quite linux-specific stuff. So the build process builds and runs small C programs on the build platform with linux-specific requirements:
- the linux headers are missing, so I added
preBuildhook (which already feels a bit too hacky)
sys/personality.his not found which is present in glibc’s headers so I additionally added
- the compilation fails at
__attribute_pure__attributes which are gcc-specific, so I changed the
After these steps the first C program seems to compile but linking fails because
___assert_fail is undefined. I could imagine that there are more hacks possible to workaround this, too, but I am starting to ask myself if this is just not supposed to work. On the other hand, nix’s cross-compilation support is already great, so it would be nice if another package could successfully be cross-compiled. And there are other packages which require patches to be successfully built, too.
What do you think? Should I stop my journey here because this is something which just should not be supported because such linux-specific stuff should not be done on darwin? Or would it be worth to find a solution to this? If so, what would be your recommendations to keep the workarounds and hacks to a minimum?