-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
luajit: fix cross build for 32 bit architectures #212760
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,15 @@ let | |
++ optional enableVMAssertions "-DLUAJIT_USE_ASSERT" | ||
++ optional deterministicStringIds "-DLUAJIT_SECURITY_STRID=0" | ||
; | ||
|
||
# LuaJIT requires build for 32bit architectures to be build on x86 not x86_64 | ||
# TODO support also other build architectures. The ideal way would be to use | ||
# stdenv_32bit but that doesn't work due to host platform mismatch: | ||
# https://github.com/NixOS/nixpkgs/issues/212494 | ||
buildStdenv = if buildPackages.stdenv.isx86_64 && stdenv.is32bit | ||
then buildPackages.pkgsi686Linux.buildPackages.stdenv | ||
else buildPackages.stdenv; | ||
|
||
in | ||
stdenv.mkDerivation rec { | ||
pname = "luajit"; | ||
|
@@ -88,8 +97,7 @@ stdenv.mkDerivation rec { | |
"PREFIX=$(out)" | ||
"DEFAULT_CC=cc" | ||
"CROSS=${stdenv.cc.targetPrefix}" | ||
# TODO: when pointer size differs, we would need e.g. -m32 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The note should be preserved, this special casing only works x86_64. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Except that this comment is almost only just for x86 because that is not some universal option. The only other applicable (also directly supported by nixpkgs) I found is PowerPC. Nixpkgs provides, in general, only a single target compilers. That is why $ nix shell nixpkgs#pkgsCross.aarch64-multiplatform.stdenv.cc -c aarch64-unknown-linux-gnu-gcc -E -march=help -xc /dev/null
...
cc1: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a
$ nix shell nixpkgs#pkgsCross.aarch64-multiplatform.stdenv_32bit.cc
error: Multilib aarch64-unknown-linux-gnu-stage-final-gcc-wrapper-9.5.0 not supported for ‘aarch64-linux’
(use '--show-trace' to show detailed location information) I am going to add The best practice here would be to use |
||
"HOST_CC=${buildPackages.stdenv.cc}/bin/cc" | ||
"HOST_CC=${buildStdenv.cc}/bin/cc" | ||
] ++ lib.optional enableJITDebugModule "INSTALL_LJLIBD=$(INSTALL_LMOD)"; | ||
enableParallelBuilding = true; | ||
NIX_CFLAGS_COMPILE = XCFLAGS; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this looks good, I wonder if there is a more universal solution that works on other crosses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I consider the luajit approach of requiring the bitness of the build host to match the build system pretty stupid. It is also the only package I know about that requires it (..although I have not looked for it. It is just from my practice with maintaining packages for OpenWrt.).
I am also afraid that this can't be easily achieved on other platforms. Only some CPUs have the ability to run 32-bit code alongside 64-bit. It is standard on x86_64 but not necessary on ARM or RISC-V (I think that one of the examples is Apple's chips).
I should have added a comment there that it is a speciality of luajit, not some common approach.