Conversation
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
|
relates to #8350 |
|
Thank you for signing the OCA. |
|
@sgammon thank you for this very interesting PR. We’re currently investigating whether merging it is feasible and practical. As far as I can tell, adding Cosmopolitan support in NI depends on changes in other projects that we don’t control. Is Justine Tunney willing to integrate your Cosmo changes as-is? From what I see, these are largely stub implementations of C library functionality that Cosmo is currently missing, but that LabsJDK (and the NI build) depends on at build time. Ideally, there would be an official Cosmopolitan release that includes your changes, which we could then build on. Regarding the LabsJDK changes, I have another concern: they further increase our delta to OpenJDK and therefore increase our maintenance effort. Would you be willing to minimize these changes as much as possible and help resolve any merge conflicts that might arise in the future? Also, could you elaborate on the need for the AArch64-specific register changes that Cosmo seems to require? Where can I read more about the rationale behind those changes? Finally, if we integrate Cosmo support, we’ll likely need a setup to safeguard against regressions—e.g., a GitHub Actions–based CI job would be appreciated. |
At the moment, the Cosmo changes are just headers and stubs for well known functions, so I would hope yes. I've submitted a PR here: jart/cosmopolitan#1474
The labs JDK changes as far as I remember are mostly just
on
We have example CI actions here. I think in terms of CI we'd just need an action that creates |
Sounds like we could possibly make this the default for all aarch64 images (not just cosmo). @lewurm do you agree? |
We have a tendency to choose the same register assignment as HotSpot to ease sharing of e.g. LIR instructions. After a quick look I don't see an unclean usages of the thread registers however, so it should be fine (and if not, it's certainly fixable).
I'm confused about that (context elide-dev/labs-openjdk@7042bab ): Do you need to change it so that you can build |
|
Thanks for graalvm/labs-openjdk#28 I left my comments: graalvm/labs-openjdk#28 (comment) |
|
@ahgamut regarding
I was able to do that. But how to proceed from here? I see that now the
I need more detailed instructions than what you provide in top comment #12865 (comment).
|
Sent a ping on the Cosmo PR jart/cosmopolitan#1474 (comment) |
Using and gives me In other words, how does this work in detail? See #12865 (comment) |
set options when cosmo is provided
- use r25 as the thread register for aarch64 - cosmo has -ffixed-x18 and -ffixed-x28 on aarch64 - (remember to patch jdkvm.ci in labs JDK ot use r25) - disable vaddr calculations and call fixupobj
we create equivalent files for a whole bunch of headers in com.oracle.svm.core.posix within a subpackage cosmo. basically every feature that involves checking for linux/posix is copied into cosmo, and a BooleanSupplier ensures the Cosmo versions are chosen only when --libc=cosmo is provided. there might be issues where a class is subclassed from core.posix.foo rather than core.posix.cosmo.foo.
perhaps equivalent translation can be within cosmo
questionable casting for mcontext_t and sa_flags
the IsWindows() checks are rather annoying to deal with outside, plus there were segfaults occurring due to memory corruption, so we moved some of the functions needed by VirtualMemoryProvider inside for closer examination. and use the ImageHeapProvider without mremap for now
the option: available as a string in SubstrateOptions, with a pair of concealed options. the individual integers can probably be part of GraalOptions, but the value checking happens in SubstrateOptions. we might also need to check wherever we are using these things. at compile time: All NOPs are added before emitting LIR to a CompilationResult. The before/after is handled by adding an offset to the function entry when the object file is laid out (this might cause an issue around trampolines), and during patchMethods when fixing rip-relative calls. at runtime: the offset due to the nops is subtracted via ImageCodeInfo.nopsBeforeEntry when the image info is loaded, so that runtime relativeIP checks work out ok. the subtraction is done with CodeInfoAccess, but not UntetheredCodeInfoAccess, which may cause issues later.
itimerspec/sigevent are stubbed anyway, so we can add them back in a later commit once the implementations have been tested in detail.
|
Updated the commits to avoid merge conflicts. When opening this PR, I provided a repo containing all scripts and Github Actions used to build example binaries (the Both example binaries appear to run without error even after the latest rebase here and here. I will re-run the actions in a while to confirm. |
|
@olpaw I have described more details of the build steps below.
this comment mentions cosmocc can be built using the above branch. However, I found building the labs JDK required some additional headers and static libraries (at least
Relevant scripts:
After collecting I provide some additional arguments at the configuration stage (notably Relevant scripts: Note A detail I failed to mention earlier that is provided in the repo: static libraries within Relevant scripts:
If I understand correctly, this step currently does not require cosmocc or any of the previous build artifacts. When writing the patch I used Relevant scripts:
Once For now, the Relevant scripts: |
|
Thanks for the updates. I will look into it in the next days (hopefully). |
|
Thanks for the info in #12865 (comment). I'm now able to successfully build the static libs with cosmocc. Next step, using these artifacts for review and test this PR. |
This patch adds support to build
native-imagebinaries with Cosmopolitan Libc. More specifically:CosmoLibCadded as a subclass ofLibCBase--libc=cosmoadded toSubstrateOptionslibchelperBooleanSupplierclasses to check for libc usage-fpatchable-function-entryflag (as ingcc/clang) to support debuggingThis enables building binaries with
native-imagethat can be converted to Actually Portable Executables.cosmocccompiler suite with this patch of Cosmopolitan Libcmake static-libs-imageusing this patch of labs JDKnative-imageas usual with this patch on the host systemnative-imagewith--libc=cosmoand provide necessary flags to build binariesExample build recipes for Github Actions are given here.