mold
mold copied to clipboard
Support macOS/iOS
We want to support the macOS/iOS target by mold 2.0.
Hey folks, I want to contribute to making mold work with macOS. I guess the first step would be to document the features currently not supported as I run into them. If you already have a task list, please do share.
Support the following flags:
-
objc_abi_version: Not documented
-
debug_variant Do not warn about issues that are only problems for binaries shipping to customers.
-
exported_symbol symbol The specified symbol is added to the list of global symbols names that will remain as global symbols in the output file. This option can be used multiple times. For short lists, this can be more convenient than creating a file and using -exported_symbols_list.
-
weak_framework name[,suffix] This is the same as the -framework name[,suffix] but forces the framework and all references to it to be marked as weak imports. Note: due to a clang optimizations, if functions are not marked weak, the compiler will optimize out any checks if the function address is NULL.
-
add_ast_path file The linker will add a N_AST stab symbol to the output file where the string is the path pointed by file and its values is the modification time of the file.
-
sectcreate segname sectname file The section sectname in the segment segname is created from the contents of file file. If there's a section (segname,sectname) from any other input, the linker will append the content from the file to that section.
-
sectalign segname sectname value The section named sectname in the segment segname will have its alignment set to value, where value is a hexadecimal number that must be an integral power of 2.
-
dependency_info NOT DOCUMENTED
-
object_path_lto filename When performing Link Time Optimization (LTO) and a temporary mach-o object file is needed, if this option is used, the temporary file will be stored at the specified path and remain after the link is complete. Without the option, the linker picks a path and deletes the object file before the linker tool completes, thus tools such as the debugger or dsymutil will not be able to access the DWARF debug info in the temporary object file.
@tapthaker Thanks! Please be aware that I'm also actively working on mold/macOS. So you want to send me PRs frequently rather than accumulating local changes in your local tree.
Sounds good 👍. Should we create a way to track our progress? That'll ensure that I don't step on something you are working on.
It looks like each feature can be implemented in a few hours, so I'm not sure if "acquiring a lock before start working on a feature" is a good model to share our work. For the tasks that take more than a few hours, feel free to file it as a bug.
@rui314 what's the progress on this? I just tested it out on an Xcode project, and it just worked; it went from 15 seconds linking to 2.1; it looks too good to be true 👀
I'm busy working on other parts of the linker, but I'll resume working on mold/macOS soon.
No problem, you've done great work to get it this far. Thank you!
我正忙于处理链接器的其他部分,但我很快就会继续处理模具/macOS。
great
How's it going? Been a while since we've heard anything here. Just tested it out on my own project and ran into fatals and complaints about missing -dynamic
flags
AFAIK this mostly works if you're using sold the commercial version of mold that supports the apple ecosystem.
Sorry for not updating this issue, but as @rockwotj pointed out, I made macOS/iOS version commercial software to support the entire project ecosystem. Please use the sold linker if you are looking for a fast linker for macOS/iOS.