lld on Windows

What’s the current state of affairs regarding lld on Windows - how much of it is supposed to work? The documentation at http://lld.llvm.org/windows_support.html suggests it should pretty much work provided you don’t need exceptions or debug info (though that documentation seems to be from last year), but when I tried it on a ‘hello world’ C program, it gave error messages; is it the case that lld is not yet expected to work on Windows, or that it should and I’m probably getting a command wrong, or something else?

What error message did you get? What http://lld.llvm.org/windows_support.html says is correct – except debug info, the linker should be pretty much usable as a drop-in replacement for MSVC linker.

C:\t>type a.c

#include <stdio.h>

int main() {
puts(“hello”);
return 0;
}

C:\t>cl /c a.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

a.c

C:\t>lld
Select the appropriate flavor
OVERVIEW: LLVM Linker

USAGE: lld [options]

OPTIONS:
-core CORE linking
-flavor Flavor for linking, options are gnu/darwin/link
-help Display this help message
-target Select the target
-version Display the version

C:\t>lld -flavor link a.obj
Cannot open /GUARDSYM:__C_specific_handler,S.obj: no such file or directory

You seems to be using MSVC 2015 which I don’t use yet, and /GUARDSYM seems to be a new option added in MSVC 2015. I’ll try to support that.

Ah! I don’t know what GUARDSYM does or whether there is any way to turn it off at the compiler end; a Google search doesn’t seem to find anything; but it would be great if you could add support for msvc 2015.

When I try using clang as the compiler, I get a different error message. In this case it seems to be just not finding the standard libraries?

C:\t>clang -c a.c

C:\t>lld -flavor link a.o
Undefined symbol: : mainCRTStartup
Undefined symbol: a.o: puts
symbol(s) not found

Ah! I don't know what GUARDSYM does or whether there is any way to turn it
off at the compiler end; a Google search doesn't seem to find anything; but
it would be great if you could add support for msvc 2015.

Yeah, there's no information about what /GUARDSYM option is on the
internet. We may want to ignore the option for now.

When I try using clang as the compiler, I get a different error message.
In this case it seems to be just not finding the standard libraries?

C:\t>clang -c a.c

C:\t>lld -flavor link a.o
Undefined symbol: <entry>: mainCRTStartup
Undefined symbol: a.o: puts
symbol(s) not found

Maybe you want to try to compile with clang-cl instead of clang?

C:\t>clang-cl /c a.c

C:\t>lld -flavor link a.obj
Cannot open /GUARDSYM:__C_specific_handler,S.obj: no such file or directory