mold icon indicating copy to clipboard operation
mold copied to clipboard

Uncaught exception running mold on macos

Open andrewdavidmackenzie opened this issue 3 years ago • 7 comments

I have installed mold on macos (Monterey 12.0.1) using homebrew:

uname -a Darwin MacBook-Pro 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64

which mold /usr/local/bin/mold

mold -v mold 1.0.3 (compatible with GNU ld)

When I try to use it, it fails with a broken symlink error, and there seems to be a reference to a linux /proc folder.

mold -run cargo build              
libc++abi: terminating with uncaught exception of type std::__1::__fs::filesystem::filesystem_error: filesystem error: in read_symlink: No such file or directory [/proc/self/exe]
zsh: abort      mold -run cargo build

andrewdavidmackenzie avatar Feb 09 '22 11:02 andrewdavidmackenzie

Fairly sure mold does not support true Unix systems, only Linux. Sorry :(

(also macOS has departed quite a bit from pure Unix, especially in its directory structure)

LoganDark avatar Feb 09 '22 16:02 LoganDark

Yes, per #189, mac support is currently nowhere near complete.

Maybe mold should print an unremovable "mold: mac support is currently in pre-alpha stage; pull requests are welcome, but please don't report bugs, they're most likely known already" warning before doing anything else.

Alcaro avatar Feb 09 '22 16:02 Alcaro

Ok, thanks I didn't see anything either way about macos, and when I saw homebrew I assumed macos.

andrewdavidmackenzie avatar Feb 09 '22 18:02 andrewdavidmackenzie

@Alcaro That's a good suggestion. Let me do that.

rui314 avatar Feb 10 '22 05:02 rui314

I confirm @andrewdavidmackenzie , I thought that there is support for macOS when I saw Homebrew in binary packages list here. Need to be removed from the list and/or show a detailed report of this problem.

pesterev avatar Jun 07 '22 09:06 pesterev

For mold -run intercepting exec on ld, ld.gold and ld.lld, macOS does not support LD_PRELOAD and the alternative DYLD_INSERT_LIBRARIES does not work with System Integrity Protection enabled:

> DYLD_INSERT_LIBRARIES=./mold-wrapper.so env | grep DYLD  # empty

I guess we need an alternative way for mold -run to work on macOS. Say creating symbolic link ld -> mold under a directory and add it to PATH. But that won't work when the absolute path of a linker is used.

ShawnZhong avatar Aug 05 '22 13:08 ShawnZhong

This caught my eye this week:

https://www.reddit.com/r/rust/comments/wd8xuc/mold_on_macos_works_kinda_and_i_confirmed_with_a/?utm_medium=android_app&utm_source=share

andrewdavidmackenzie avatar Aug 08 '22 00:08 andrewdavidmackenzie