Skip to content

[Support] Add MacOS as a host for ELD - #1818

Open
Dhruv Menon (malto101) wants to merge 7 commits into
qualcomm:mainfrom
malto101:add-macos-support
Open

[Support] Add MacOS as a host for ELD#1818
Dhruv Menon (malto101) wants to merge 7 commits into
qualcomm:mainfrom
malto101:add-macos-support

Conversation

@malto101

Copy link
Copy Markdown

This PR adds MacOS support as a host for ELD (not a Mach-O target)

CMake detecs Darwin, uses "@loader_path" rpath and a kinda "bin/lib" layout, and skips GNU ver scripts on ld64

Runtime supports ".dylibs" plugins, Mach-O plugin metadata and "DYLD_LIBRARY_PATH/@loader_path" search. Lit gains Darwin features and FileChecks also accepts .dylib

also this was on my side
tried fixing "target_link_libraries" keyword that was mixed, it was breaking CMake on LLVM 22 on my host

@quic-seaswara

Copy link
Copy Markdown
Contributor

Wow! Thanks for adding this support.

Could you please add a github workflow to accompany and allow it to be tested on a mac ?

You would need to add

runs-on: macos-latest

@malto101

Dhruv Menon (malto101) commented Sep 2, 2026

Copy link
Copy Markdown
Author

Could you please add a github workflow to accompany and allow it to be tested on a mac ?

I have added the support

@quic-seaswara

Copy link
Copy Markdown
Contributor

Do you plan on working and improving eld ? If so what areas are you planning to look at ?

@quic-seaswara

Shankar Easwaran (quic-seaswara) commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

one cause of concern here is that this is a CI instead of a nightly job(using github schedules). Since we are using the github free machines, it will significantly slow down CI as the CI that we have runs on self-hosted machines.

I would prefer this to be a nightly job instead of a CI.

Can we do this, and allows you to work independently to debug things if something ends up breaking and not affecting CI's.

For now its definitely ok to see if the CI passes, but once the CI passes move it to nightly schedule.

@malto101

Dhruv Menon (malto101) commented Sep 2, 2026

Copy link
Copy Markdown
Author

onee cause of concern here is that this is a CI instead of a nightly job(using github schedules). Since we are using the github free machines, it will significantly slow down CI as the CI that we have runs on self-hosted machines.

Makes sense, once the job pass I will move the schedule to nightly

or maybe we can have a bot to start CI jobs based on tags along with nightly?

@malto101

Dhruv Menon (malto101) commented Sep 2, 2026

Copy link
Copy Markdown
Author

Do you plan on working and improving eld ? If so what areas are you planning to look at ?

Happy to keep contributing, though it'll be sporadic. I usually only work on this in my free time — traditionally I'm mostly on Zephyr, kernel, BeagleBoard for OSS stuff.
I got curious after Parth's talk at the recent Zephyr conference at hyd, started digging into eld after that, and this PR was the first thing that felt useful to try (I develop on a Mac).
If I keep poking at it, the areas I'd naturally look at are:

  • Host / CI / DX: Darwin support, nightlies, making it easier to build and test eld outside Linux
  • Zephyr: GNU ld / linker-script compatibility that shows up in Zephyr nightlies, quarantine, and bringing more boards through
  • Smaller cleanup / tests / docs as I run into them

Happy to take pointers if there's something more useful for me to look at.

@Steven6798

Copy link
Copy Markdown
Contributor

Happy to take pointers if there's something more useful for me to look at.

Thanks for the contribution! While we have issues already posted, you can work on anything that feels natural and you think will benefit ELD and its users. This PR is going in the right direction.

@quic-seaswara

Shankar Easwaran (quic-seaswara) commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Do you plan on working and improving eld ? If so what areas are you planning to look at ?

Happy to keep contributing, though it'll be sporadic. I usually only work on this in my free time — traditionally I'm mostly on Zephyr, kernel, BeagleBoard for OSS stuff. I got curious after Parth's talk at the recent Zephyr conference at hyd, started digging into eld after that, and this PR was the first thing that felt useful to try (I develop on a Mac). If I keep poking at it, the areas I'd naturally look at are:

  • Host / CI / DX: Darwin support, nightlies, making it easier to build and test eld outside Linux
  • Zephyr: GNU ld / linker-script compatibility that shows up in Zephyr nightlies, quarantine, and bringing more boards through
  • Smaller cleanup / tests / docs as I run into them

Happy to take pointers if there's something more useful for me to look at.

Appreciate the reply. More boards mean more testing opportunities.

We're also focused on improving link-time performance, enhancing diagnostics, expanding reproducibility features for debugging, and adopting proven capabilities from BFD and LLD that can benefit both general-purpose and embedded linking use cases.

Another area where contributions are valuable is expanding support for command-line options and improving compatibility with existing linker workflows, making it easier for users to migrate and adopt ELD in a wider range of environments.

Leveraging linker plugins, which are already quite robust in ELD, within Zephyr could also be an effective way to address a number of challenges.

There's plenty of value in helping improve documentation as well. Learning, documenting, and sharing best practices are all meaningful contributions.

And of course, if you're interested in code size optimization, linker optimizations, or performance tuning, there are plenty of opportunities there too.

Overall, any patches are welcome!

@malto101
Dhruv Menon (malto101) force-pushed the add-macos-support branch 3 times, most recently from 3ae9a6e to fcbef01 Compare September 3, 2026 09:16
LLVM 22's llvm_add_library already uses PRIVATE/PUBLIC. Mixing that
with the plain signature fails CMake. Use PRIVATE on LayoutMap and
the TargetInfo libraries.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
Unix Path.inc no longer includes unused Linux-only linux/nfs.h.
Plugin libraries use .dylib, Mach-O-safe plugin metadata, and
DYLD_LIBRARY_PATH / @loader_path search. CMake sets ELD_ON_APPLE,
@loader_path rpath, bin/lib output dirs, and skips GNU version
scripts on Apple ld64.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
@Steven6798

Steven Ramirez Rosa (Steven6798) commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Dhruv Menon (@malto101) to prevent having failures in tests due to missing tools (which could be expanded at any point), you can use "ninja" instead of "ninja ld.eld clang" to build everything. That will eliminate these kinds of failures.

@malto101
Dhruv Menon (malto101) force-pushed the add-macos-support branch 2 times, most recently from 76d6483 to 5d50f0a Compare September 6, 2026 00:58
Add darwin/arm-darwin/aarch64-darwin features, python3, BSD tar,
and DYLD_LIBRARY_PATH. Allow plugin FileCheck to match .dylib as
well as .so/.dll.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
macOS is a host for the ELF linker, not a Mach-O target. Document
.dylib plugin naming and DYLD_LIBRARY_PATH search.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
Test ld.eld on macos-latest so PRs get a Mac host build without
changing the Linux self-hosted job.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
Replaced inline scripts for checking non-documentation changes with a reusable action in ci.yml, ci-macos.yml, and ci-win.yml. This improves maintainability and consistency across workflows. The new action fetches the base branch from the Qualcomm repository and determines if the changes are solely documentation-related.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
Updated the CI workflow to stage the CheckNonDocChanges action at
the workspace root, allowing for better path management. Added an
optional input for the eld-root to support staging the action awa
from its original location.

Introduced a new lit configuration file for Linux x86_64 binaries
to ensure compatibility with libc headers.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
@malto101

Copy link
Copy Markdown
Author

Dhruv Menon (Dhruv Menon (@malto101)) to prevent having failures in tests due to missing tools (which could be expanded at any point), you can use "ninja" instead of "ninja ld.eld clang" to build everything. That will eliminate these kinds of failures.

Thanks Steven Ramirez Rosa (@Steven6798) it helped a lot

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this ci-macos to be a nightly-macos.yml.

I will be able to approve this.

Thanks for getting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants