Opened 5 years ago

Closed 3 years ago

Last modified 15 months ago

#58042 closed request (fixed)

port request: lld

Reported by: saagarjha (Saagar Jha) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: kencu (Ken), larryv (Lawrence Velázquez), jeremyhu (Jeremy Huddleston Sequoia), ryandesign (Ryan Carsten Schmidt), cjones051073 (Chris Jones), nickhutchinson (Nick Hutchinson), 0x8ff
Port:

Description

I don't see the LLVM Linker available on MacPorts, so I thought I'd request for it to be added. This might go under the llvm port?

Change History (18)

comment:1 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: kencu larryv jeremyhu ryandesign added

I also need lld now. Ken, Larry, or Jeremy: do you have any thoughts on how best to offer this in MacPorts? Standalone port or integrated somehow into the existing llvm ports?

Last edited 4 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:2 Changed 4 years ago by kencu (Ken)

Probably not hard. Just add it to < https://github.com/kencu/myports/tree/master/lang/llvm-devel> as another project, which I am working on, with Chris, now.

Can I ask, what do you think it will be useful for, though? ld64 is the Apple linker. Does lld offer something you need?

comment:3 Changed 4 years ago by kencu (Ken)

Cc: cjones051073 added

comment:4 Changed 4 years ago by kencu (Ken)

bringing you in here, Chris, as you are integral to the compiler setups on MacPorts these days.

comment:5 in reply to:  2 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to kencu:

Can I ask, what do you think it will be useful for, though? ld64 is the Apple linker. Does lld offer something you need?

Not sure about the original reporter, but in my case, I misread a discussion and thought lld would be useful to solve a build problem I was seeing. It turns out that wasn't the problem and I don't need lld to solve it after all.

comment:6 Changed 4 years ago by cjones051073 (Chris Jones)

I guess if the LLVM produces the linker, there must be a reason why Jeremy did not include it in the original installation, likely because either the system (Xcode) ld, or the one provided by the ld64 port, covers all the bases. I'm not sure I have ever seen a need for lld specifically so it would be good to know why the OP thinks this would be needed, compared to the existing ld options.

comment:7 Changed 4 years ago by nickhutchinson (Nick Hutchinson)

One use case that lld does enable is cross-compilation for *nix or Windows platforms. I'm using llvm provided by Homebrew for this reason.

comment:8 Changed 4 years ago by nickhutchinson (Nick Hutchinson)

Cc: nickhutchinson added

comment:9 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Has duplicate #62533.

comment:10 Changed 3 years ago by kencu (Ken)

ok, seems there is sufficient demand to add it. Will report back.

comment:11 Changed 3 years ago by kencu (Ken)

People are invited to kick the tires on this PR.

I put this lld addition to the clang-11 port together for some early testers <https://github.com/macports/macports-ports/pull/10404>

comment:12 Changed 3 years ago by kencu (Ken)

$ port contents clang-11 | grep lld
  /opt/local/bin/ld.lld-mp-11
  /opt/local/bin/ld64.lld-mp-11
  /opt/local/bin/lld-link-mp-11
  /opt/local/bin/lld-mp-11
  /opt/local/libexec/llvm-11/bin/ld.lld
  /opt/local/libexec/llvm-11/bin/ld64.lld
  /opt/local/libexec/llvm-11/bin/lld
  /opt/local/libexec/llvm-11/bin/lld-link
  /opt/local/libexec/llvm-11/include/lld/Common/Args.h
  /opt/local/libexec/llvm-11/include/lld/Common/DWARF.h
  /opt/local/libexec/llvm-11/include/lld/Common/Driver.h
  /opt/local/libexec/llvm-11/include/lld/Common/ErrorHandler.h
  /opt/local/libexec/llvm-11/include/lld/Common/Filesystem.h
  /opt/local/libexec/llvm-11/include/lld/Common/LLVM.h
  /opt/local/libexec/llvm-11/include/lld/Common/Memory.h
  /opt/local/libexec/llvm-11/include/lld/Common/Reproduce.h
  /opt/local/libexec/llvm-11/include/lld/Common/Strings.h
  /opt/local/libexec/llvm-11/include/lld/Common/TargetOptionsCommandFlags.h
  /opt/local/libexec/llvm-11/include/lld/Common/Timer.h
  /opt/local/libexec/llvm-11/include/lld/Common/Version.h
  /opt/local/libexec/llvm-11/include/lld/Core/AbsoluteAtom.h
  /opt/local/libexec/llvm-11/include/lld/Core/ArchiveLibraryFile.h
  /opt/local/libexec/llvm-11/include/lld/Core/Atom.h
  /opt/local/libexec/llvm-11/include/lld/Core/DefinedAtom.h
  /opt/local/libexec/llvm-11/include/lld/Core/Error.h
  /opt/local/libexec/llvm-11/include/lld/Core/File.h
  /opt/local/libexec/llvm-11/include/lld/Core/Instrumentation.h
  /opt/local/libexec/llvm-11/include/lld/Core/LinkingContext.h
  /opt/local/libexec/llvm-11/include/lld/Core/Node.h
  /opt/local/libexec/llvm-11/include/lld/Core/Pass.h
  /opt/local/libexec/llvm-11/include/lld/Core/PassManager.h
  /opt/local/libexec/llvm-11/include/lld/Core/Reader.h
  /opt/local/libexec/llvm-11/include/lld/Core/Reference.h
  /opt/local/libexec/llvm-11/include/lld/Core/Resolver.h
  /opt/local/libexec/llvm-11/include/lld/Core/SharedLibraryAtom.h
  /opt/local/libexec/llvm-11/include/lld/Core/SharedLibraryFile.h
  /opt/local/libexec/llvm-11/include/lld/Core/Simple.h
  /opt/local/libexec/llvm-11/include/lld/Core/SymbolTable.h
  /opt/local/libexec/llvm-11/include/lld/Core/UndefinedAtom.h
  /opt/local/libexec/llvm-11/include/lld/Core/Writer.h
  /opt/local/libexec/llvm-11/include/lld/ReaderWriter/MachOLinkingContext.h
  /opt/local/libexec/llvm-11/include/lld/ReaderWriter/YamlContext.h
  /opt/local/libexec/llvm-11/lib/cmake/lld/LLDConfig.cmake
  /opt/local/libexec/llvm-11/lib/cmake/lld/LLDTargets-release.cmake
  /opt/local/libexec/llvm-11/lib/cmake/lld/LLDTargets.cmake
  /opt/local/libexec/llvm-11/lib/liblldCOFF.a
  /opt/local/libexec/llvm-11/lib/liblldCommon.a
  /opt/local/libexec/llvm-11/lib/liblldCore.a
  /opt/local/libexec/llvm-11/lib/liblldDriver.a
  /opt/local/libexec/llvm-11/lib/liblldELF.a
  /opt/local/libexec/llvm-11/lib/liblldMachO.a
  /opt/local/libexec/llvm-11/lib/liblldMachO2.a
  /opt/local/libexec/llvm-11/lib/liblldMinGW.a
  /opt/local/libexec/llvm-11/lib/liblldReaderWriter.a
  /opt/local/libexec/llvm-11/lib/liblldWasm.a
  /opt/local/libexec/llvm-11/lib/liblldYAML.a
$ /opt/local/bin/ld64.lld-mp-11
OVERVIEW: LLVM Linker

USAGE: /opt/local/libexec/llvm-11/bin/ld64.lld [options] file...

BUNDLE EXECUTABLE OPTIONS:
  -bundle_loader <path> The executable that will be loading this Mach-O bundle

DYLIB EXECUTABLE OPTIONS:
  -compatibility_version <version>
                       The dylib's compatibility version
  -current_version <version>
                       The dylib's current version
  -install_name <path> The dylib's install name
  -mark_dead_strippable_dylib
                       Marks the dylib as having no side effects during initialization

LIBRARY OPTIONS:
  -all_load         Forces all members of all static libraries to be loaded
  -force_load <library-path>
                    Forces all members of specified static libraries to be loaded
  -F <dir>          Add directory to framework search path
  -L <dir>          Add directory to library search path
  -syslibroot <dir> Add path to SDK to all absolute library search paths

MAIN EXECUTABLE OPTIONS:
  -export_dynamic     Preserves all global symbols in main executables during LTO
  -e <entry-name>     entry symbol name
  -no_pie             Do not create Position Independent Executable
  -pie                Create Position Independent Executable (for ASLR)
  -stack_size <value> Specifies the maximum stack size for the main thread in a program. Must be a page-size multiple. (default=8Mb)

OBSOLETE OPTIONS:
  -multi_module       Unsupported way to build dylibs
  -objc_gc_compaction Unsupported ObjC GC option
  -objc_gc_only       Unsupported ObjC GC option
  -objc_gc            Unsupported ObjC GC option
  -single_module      Default for dylibs

OPTIMIZATIONS:
  -data_in_code_info      Force generation of a data in code load command
  -dead_strip             Remove unreference code and data
  -exported_symbols_list <file-path>
                          Restricts which symbols will be exported
  -exported_symbol <symbol>
                          Restricts which symbols will be exported
  -flat_namespace         Resolves symbols in any (transitively) linked dynamic libraries. Source libraries are not recorded: dyld will re-search all images at runtime and use the first definition found.
  -function_starts        Force generation of a function starts load command
  -ios_simulator_version_min <version>
                          Minimum iOS simulator version
  -ios_version_min <version>
                          Minimum iOS version
  -keep_private_externs   Private extern (hidden) symbols should not be transformed into local symbols
  -macosx_version_min <version>
                          Minimum Mac OS X version
  -mllvm <option>         Options to pass to LLVM during LTO
  -no_data_in_code_info   Disable generation of a data in code load command
  -no_function_starts     Disable generation of a function starts load command
  -no_objc_category_merging
                          Disables the optimisation which merges Objective-C categories on a class in to the class itself.
  -no_version_load_command
                          Disable generation of a version load command
  -order_file <file-path> re-order and move specified symbols to start of their section
  -sdk_version <version>  SDK version
  -source_version <version>
                          Source version
  -twolevel_namespace     Resolves symbols in listed libraries only. Source libraries are recorded in the symbol table.
  -undefined <undefined>  Determines how undefined symbols are handled.
  -unexported_symbols_list <file-path>
                          Lists symbols that should not be exported
  -unexported_symbol <symbol>
                          A symbol which should not be exported
  -version_load_command   Force generation of a version load command

OPTIONS:
  -arch <arch-name>       Architecture to link
  -demangle               Demangles symbol names in errors and warnings
  -dependency_info <file> Write binary list of files used during link
  -error-limit <number>   Maximum number of errors to emit before stopping (0 = no limit)
  -filelist <path>        file containing paths to input files
  -framework <name>       Base name of framework searched for in -F directories
  -lto_library <path>     Ignored for compatibility with other linkers
  -l<libname>             Base name of library searched for in -L directories
  -o <path>               Output file path
  -path_exists <path>     Used with -test_file_usage to declare a path
  -print_atoms            Emit output as yaml atoms
  -rpath <path>           Add path to the runpath search path list for image being created
  -sectalign <segname> <sectname> <alignment>
                          Alignment for segment/section
  -sectcreate <segname> <sectname> <file>
                          Create section <segname>/<sectname> from contents of <file>
  -S                      Remove debug information (STABS or DWARF) from the output file
  -test_file_usage        Only files specified by -file_exists are considered to exist. Print which files would be used
  -t                      Print the names of the input files as ld processes them
  -upward-l<libname>      Base name of upward library searched for in -L directories
  -upward_framework <name>
                          Base name of upward framework searched for in -F directories
  -upward_library <path>  path to upward dylib to link with
  -v                      Print linker information
  -Z                      Do not search standard directories for libraries or frameworks

OUTPUT KIND:
  -bundle  Create dynamic bundle
  -dylib   Create dynamic library
  -dynamic Create dynamic executable (default)
  -execute Create main executable (default)
  -preload Create binary for use with embedded systems
  -r       Create relocatable object file
  -static  Create static executable

comment:13 Changed 3 years ago by kencu (Ken)

Resolution: fixed
Status: newclosed

comment:14 Changed 15 months ago by 0x8ff

I just installed LLVM 15 on my Mac, and lld doesn't seem to be installed?

Is it really included now or am I suppose to sudo port select --set <something>`?

comment:16 Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: 0x8ff added

lld appears only to have been added to the clang-11 port, not earlier nor later versions; don't know why.

comment:17 Changed 15 months ago by saagarjha (Saagar Jha)

I have LLVM 15 installed and it includes mp-lld-15. Perhaps it just needs to be added to the list of things to select?

comment:18 in reply to:  17 ; Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to saagarjha:

I have LLVM 15 installed and it includes mp-lld-15.

Oh. Huh.

clang-11 is the only portfile that was updated by the above commit and clang-11 and clang-11-bootstrap are the only ports that contain the line:

        ln -s ${workpath}/llvm-project/lld                              ${worksrcpath}/projects/lld

So I assumed that it had not been added to other ports. However I see now that clang-12 and later do it a different way with:

        -DLLVM_ENABLE_PROJECTS="clang\;clang-tools-extra\;compiler-rt\;libcxx\;libcxxabi\;flang\;mlir\;lld"

According to a search on the ports web site, clang-12 and later all have files whose paths begin with /opt/local/bin/lld (but clang-11 does not).

Perhaps it just needs to be added to the list of things to select?

You're right that lld is not mentioned in any of the clang ports' select files. It could be added, at the expense of having to rebuild all clang ports on all OS versions, which is time-consuming.

comment:19 in reply to:  18 Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to ryandesign:

According to a search on the ports web site, clang-12 and later all have files whose paths begin with /opt/local/bin/lld (but clang-11 does not).

Looking at the list of files for clang-11 shows that it does contain /opt/local/bin/lld-mp-11; don't know why the search doesn't return that result then.

Note: See TracTickets for help on using tickets.