You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After we removed cross-endian bytecode support in #1412, I tested native builds with Docker (s930x) and looks like native BE is currently broken, due to the bytecode checksum?
I know there is reluctance to taking the “defining the endianness of the bytecode format as little-endian and handling for big-endian targets” approach (as @chqrlie mentioned in option 1 here). I do think it’s a shame, although I understand the maintainability concern.
For some background: we cross-compile an open source game that embeds QuickJS for a number of scenarios. Fortunately, and perhaps expectedly, all of our current cross-compilation scenarios are little-endian hosts and little-endian targets. However I do want to raise some general concerns:
Even if cross-compiling between different-endian architectures is officially not supported going forward, I’d hope that general cross-compiling continues to be considered a fully supported scenario.
We do have some people compiling our project for big-endian architectures, and thus we want to ensure that there isn’t any sort of undetected-at-compile-time failure here due to using the pre-generated codegen files in this scenario.
Right now, it appears as though codegen only happens if using the make codegen command (?), and not as part of the CMake or Meson buildsystems. At a minimum, assuming the decision remains to not support cross-endian compilation, I think that compilation of targets including pre-compiled bytecode should fail if the pre-compiled bytecode files do not match the target endianness.
However, what about the scenario where the QuickJS compiler executable, which is required to generate the pre-compiled bytecode, itself increasingly relies on pre-compiled bytecode?
Even if cross-compiling between different-endian architectures is officially not supported going forward, I’d hope that general cross-compiling continues to be considered a fully supported scenario.
Yes, nothing has changed there. Bytecode is not host dependent, but it is endian dependent.
2. We do have some people compiling our project for big-endian architectures, and thus we want to ensure that there isn’t any sort of undetected-at-compile-time failure here due to using the pre-generated codegen files in this scenario.
You'd have a problem there. You'd need to regenerate the codegen for BE.
Right now, it appears as though codegen only happens if using the make codegen command (?), and not as part of the CMake or Meson buildsystems. At a minimum, assuming the decision remains to not support cross-endian compilation, I think that compilation of targets including pre-compiled bytecode should fail if the pre-compiled bytecode files do not match the target endianness.
Not sure how we'd do that at compile time. Any ideas?
However, what about the scenario where the QuickJS compiler executable, which is required to generate the pre-compiled bytecode, itself increasingly relies on pre-compiled bytecode?
It doesn't and likely won't, otherwise we'd have a bootstrapping issue regardless of endianness, since bytecode versions are not compatible.
Not sure how we'd do that at compile time. Any ideas?
If what is meant are official releases, then it is trivial, since endianness of included bytecode is known. The same would apply to packaging by downstream distributions. Are there any scenarios where inputs are unknown?
Not sure how we'd do that at compile time. Any ideas?
If what is meant are official releases, then it is trivial, since endianness of included bytecode is known. The same would apply to packaging by downstream distributions. Are there any scenarios where inputs are unknown?
I don't think so.
Btw master now properly works on BE. You need to run make codegen before make to have the bytecode regenerated and that's it.
How to build it correctly? I cannot require quickjs-ng to build quickjs-ng, obviously, though it is possible in principle to have a bootstrap port. But then, bootstrap port will need to be pegged to some old version which can be compiled without running codegen. And perhaps eventually it will not be able to generate current sources.
Or do I get this wrong?
Also, it will be nice – though not necessary – to have the thing working with CMake directly.
Thanks. Does something prevent adding this into CMake logic, conditional on platform being BE? I.e. so that nothing changes for LE, but on BE direct build without manual steps works correctly?
Activity
saghul commentedon Mar 21, 2026
@barracuda156 FYI.
Fix native Big Endian build
past-due commentedon Mar 21, 2026
My two cents:
I know there is reluctance to taking the “defining the endianness of the bytecode format as little-endian and handling for big-endian targets” approach (as @chqrlie mentioned in option 1 here). I do think it’s a shame, although I understand the maintainability concern.
For some background: we cross-compile an open source game that embeds QuickJS for a number of scenarios. Fortunately, and perhaps expectedly, all of our current cross-compilation scenarios are little-endian hosts and little-endian targets. However I do want to raise some general concerns:
Even if cross-compiling between different-endian architectures is officially not supported going forward, I’d hope that general cross-compiling continues to be considered a fully supported scenario.
We do have some people compiling our project for big-endian architectures, and thus we want to ensure that there isn’t any sort of undetected-at-compile-time failure here due to using the pre-generated codegen files in this scenario.
Right now, it appears as though codegen only happens if using the make codegen command (?), and not as part of the CMake or Meson buildsystems. At a minimum, assuming the decision remains to not support cross-endian compilation, I think that compilation of targets including pre-compiled bytecode should fail if the pre-compiled bytecode files do not match the target endianness.
However, what about the scenario where the QuickJS compiler executable, which is required to generate the pre-compiled bytecode, itself increasingly relies on pre-compiled bytecode?
saghul commentedon Mar 21, 2026
Yes, nothing has changed there. Bytecode is not host dependent, but it is endian dependent.
You'd have a problem there. You'd need to regenerate the codegen for BE.
Not sure how we'd do that at compile time. Any ideas?
It doesn't and likely won't, otherwise we'd have a bootstrapping issue regardless of endianness, since bytecode versions are not compatible.
barracuda156 commentedon Mar 21, 2026
If what is meant are official releases, then it is trivial, since endianness of included bytecode is known. The same would apply to packaging by downstream distributions. Are there any scenarios where inputs are unknown?
Fix native Big Endian build
saghul commentedon Mar 21, 2026
I don't think so.
Btw master now properly works on BE. You need to run make codegen before make to have the bytecode regenerated and that's it.
barracuda156 commentedon Mar 22, 2026
Great, thank you
barracuda156 commentedon Jun 13, 2026
@saghul I was going to update to the latest release, and now got a question: does
codegentarget depend onquickjsitself?quickjs/Makefile
Lines 76 to 85 in 66adc82
How to build it correctly? I cannot require
quickjs-ngto buildquickjs-ng, obviously, though it is possible in principle to have a bootstrap port. But then, bootstrap port will need to be pegged to some old version which can be compiled without runningcodegen. And perhaps eventually it will not be able to generate current sources.Or do I get this wrong?
Also, it will be nice – though not necessary – to have the thing working with CMake directly.
barracuda156 commentedon Jun 13, 2026
Upd. I guess
codegencan be inserted after buildingquickjscmanually, and before buildingquickjs.saghul commentedon Jun 13, 2026
Yep codegen just needs the compiler, which uses the engine, but doesn't depend on generated bytecode itself.
barracuda156 commentedon Jun 13, 2026
Thanks. Does something prevent adding this into CMake logic, conditional on platform being BE? I.e. so that nothing changes for LE, but on BE direct build without manual steps works correctly?
saghul commentedon Jun 13, 2026
I'd review a PR, but last I tried it made things too complex for cross compiling, for example.