-
Notifications
You must be signed in to change notification settings - Fork 0
WIP: Write a CMakeLists.txt to build the NaCl loader #2
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
base: master
Are you sure you want to change the base?
Conversation
2775579
to
993144e
Compare
Is it really so bad to use Scons? Unlike CMake, it can handle multiple toolchains, which makes it well-suited for this repo. Also if we keep the same build system, we can easily compare things between our version and upstream. |
Yes. 😅️
Uh, totally not. The Scons scripts are not compatible with cross-compiling to begin with. First purpose of this effort is to make possible to use multiple toolchains. |
Wrong. With Chromium |
How do I build with MinGW for Windows on Linux? For Linux Arm? How do I make a static This scons stuff is over-convoluted… |
With this exact command I get that:
I have |
Found some documentation: https://github.com/DaemonEngine/native_client/blob/master/docs/build_systems.md. Although cross-architecture builds are supported, cross-OS builds are not. And you can't build with MinGW at all as it is designed for the MSVC toolchain. It seems building with MinGW would imply a porting effort beyond just the build system, as there is, e.g., a Microsoft assembler file. The lack of cross-OS support would seem to be a limitation of Native Client though, not a limitation of Scons.
I posted that in the previous message.
You're getting an error finding a PNaCl toolchain, which should have been downloaded by |
Why do I need a PNaCl toolchain to build an Arm
Yes, all that scons code in the repository is not meant for cross-compilation, that's what I meant.
Very annoying… I have seen they also have some Cygwin code, so I wonder if that can be used on MinGW, I haven't looked at this deeply though. |
Sorry, the output of
|
This can already build |
This can now rebuild |
This can now rebuild |
This can now rebuild |
This can now rebuild |
02ffbba
to
b588d34
Compare
7b597e6
to
11988ff
Compare
21e0ec0
to
49d6042
Compare
So, now, when the compiler is not a Clang-derivative, it build the |
So, it looks like the
|
Now, what's remaining on the list of things I would like to see being implemented is to get a 16k PageSize |
8bf5231
to
37a91b9
Compare
So, I found a way to build a
But the
|
fd5719a
to
555055d
Compare
So, I found a way to build
I have not tested it though, and I wonder if the armhf nexe also have to be built with a 16K PageSize too. |
To run on 16K PageSize kernel, it looks like we would also need to rebuild the nexe as well:
|
The nexe is loaded by sel_ldr, not the system executable loader right? So maybe its "page size" doesn't matter, or maybe the code of sel_ldr has to be changed. Hard to speculate since I don't understand the concept of page size of an executable. |
As far as I know, this is related to the kernel, not the executable loader. Systems like Box64 or FEX-Emu to run amd64/i686 binaries on arm64 are required to do some translation on the binaries (not just for the architecture, but for the page size itself). Wine cannot run them out of the box for the same reason, even with an amd64 translator. To run 4k binaries on a 16k kernel, the current solution is to run a 4k secondary kernel in a microvm using some pass-through techniques for input and graphics: https://asahilinux.org/2024/10/aaa-gaming-on-asahi-linux I assume the NaCl virtual machine is not low-level enough to emulate a kernel interface, it would be surprising. |
https://tristanxr.com/post/why-16k-page-size/ has more details on Asahi Linux's experiences with page size portability issues. It says that most Linux programs work without issues. The ones with problems are ones that manage their own memory mappings somehow, e.g. using a custom allocator instead of libc's. In the thing about Windows games you linked, the problem is probably with the Windows memory allocator or some other part of the Windows runtime. The problem is surely not with executable alignment: given that you are translating to a different ISA, you can lay out the translated instructions however you want. So I don't think the section alignments in the program header really matter for 16k page compatibility. As a last bit of evidence, I tried setting a binary's executable section's alignment to 1, and it still worked. I do very much expect that sel_ldr is a program that manages its own memory mappings. Firstly, I believe that it maps the nexe into memory itself, rather than using the kernel's executable loading. Secondly, The NaCl sandbox model specifies a specific range of memory that the untrusted code is allowed to read/write access. All memory allocations by untrusted code must go in this range and all allocations by trusted code outside it. If there is an NaCl syscall for mapping more memory pages, we should check whether the page size is a hard-coded number, baked in at compile time from a system header, or queried at runtime. Note that if you read the nexe program header dump closely, the alignment is not 4k, but 64k. So no problem even if it somehow mattered. |
2dc28fc
to
a5ae566
Compare
The It works on Even when building with debug symbols, I cannot debug the tool:
|
a8436ab
to
961bfa0
Compare
The inability to build a working When running on a debugger, It fails at the empty line preceding the assembly startup code (outside of any code block). When building with GCC 8 instead of GCC 13, it works. I also noticed that building it with optimization enabled whatever the GCC version tested introduces other bugs. Disabling optimization ( I'll make a bug report to GCC at some point, with some reduced source sample. |
I added some
CMakeLists.tx
code to rebuildsel_ldr
andnacl_helper_bootstrap
.This relies on some unified
DaemonPlatform
framework copied from DaemonEngine/Daemon#1641 on purpose to give this CMake code the same easiness at doing cross-compiled builds.I need help to complete the
src/trusted/service_runtime/CMakeLists.txt
file.The
CMakeLists.txt
files are a rewrite of the fileSConstruct
and*.scons
files with all unit tests deleted. Remaining unported code is commented out with lines starting with#TODO:
.Build status:
sel_ldr
nacl_helper_bootstrap
helloworld
nexeDynamically linked loader:
sel_ldr
helloworld
nexeStatically linked loader:
sel_ldr
helloworld
nexeThings like
linux-mips
were tested only because I ported the SCons code to CMake for completeness and make sure I forgot nothing.I tested
android-armel
because I remember that in the past @cu-kai tried to getdaemon-tty
running on Android to get a console for his server.