mold icon indicating copy to clipboard operation
mold copied to clipboard

platform: Add basic support for Haiku

Open kallisti5 opened this issue 2 years ago • 9 comments

kallisti5 avatar Feb 27 '22 23:02 kallisti5

Still a WIP given the last error below:

  • Mold changes were pretty simple
  • tbb fixes might be misplaced.. anywhere to upstream?
  • getting "Could not resolve symbol 'scalable_malloc'" from mold on execution. Seems tbb related?

kallisti5 avatar Feb 27 '22 23:02 kallisti5

Here is the upstream repo of TBB. Your changes to third-party/tbb should be made here. https://github.com/oneapi-src/oneTBB

scalable_malloc seems to be related to TBB. TBB provides its own implementation of malloc, and that is scalable_malloc. I don't know why mold tries to resolve that function at runtime on Haiku, though.

rui314 avatar Feb 28 '22 03:02 rui314

scalable_malloc seems to be related to TBB. TBB provides its own implementation of malloc, and that is scalable_malloc. I don't know why mold tries to resolve that function at runtime on Haiku, though.

scalable_malloc is a weak symbol by TBB. It seems odd they chose that

kallisti5 avatar Feb 28 '22 13:02 kallisti5

I got those scalable_malloc errors on SerenityOS untill I added this patch:

https://github.com/SerenityOS/serenity/blob/master/Ports/mold/patches/0003-Tell-TBB-that-SerenityOS-does-not-support-weak-symbo.patch

Defining away weak symbol usage in tbb made the linker stop putting unresolved weak symbol references to "scalable_malloc" into the binary. But I would also expect it to use "malloc" as the actual final symbol name 🤷‍♂️

ADKaster avatar Feb 28 '22 15:02 ADKaster

I will update the in-tree TBB copy at some point in the future, and I can't maintain a local patch to TBB for Haiku, so please upstream that patch. We can only accept a local patch as a temporary measure.

rui314 avatar Feb 28 '22 21:02 rui314

@rui314 sounds good. I can definitely upstream. I can confirm the patch @ADKaster mentioned (adjusted for Haiku) fixed the final issue.

mold

kallisti5 avatar Feb 28 '22 21:02 kallisti5

Ok. I dropped the tbb changes from this patchset.

It should be applicable on mold without any impact to other platforms. I'll work on up-streaming the tbb changes to the repo mentioned.

kallisti5 avatar Feb 28 '22 21:02 kallisti5

This patch LGTM, but let me wait until an upstream patch is accepted by the TBB folks. It shouldn't take too long. (I sent a patch to TBB to support the musl libc, and I didn't take too long.)

rui314 avatar Feb 28 '22 21:02 rui314

My current Mold patches for Haiku: https://github.com/X547/mold/commit/ccbadabd1d1596da406a81396426ee58ddfab42d.

X547 avatar Jul 09 '22 05:07 X547