I'm using Windows, the swift installer will install clang.exe at C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin and I think I need to add the path to my system variable of 'path'.
In that case, the clang.exe installed from swift will be available at system level, then can it be used as a generalized clang.exe, for example, to compile other c/c++ source code?
The reason why I ask is that I heard that lldb from swift is not same as the original one.
@felixfxu, yes, as @John_McCall mentioned, the compiler does have some additional patches for Swift, but, overall, it should be usable as a general C/C++ compiler as well (and in fact, in some cases is required). The path that you are referring to should already be added to Path when you install Swift on Windows (the installer will configure this). Of course, the version of clang that is being shipped is not from main, so there may be occasional issues that need to be fixed, but we should be able to backport self-contained changes if necessary.
I don't think that this works as well on Windows due to the need to inject the swift registrar as swiftc assumes that the target is a Swift target and not only a C/C++ target. If you add the explicit link to the swiftCore library, it should work on Windows as well! (This is something that we end up seeing with swift-driver).
Doesn't seem to work on Linux either, but I could be doing it wrong:
$ swiftc hello.c
error: autolink-extract command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: error opening input file 'hello.c' (The file was not recognized as a valid object file
)
error: fatalError
Using swift rather than swiftc spews a dozen errors as it tries to parse the C file as Swift code.