Port pony to Haiku - #5358
Conversation
|
I will tell you that there are BeOS fans among the ponyc maintainers ;) I found inspiration in https://www.haiku-os.org/legacy-docs/bebook/TheInterfaceKit_Overview_Introduction.html |
|
Hi. Thanks for taking this on. I haven't looked at all. Some general comments. I have a couple of large changes coming that I would want to land before these and would then ask you to incorporate and update again. We need to talk about if we want to take this on as platform we support in the codebase. I love BeOS dearly. I learned to "really C++" on it. You will find my name in the old BeOS newsletter. But I am hesitant. I'd like to see things like: ifdef haiku then
// Workaround haiku bug with parsing "nan(123)": https://dev.haiku-os.org/ticket/20092
if (errno == 0) and (endp == ptr.offset(_size - 1)) and (this.at_offset(_size.isize() - 1)? == 0x29) then
resaddressed upstream and not carry the cost of this in the codebase if we were to accept it. I notice there are at least a few such things. Linking would need to be made to work with the new embedded linker that we are moving all platforms to before merging. I'm not going to take on doing that work on Haiku. It would need to be done before merging. All the Linuxes, MacOS, and Windows currently use it. The BSDs have yet to be ported over. I note that there are comment like "under pressure example consistently crashes". This and other issues would need to be resolved before merging. Lastly, it would need a tier 3 CI job like what OpenBSD, FreeBSD, and DragonFly have. Before you undertake any work related to the above, I'd suggest waiting for our decision if we would want to take this on to maintain long term. |
Sylvan was also a BeOS developer. Both of us were. |
|
Thanks for checking and answering :).
Great! BeOS was my favorite OS, unfortunately i learned about it only around BeOS R5 PE, so not long before the end. But i was lucky enough to use it as my one and only OS for a few years, before i had to change hardware :).
Even better :D! Thanks!
Sure, i already saw change about strtof/d, so the ugly workaround i did was mainly to pass the tests and i did plan to remove it eventually. I guess it would be better to just ifdef the only two test cases that fail on Haiku? I reported the problem, but i don't think they'll work on this anytime soon. The other workaround is for socket shutdown, and i plan to prepare test case and report it (unless it's just something that i messed up in asio implementation and i'll be able to fix it myself). Two smaller things are in tests:
I was trying to keep changes minimal, so most of it is just adding "or haiku" or "and not haiku" or error/signal constants in places where platform is already checked in code. Two "bigger" chunks of code are in:
I plan to remove custom logging from wfo.c (LOG and LOGLIST stuff). It's suboptimal, it just helped me a lot while implementing asio. I was thinking about adding stuff to runtime tracing, but decided to postpone it, because that could mess with other platforms (either it would be strange that there are functions that only one platform uses, or i would have to implemented it for all of them, some of which i would not have a way to test besides waiting for CI). There is kevent implementation for Haiku, but it's missing some of the stuff used in pony. I wanted to see if i can write Haiku-specific implementation anyway ;). I was also thinking about implementing threading using native threads and ports, but that would require more changes, because pthread* stuff is not contained in a single file. Also messaging could be slower then, because it would need to pass through Haiku kernel then, and AFAIK it's all on pony side now.
Hmm... i could try it, but i never wrote any linking (or compiler, for that matter) code before, so... i would need some pointers regarding what's needed and where, or maybe i'll wait for BSDs and follow their steps? BTW i'm not sure yet about static libs. BeOS and Haiku are all for shared libraries, and i did not have a look yet to see how to make sure pony stuff links dynamically and then generate ponylang package with correct content (to add it to HaikuDepot).
Yes, of course. But under pressure works fine now. Actually nothing crashes AFAIK, except for runtime tracing actor behaviors. Not sure why. It looks like the tracing thread calls a function chain that ends up checking if tracing is enabled and then it crashes. It's kinda similar to how timers were crashing, only there thread ctx (like on Windows) was needed, and it looked like thread local variable access was crashing. My guess is that, it's because it's Haiku's thread that calls timer function. Once i changed it to just "ping" asio thread, which in turn sends event, timers started working ok 100% of time.
Yeah, that's why i was already thinking about how to implement that.
OK, thanks for at least considering it anyway. I know Haiku is way smaller in popularity than other platforms, and i understand well that maintaining project takes precious time. So, if it means too much of a burden for pony team (for now?), i can keep fork updated from time to time and maybe you can reconsider merging in the future :). |
|
I'm completely ok if we decide to move forward with Haiku support of treating it as a real option and leaning into its own APIs rather than doing things like riding on a kqueue compatibility layer. So long as those Haiku APIs dont bring an oversized burden for their relative merit. Just had to caveat that. If we take on Haiku, we should take on Haiku.
I'm not sure where this would fall on the line I put above. I would encourage doing a rough and dirty spike for what it would look like to get early feedback before investing a ton of time. That would probably be the answer with everything "like this". "Can you show us what it might look like and we can tell you how likely we would be to accept?" I really feel bad when people put a lot of work into something and then we reject it. I'd much rather they talk with us early on and rejections come with much less effort that won't get merged (I dont want to say the effort is wasted as people often learn a ton in the process). Re the linking: you dont need to write linker. You "just" need to use the embedded LLD linker like the MacOS, Windows, and Linux versions are. Basically, instead of calling out to an external linker, you call into the "lld as a library" that exists in the pony compiler.
And again, thank you for doing this. BeOS is still my favorite OS. I still have 2 early rev BeBoxes and I still check in on Haiku once a year to see if there is any way I could use it as a daily driver. It's a ritual I have been undertaking for at least 10 years and almost assuredly longer. I would model after MacOS on this front as it "doesn't really do static libs". |
Hmm... then maybe i'll try it, after i'm sure everything else is 100% OK. I know that sending a message to native thread/port means it's copied, so i guess i could send pointer to pony message data instead of whole data... anyway, i suspect it will be slower than just passing pointer all on pony side. Still, it could be interesting to see how it would look like anyway.
No worry :). It's on me - i got curious and carried away ;). And i did learn stuff and got reminded about a lot more (i'm not working with C/C++, and never really did professionally, so my knowledge is... spotty and/or rusty).
OK, i'll try that :).
Nice! I'm checking Haiku from time to time too, but less regularly (usually when i'm between work/projects or on holidays) and in meantime i just try to be up to date on the stuff happening there.
OK, thanks! |
|
@ahwayakchih please proceed if you want. our caveat would be. we don't see ourselves supporting haiku going forward but we are happy to take into mainline with all the previous caveats if you are willing to commit to doing ongoing support and if breakages start piling up and you are no longer around, we would almost assuredly remove support. Sound good? |
|
@SeanTAllen that's great! and very fair, thanks! |
|
Hi, I've rebased Haiku port onto latest ponyc source and applied additional changes:
I added |
socket.c seems fine to me. |
c541a43 to
4982bbe
Compare
|
@ahwayakchih i apologize for the fact that the build system is going to change out from underneath you soon. hopefully it won't be painful. |
@SeanTAllen oh well, i'll try to bring it back then :). |
|
@ahwayakchih that is odd with the process tests. they run in an exclusion group so they should be running sequentially no matter what. do they fail when you do --sequential to make sure only 1 test is running at a time? |
|
@ahwayakchih oof. no headless way to install haiku? |
I did try running make test-stdlib-release directly (IIRC, not sure about exact name at the moment) with and without --sequential, also with filtering to run just My wild guess is that maybe Haiku closes and cleans up everything before IO on pony's side handles reading output of child process. AFAIK, OS should not remove anything while something is still reading, but maybe there's a bug somewhere (most probably my code, or maybe something on Haiku's side).
Unfortunately no, not that i know of :(. There was experimental app_server over http, but that would require even more complications to set it up. |
|
@SeanTAllen rpath is supported on Haiku, but software distributed for Haiku does not use it. For building and testing it might be ok, but then it's very inconvenient to remove or modify it later. Leaving build-time environment paths in distributed packages is not tidy. When executables/libraries are packaged and distributed for Haiku, they should not depend on totally custom paths. They should depend on libraries placed in one of the default places (currently there are 4 main, 2 additional for dev/compiler stuff, + "lib" subdirectory next to an executable, but the 6 default ones preferably should not be hardcoded - there's an API to get them, which i used in codegen files) - where Haiku looks for them by default. I wouldn't say that this is an issue with any of the systems. It's more like an issue with where the generated *-additional libraries are stored while tests that depend on them are built and run. Unless there's something else that depends on some custom-path libraries, and i just did not happen to stumble upon it, and that something else is distributed later (but in that case, custom-path libraries should end up in one of the default paths anyway, or in "lib" subdirectory of distributed executables)? Why a few tests should force all generated executables to include rpaths that are very build-time environment specific (and will almost always be incorrect for any other run-time environment)? In general, having somewhat standardized paths for libraries is easier for user to monitor and manage. |
|
@SeanTAllen i think i found the original issue you mentioned: #651. Looks like it was about custom builds, but solution impacts everyone. Maybe there could be an additional option to NOT to add rpath for all paths, e.g., "--no-rpath"? I think it would be better if option was opt-in instead of opt-out, but that would break compatibility. |
|
@ahwayakchih I'm not comfortable with haiku being different here. It will end up being surprising to pony users and maintainers. |
|
@SeanTAllen ok then, i'll change it back so rpath is generated on Haiku too (even though it may be surprising for Haiku users), but then... do you want to keep rpath in distributed executables too (i mean, after i'll add script to create ponyc.pkg for Haiku)? it does not make sense on Haiku, no one will have any libraries in /Data/ponyc/[whatever] (path used in provisioned Haiku VM for building and testing ponyc). |
b5d8ecf to
7fc7ef0
Compare
|
I've modified builder repo and now it builds Pony both for Haiku nightly and recently released r1beta6 version. It also publishes packages, so if you'd like to test how pony works on r1beta6, you don't have to even build it, just download package ready to install: It builds Pony with system installed LLVM instead of statically linked one. I did not include changes to use shared LLVM in this PR, because i suspect you will not want it. But just in case you'd consider it, here's a diff: |
|
@ahwayakchih we dont support using system llvm and won't be doing that. back when we did, chasing down llvm bugs and weird interactions was almost all of our time. its definitely not something we are going to do. so yes, don't want. it was just a massive massive timesink. |
|
@ahwayakchih let me know if/when you are ready for CI to kick off for anything. |
|
@SeanTAllen regarding shared LLVM: i suspected that, since you pin specific version in repo. Thing is, i have similar reasons to avoid building LLVM: it takes very long time and sometimes just stops hanging forever and never finishing (that most probably is a problem with Haiku, not LLVM, but from my point of view result is the same). Locally, i can kill the process, start build again, and sometimes it works in the end, other times i end up with non-working/crashing binaries and have to repeat whole process again. In CI i have to cancel workflow (if i notice this, or wait until GitHub fails it automatically after a very long time) and restart from zero again. I re-enabled building with static LLVM in my repository today and will see what will happen this time. There were two changes in Haiku that might affect it: one regarding io handling, which i did test on nightly and it did not seem to help then, and recently there was a fix for timer handling that mentioned haiku crashing after ~5 hours (which kinda fits to what was happening in CI, although it looks more like freezing then to me) that i did not check yet. Both are in r1beta6 AFAIK, so we'll see... but as of this moment it looks like nightly build is already hanging doing nothing at 27%, while r1beta6 build is at 59% and looks like it's still alive and moving on. LLVM available in HaikuPorts (installable from HaikuDepot applicaiton provided by Haiku) is built with some patches (https://github.com/haikuports/haikuports/blob/f40c16e59aa091c55ad427b54b75f87704c2fea8/sys-devel/llvm/patches/llvm22-22.1.8.patchset) but it looks like they're only for default system paths (which do not matter much, since Pony is instructing LLVM anyway) and adding 32 vs 64 bit build handling (which we do not care about AFAIK, requiring 64 bit anyway). It worked much better a few months ago, so it's something with Haiku changing, or maybe updated LLVM... or both. Anyway, if it keeps happening, this port will have to be dropped :(. |
Thanks, i'll let you know, but i think LLVM builds have to start working again first :(. |
|
So LLVM build for r1beta6 got stuck at
So i guess this PR is on hold, or maybe should be closed and re-opened at some point in future, when LLVM can be built in one go and without issues, like it used to :(. |
|
@ahwayakchih i dont think we need to close. do you want to see what happens with building LLVM here in CI? Probably the same thing, but... maybe not. |
|
@SeanTAllen well, sure we can try, but i wanted to spare you spending time on this :). Especially when i did not actually run workflows prepared for Pony repository. I tried to keep it close to what i used in my "builder" repo, but never actually run it, so there might be errors in there that will fail before it even gets to building anything ;). |
|
I noticed that pr workflow does not include BSDs, so i did not add Haiku there. Which means that PR workflow could be run for this. AFAIK it would check if my changes did not break anything for main platforms, and lint anything i did change. |
|
@ahwayakchih yes. Tier 3 gets run a few times a week and can be manually kicked off as well when needed for given PRs |
|
Some good news: deadlocking problem got fixed in Haiku nightly hrev60080. Static LLVM builds seems fine there now. Unfortunately i don't know when this will get backported to recently released r1beta6. I want to make sure builds are ok for nightly today, and if all goes well, i'll switch workflows in this PR back to using nightly (and then i guess we could try running CI for the PR?). |
|
@ahwayakchih that's awesome news. let me know when you are ready to "try turning it on". |
|
Hi @ahwayakchih, The changelog - added label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do. Release notes are added by creating a uniquely named file in the The basic format of the release notes (using markdown) should be: Thanks. |
|
@SeanTAllen building LLVM works on Haiku nightly, so i switched workflows back to it. I guess you'll prefer to target r1beta6 (or next one) in future, since that's more like a "LTS" release of Haiku, but for now we have to target nightly. Building and testing is in a separate workflow file for now: |
Workarounds to fix at some point in future: - In `packages/net/tcp_connection.pony` there's a workaround for a problem with sockets not being closed at all on Haiku; - Pony on Haiku will incorrectly parse `NaN(123)` cases: In `packages/builtin_test/_test.pony` there's a workaround which passes the test if implementation is still broken on Haiku. When it fails, it will mean Haiku's part was fixed and workaround can be removed. Things not tried: - `LTO`, - building apps with `static` option (which probably will fail, Haiku follows in BeOS footsteps and is all about using shared libraries), - failing fast for some combinations/features like `DTrace` (N/A on Haiku), `pool_classic`, sanitizers. `systematic-testing` was tested long time ago, but not recently. Same for using `runtime-bitcode`.
|
0.71.0 built ok both in static and shared versions for Haiku nightly: It also got through build and test process for Haiku r1beta in shared version. Static version keeps timing out now (so i was very lucky before, when LLVM got built with |
Hi,
This is my attempt to port Pony to Haiku operating system (https://www.haiku-os.org/).
It passes all the tests (but i had to force regression-1118 to use just 2 threads on Haiku, otherwise it times out, and disable error same way as Windows has it disabled), all examples work:
pony-test.log
Runtime tracing works, except for crash when actor behavior category is enabled (i'm attaching crash log, maybe you could help me fix that?):
net-5509-debug-17-05-2026-16-58-34.report.txt.
I did get some crashes with systematic_testing, but i have to retest it yet.
I did not test LTO, pony-lint and pony-lsp (i mean, besides checking if executable works).
pony-doc seems to work too.
libponyc and libponyrt benchmarks work, but they warn about not being able to set thread affinity (but i think that may be because of benchmark library?):
pony-benchmark.txt
If you think this has a chance to be merged, i can try to prepare CI config for running Haiku, but it would have to be a bit... hacky. Haiku is not Linux or BSD, so running it means running QEmu, and building pony requires over 10 GB of space on disk. My idea is to prepare install image, and then separate data disk (qcow) for pony. Disks could be cached between CI runs. First build run would be horribly long (it took over half a day on my laptop ;).