Using LLD on the Command Line
Go Up to Command-Line Utilities Index
he Windows 64-bit Modern (bcc64x) toolchain uses LLVM’s lld linker. For reference, check the official lld documentation.
lld is normally invoked by the MSBuild scripts. If you want to invoke lld manually, there are a few things to note.
RTL linking
The startup code `crt2.o
` and `crtbegin.o
` object files should be the first objects listed and `crtend.o
` must be the last.
When building for Delphi (as for a normal VCL or FMX application), add `sysinit.o
` and additional Delphi-related libraries like rtl.lib and rtle.lib.
Default static vs dynamic RTL linking
By default, the new toolchain uses dynamic linking, while Borland/CodeGear/Embarcadero defaulted to static linking.
RAD Studio needs to maintain compatibility with both traditional C++BuilderBuilder behavior, which is the default for our toolchains, and mingw-llvm
compatibility, which is important for libraries that support it and detect our toolchain as being compatible with it.
Keep in mind that for Borland-style targets static linking is the default. Use the following flags to specify the target of the build:
-tC
– Console App-tW
– GUI App-tD
– DLL-tP
– Package
However, you can enable dynamic RTL linking for any of these targets, using the -tR
flag.
Without any of these targets being specified, dynamic linking is the default.
This approach gives mingw-llvm
behavior for normal C++Builder and switches to C++BuilderBuilder-toolchain-traditional behavior when using the above-style targets, such as building VCL apps.
Linking Libraries
Add libraries using the `-l:[library]
` flag. Note the colon between the lowercase L and the library name. Use `-lname`
to add library `libname.a`
with `.a`
extension and use `-l:name.ext`
for explicitly specified names like `-l:rtle.lib`.
For example, `-l:ucrt
` links with the UCRT library `libucrt.a
` and `-l:rtle.lib
` for rtle.lib.
`lib`
prefix and may instead use a `.lib`
extension. For example, `rtle.lib`
or `import64.lib
'.