Live data from Hacker News

Using Clang on Windows

arvid.io

21–30 of 30 posts

Re: Using Clang on Windows

#21
post #17

Earlier quoted context omitted.

> Unlike gcc the license for llvm/clang is more liberal so if they want private internal tooling they can still do that also. How can that be true? The definition of private internal tooling is that it's not publically distributed, and therefore, GPL isn't a concern. Unless you distribute the result of your modifications to GCC, both clang and GCC are viable bases from which you make your internal tooling.

Wanting to distribute something externally does not mean that you want to release it publicly. Lots of "internal" tools are distributed to teams at partner companies and contractors, for example. And more generally, the internal tool of today can become the hit add-on to your existing product of tomorrow, or a new product line. You want to retain flexibility. Legal departments aren't just being paranoid when they ins…

Which is why the *BSDs have a bigger amount of contributions than GPL-licensed operating systems.

Re: Using Clang on Windows

#22
post #3

"Unfortunately, getting clang to compile MSVC based projects isn't as easy as just dropping in clang and changing a few flags. Let's get started." Errr, use clang-cl, and "yes it is". That's the whole point of clang-cl :)

Unfortunately, clang-cl only supports a very limited subset of CL's flags. And if you want to talk to clang directly you have to go through an extra layer of indirection by using -Xclang -flag. By using clang directly you get the whole power of clang without arbitrary limitations (and as a bonus you can now compiler your software on mac and linux).

Re: Using Clang on Windows

#24
post #20
post #15

"Visual Studio 2017 will not work." Ouch...

I'm not sure what is meant here. "opting in" to VS 2017 is recommended when building Chrome for 64-bit Windows to get improved incremental linking support. (We still link Chrome on Windows with link.exe even when compiling with Clang.)

Not true anymore, I've updated the repository and article to work with 2017. Visual Studio 2017 doesn't require the -fms-compatibility flags anymore, in fact, it refuses to compile if you specify them. Since I was expecting these to be required I found no way to compile them.

Re: Using Clang on Windows

#25
post #2

Looks like this is using clang++ instead of clang-cl, which sets almost all of these flags automatically.

Unfortunately, clang-cl only supports a very limited subset of CL's flags. And if you want to talk to clang directly you have to go through an extra layer of indirection by using -Xclang -flag. By using clang directly you get the whole power of clang without arbitrary limitations (and as a bonus you can now compiler your software on mac and linux).

Re: Using Clang on Windows

#26
post #20
post #15

"Visual Studio 2017 will not work." Ouch...

I'm not sure what is meant here. "opting in" to VS 2017 is recommended when building Chrome for 64-bit Windows to get improved incremental linking support. (We still link Chrome on Windows with link.exe even when compiling with Clang.)

> (We still link Chrome on Windows with link.exe even when compiling with Clang.)

I wasn't aware of this, I know Rui the COFF owner in lld puts in a lot of effort into lld for chrome link times. Maybe he just uses it as a benchmark then :D

I actually caused a regression in migrating def code from lld to llvm with symbol mangling because we were missing a test case for this specific type of mangling and within hours it ended up on a chromium bug tracker and was fixed also within hours by Reid another googler on LLVM.

Re: Using Clang on Windows

#27
post #17
post #7

Earlier quoted context omitted.

By using clang-cl you are getting the advantage of the LLVM backend. LLVM/Clang can target many different platforms besides windows and it is open source so it is sponsored by many large companies including Google Apple etc. Google use it for Chrome for example (which includes windows) and have engineers working full time to meet their needs. Intel, ARM, AMD and co have upstreamed many optimisations into LLVM also. I…

> Unlike gcc the license for llvm/clang is more liberal so if they want private internal tooling they can still do that also. How can that be true? The definition of private internal tooling is that it's not publically distributed, and therefore, GPL isn't a concern. Unless you distribute the result of your modifications to GCC, both clang and GCC are viable bases from which you make your internal tooling.

> both clang and GCC are viable bases from which you make your internal tooling.

License is not the only factor determining usability of a compiler wrt interfacing with external tools. GCC was deliberately designed to prevent such usage.

See https://www.youtube.com/watch?v=NURiiQatBXA at 2:22 for a direct quote from RMS on this topic.

Re: Using Clang on Windows

#28
post #26
post #20

Earlier quoted context omitted.

I'm not sure what is meant here. "opting in" to VS 2017 is recommended when building Chrome for 64-bit Windows to get improved incremental linking support. (We still link Chrome on Windows with link.exe even when compiling with Clang.)

> (We still link Chrome on Windows with link.exe even when compiling with Clang.) I wasn't aware of this, I know Rui the COFF owner in lld puts in a lot of effort into lld for chrome link times. Maybe he just uses it as a benchmark then :D I actually caused a regression in migrating def code from lld to llvm with symbol mangling because we were missing a test case for this specific type of mangling and within hours i…

Yes, I should have been a bit more clear. You can link with lld (we have bots running that do this; we're even setting up a bot that enables ThinLTO). But lld support for emitting PDB files isn't quite there yet.

Re: Using Clang on Windows

#30
post #2

Looks like this is using clang++ instead of clang-cl, which sets almost all of these flags automatically.

Unfortunately, clang-cl only supports a very limited subset of CL's flags. And if you want to talk to clang directly you have to go through an extra layer of indirection by using -Xclang -flag. By using clang directly you get the whole power of clang without arbitrary limitations (and as a bonus you can now compiler your software on mac and linux).

What's missing?
Post reply on HN