Chrome On Windows Ditches Microsoft's Compiler, Now Uses Clang (arstechnica.com) 94
An anonymous reader quotes a report from Ars Technica: Google's Chrome browser is now built using the Clang compiler on Windows. Previously built using the Microsoft C++ compiler, Google is now using the same compiler for Windows, macOS, Linux, and Android, and the switch makes Chrome arguably the first major software project to use Clang on Windows. Chrome on macOS and Linux has long been built using the Clang compiler and the LLVM toolchain. The open-source compiler is the compiler of choice on macOS, making it the natural option there, and it's also a first-class choice for Linux; though the venerable GCC is still the primary compiler choice on Linux, by using Clang instead, Google ensured that it has only one set of compiler quirks and oddities to work with rather than two. But Chrome on Windows has instead used Microsoft's Visual C++ compiler. The Visual C++ compiler is the best-supported, most widely used compiler on Windows and, critically, is the compiler with the best support for Windows' wide range of debugging and diagnostic tools. The Visual Studio debugger is widely loved by the C++ community, and other tools, such as the WinDbg debugger (often used for analyzing crash dumps), are core parts of the Windows developer experience.
No, that's typical of commercial software. (Score:2, Insightful)
Commercial software is written for profit; the programmers don't do shit to improve it unless there's a paying customer.
In contrast, open-source programs are written largely by people who are trying to scratch their own itches, including performance itches.
Good luck re-programming Microsoft Edge when you're unhappy with its performance.
Re: (Score:2)
Allow me to fix that for you:
Commercial software is written for profit; the programmers don't do shit to improve it unless there's a paying customer.
In contrast, open-source programs are written largely by people who are trying to scratch their own itches, which may or may not coincide with yours
If you are lucky to find open-source software whose authors' "vision" co-align with yours, that's great. If you have the skills and the free time to hack on the code yourself, even better. Otherwise, you pay for what you want/need.
Re: (Score:2)
I never met a time traveler before. How is life in 2004 treating you? If my computer has 16Gb of memory why should I be upset that programs take advantage of it? Is that bragging rights or something? Oh look I have 64Gb and never use more than 6!
Re: (Score:3)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
You one of those nutjobs that keeps 400 tabs open? Chrome never uses more than 2-3Gb for me.
Re: (Score:2)
Re: (Score:1)
Tablets and netbooks still usually come with 1-2GB of non upgradeable ram. Even the Surface Laptop, a relatively expensive laptop comes with only 4.
Re: (Score:1)
I have, unfortunately, met people like you before. People like you are the reason why it costs a gigabyte of RAM and requires a VM being spun up just to plop "Hello World" on a screen. Why am I upset when your inefficient program eats my RAM? I am upset because my computer's resources are not yours to waste. Read that again to yourself a few times for emphasis please.
Good code is efficient with memory, CPU, and any other resource it makes use of. This is just simply programming best practice. Wasting
Re: (Score:2)
Well, for one thing, it's nice to be able to run something besides a web browser in that 16GB of RAM at the same time. Like maybe an over-bloated email cllient. Or an over-bloated messaging app. Maybe even an application to get actual work done.
We've had multitasking for over 30 years now, are you suggesting that we step back to the days of the Apple II and the original IBM PC? Except with pretty graphics and untold waste of system resources?
Re: (Score:2)
no, that's mostly because of shitty javascript on the whiz-bang web-2.0 sites you're browsing.
All of those videos on pornhub take up a lot of ram.
Re: (Score:2)
The GNU folks have been too ambitious in their vision and many of its leaders didn't want to reconcile with its own problems in its vision. It was too easy to call people who disagreed with some of the GNU greedy corporate shills, where many the people were mostly on board however they had a few issues.
The biggest issue I have with GNU is the lack of respect of the time and effort it goes into coding. It seemed that if you wanted to make money off of GNU software you were limited to Distributions and Consul
Re: (Score:2)
The biggest issue I have with GNU is the lack of respect of the time and effort it goes into coding.
The biggest problem I've had with GNU/GPL software is two fold:
On top of that it seems like a lot of tools were developed in a weekend by a single individual to scratch an itch and move on. GNUMake seems to be one of the biggest ones that everyone runs into. No one wants to make any changes that break stuff because then people will complain, and at this point so much needs to be 'fixed' that it'll never happen. And
Re: (Score:2)
They've chosen Clang over GCC for political reasons: despite a codebase without historical baggage, Clang is at least several percent slower than GCC, it only compiles faster. A good rule of thumb is that Clang-built code executes as GCC at one optimization level less, with compilation speed being likewise faster. Obviously, this wildly differs per test case.
Also, Clang's portability is pretty bad [debian.org].
Re: (Score:2)
It's important to be able to be able to run the edit-compile-test cycle rapidly
Please remind me: which company has the biggest computing power on the planet? And even on a single beefy machine, you can have enough cores to make final link the slowest part. Chrome still uses system linker both on Linux and Windows.
Re: (Score:2)
There will be many more users than developers, wasted processor cycles have to be multiplied by the number of users out there...
This translates to a significant amount of power wasted when spread over millions of devices.
This also adds up in virtualized environments, if you're running many instances of something than any inefficiencies are multiplied.
Re: (Score:2)
Also gcc's optimizer is notorious for bugs and undefined behaviors. Just try this in optimized mode with any gcc version and compare it with other compilers:
Your code is buggy; gcc notices the bug and issues a diagnostic, while clang happily produces incorrect output.
Re: (Score:2)
It's not about Clang, it's about LLVM.
Google wants to commence re-implementing their browser in Rust, a thread-safe functional language. By using LLVM, they can cherrypick any code from the Servo project for incorporation into Chromium. And they save on R&D costs by letting Mozilla employees do most of the work.
How well optimized is CLANG vs Visual C++ Compiler (Score:3)
Being that Google Chrome is in a constant speed race with Edge and Firefox all trying to be the fastest full featured browser out there. These guys need every advantage they can get to inch out on the benchmarks to claim they are the fastest. The general rule of thumb is tools made to run on many platforms tend to run more slowly then tools made for a particular platform.
Is Google going to stop in the benchmark war? Is CLang optimized enough for windows platforms to allow time saved in compiler compatibility to be used in better speed algorithms. Is CLang objectively equal or better then Visual C++ (As Microsoft sometimes sacrifices performance, for legacy support that Chrome may not be worried about)
Re: (Score:3)
Just guessing here, but I doubt the compiler makes any difference to speed whatsoever. Why? Because modern javascript browsers are just-in-time compiling the javascript into native code. So the native code is 2 levels removed from the C++, and the code your compiler generated.
Re: How well optimized is CLANG vs Visual C++ Comp (Score:2)
This is some very poor guessing.
Re: (Score:2)
Re: (Score:2)
Which makes for less portable code...
You'll have to maintain multiple versions for different architectures (x86, amd64, arm, arm64 etc), and it won't support other architectures unless you also implement a C version as well. Porting to a new architecture becomes a lot more work.
Re: (Score:2)
Why would a tool that emits x86 code on macOS do anything different on windows/x86?
Re: (Score:2)
A big part of a browser is its displaying of the page and details. A lot of this is actually calling the OS layers to do the work. Input Output, Drawing graphics, handling fonts, mouse input... All this stuff is on the OS layer which different compilers may have different tricks to call.
Re: (Score:1)
There is no trick in calling OS layers.
How should that work?
If your C++ code says: drawRect(r); assuming r is of type Rect, it will be the exact same code regardless what OS.
For everything that actually is calling the OS a thin C layer in the libraries is used, because it is a difference if you need to to do an "interrupt" or some other way to call the kernel.
Above the C layers, there is hardly any reason to arrange code different because of different OS's
Re: (Score:2)
For everything that actually is calling the OS a thin C layer in the libraries is used, because it is a difference if you need to to do an "interrupt" or some other way to call the kernel.
There's absolutely zero need to use C. C++ will do exactly the same things (possibly in exactly the same ways) with absolutely no extra overhead compared to C and C++ will do so in an easier, safer, and more readable fashion than C.
Do not misconstrue my statements to be derogatory toward C or C programmers! I'm simply trying to pedantically point out that there's no need to have a "thin layer of C" between C++ and the kernel.
Re: (Score:2)
Ofc. C and C++ are the same in that area.
But the libraries wrapping system calls are usually C because they then link with both.
Re: (Score:2)
I guess I misunderstood you. I'm sorry.
Re: (Score:2)
Yes, suppose you call fopen() in the C library, that boils down to an system call in unix/linux, not sure if they call it system call in Windows, too. :D
The calling conventions to the respective "kernels" might be different, the system libraries take care for that.
Well, in simple words
No offense taken if you misunderstood me, I was bad in explaining.
Re: (Score:2)
Because there are platform dependencies. The LLVM backend and annotators are different for Linux, macOS and WIndows, because they use different executable formats (ELF, MachO, and PE). And likewise, debug symbols are stored differently in each format - ELF can be self-contained, I believe MachO has external symbols, and PEs use PDBs (program database) generated during the build.
PDB support is interesting, because apparently i
Re: (Score:2)
And a binary format again has what exactly to do with the llvm code or x86 code emitted by clang?
Re: (Score:2)
The point is that chrome dev's can write *and debug* code using visual studio if that's what they prefer. While developers for all supported platforms can submit patches that are less likely to break when compiled for another platform, as they are using the exact same compiler.
Writing C++ code that works with microsoft's compiler on windows and clang on other platforms adds significant overheads. Microsoft has historically been slow to implement new C++ features completely and correctly in the past, making
Re: (Score:2)
You don't need to do anything special to be able to debug any program with visual studio. The binaries only ned debug info.
Writing C++ code that works with microsoft's compiler on windows and clang on other platforms adds significant overheads.
For whom? The Clang developers, no.
The Chrome developers, yes. But that has nothing to do with Clang but with the names of the functions of the system libraries and their parameters.
Re: (Score:2)
The binaries only need debug info
Yes they do, and now clang can produce that debug info in a format that visual studio can read. That was a key piece of development that allowed this change to happen.
but with the names of the functions of the system libraries and their parameters
Any developer should be hiding platform differences in isolated code that is only compiled for that platform. If you aren't touching that kind of code, your patch shouldn't break any other platform. The problems of supporting multiple compilers can be much more subtle than that.
C++ is a complex language, with many small behaviour details eith
Re: (Score:2)
Code that works fine when compiled with MSVC, might raise an error when compiled with clang, breaking the build for other developers. Developing any large C++ software, and supporting compiling it with multiple different C++ compilers, adds overhead to the day-to-day development of that software.
Yes, and that is why many companies actually do compile the code with different compilers on build farms to see if it compiles and run the tests against different binaries. Heck, many even use just one compiler but
Re: (Score:2)
Re: (Score:2)
I found Google's motivations here to be a bit interesting. They apparently wanted to use Clang across all their platforms.
I'm writing a cross-platform PC game using my own game engine. It runs natively on Windows desktop, UWP, Mac, and Linux. About 95% of it is written in portable ANSI C++, and the other 5% interfacing with native APIs. I actually use three different compilers, one for each OS, and I consider this a GOOD thing, not a bad thing. Compiling the same code against three compilers gives me a
Re: (Score:2)
Want to know the answer? There's an easy way. RTFA and find out! Amazing but true!
tl;dr +/- 5%. In some areas Clang does better, in others worse.
Re: (Score:2)
Not on debian -- chrome only updates when i run apt-get update. just like everything else. Why give any program permission to overwrite itself?
Re: (Score:2)
LLVM Project Blog says (Score:3, Informative)
I read LLVM Project Blog; I think it said it was done partly for code maintenance issues. As, in it should be faster to add patches for Windows using the same Compiler over all platforms.
Note: They are still using Microsoft linker.
Tim S.
Re: (Score:2)
illustrating the power of open source (Score:4, Insightful)
Re: (Score:2)
According to Judy Garland, the trolley. The trolley went clang, clang, clang.
Vivaldi (Score:4, Informative)
Er... Vivaldi has used Chrome as a base and been compiled with clang for a while now, I think:
Vivaldi 1.14.1077.55 (Stable channel) (32-bit)
Revision 46ff8f974f033190bbae67a70c7809ee15bc2353-
OS Windows
JavaScript V8 6.4.388.46
Flash (Disabled)
User Agent Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.189 Safari/537.36 Vivaldi/1.95.1077.55
Command Line "C:\Users\ldowling\AppData\Local\Vivaldi\Application\vivaldi.exe" --always-authorize-plugins --enable-blink-features=ResizeObserver --flag-switches-begin --flag-switches-end https://vivaldi.com/newfeature... [vivaldi.com]
Executable Path C:\Users\ldowling\AppData\Local\Vivaldi\Application\vivaldi.exe
Profile Path C:\Users\ldowling\AppData\Local\Vivaldi\User Data\Default
Compiler clang
Re:Vivaldi (Score:4, Insightful)
The option to use a 3rd party compiler for the release has always been there. The big news in TFA is that Microsoft helped them with the PDB format so that you could compile *and* debug with Clang.
SPARC (Score:2)
Google ought to pour a LOT of love into a SPARC port. The best-situated would be OpenBSD.
Why, you ask? For the same reason that Microsoft's original target for the NT kernel was MIPS, and x86 was specifically secondary - oddball architectures will force you to clean up your code.
OpenBSD is also vicious in showing you your use-after-free mistakes since malloc() uses mmap() instead of sbrk() on their platform.
The bazaar of MS-OS compilers (Score:2)
There always was a plethora of compilers on Microsofts operating systems: Watcom, Intel, Borland, Digital Mars, various gcc ports, and many others long forgotten, not to mention Microsoft's offerings.
But these days people seem to have borrowed a notion from Unix: "The platform compiler", and have gotten into their heads that Microsoft(tm) Visual Studio(tm) is just that.
But it isn't! There's no such thing! You just pick whichever compiler you feel feeds the needs of your project. For all the things that suck
Now I get the strategic move (Score:2)
Now the strategy is clearer. It is an attempt to dislodge gcc from its perch in the Linux world. One of the very few standard things in Linux is the gcc. Fragment it, tout, one source both linux and windows as target binaries as benefit to woo people away from gcc. They think they MsDev is so g
Re: (Score:1)
Also compare template error messages between gcc/VC++ and Clang. It is just no competition.
Finally a modular compiler chain so people with more complex problems can adapt the stack as needed. I am happy the 2 monolithic monst