10 ms·
Toward _FORTIFY_SOURCE Parity Between Clang and GCC
- unixhero 7y agoIs it good for both, Pareto optimal, or is it bad for GCC that Clang is catching up? But if Clang is catching up, is that really bad?
- qeqeqeqe 7y agoClang has mostly caught up to GCC and suppressed it in many others ways. It's probably somewhat bad in the long run since LLVM/Clang seems to have more devs contributing to it now.
- romaniitedomum 7y agoGiven both are open source, neither of them is going to be able to leapfrog the other for long, at least in terms of core C/C++ language features, without the other copying and implementing something similar. Both have sufficient developers to keep up with the pace of development. What's more interesting, at least to me, is what impact this competition is having on the wider ecosystem. Is it leading to more features and better compilation than would be the case if there was just one compiler toolchain?
- inetknght 7y ago> Is it leading to more features and better compilation than would be the case if there was just one compiler toolchain? I would argue that the pace of C++ compiler development has significantly increased since clang was introduced. I would surmise that elimination of GCC or Clang -- in the way that Chrome has resulted in the elimination of more than one competing browser -- would be detrimental to C++ as a whole. And therefore, I would say: yes, it's leading to more features and better compilation that if it was just one compiler toolchain.
- favorited 7y agoThough obviously not because of Clang, the pace of C++ itself significantly increased since Clang was introduced.
- pjmlp 7y agoHowever, because Clang, we have finally IDEs caughting up with Energize C++ and VA for C++ v4 ideas, a couple of decades after they shown what would be possible with C++ when one isn't constrained to UNIX mentality of development.
- inetknght 7y agoWhat do you mean?
- pjmlp 7y agoI mean this, https://www.youtube.com/watch?v=pQQTScuApWk https://www.youtube.com/watch?v=pQQTScuApWk http://dreamsongs.com/Files/Energize.pdf http://dreamsongs.com/Files/Energize.pdf http://www.edm2.com/index.php/VisualAge_C%2B%2B_4.0_Review http://www.edm2.com/index.php/VisualAge_C%2B%2B_4.0_Review Basically Smalltalk like development experience, just for C++. Too advanced for early 90's computers (it demanded very high end hardware).
- jhasse 7y agoClang can't copy from GCC due to the different licenses. GCC can't copy from Clang due to the FSF requiring a copyright assignment.
- romaniitedomum 7y agoNot literal copying, no, since the two codebases differ substantially, but they can look at the code for what the other has done to see how they did it and they can re-implement it without fear of patent infringement claims.
- cycloptic 7y agoNeither of those are significant -- both can be forked if it becomes necessary. GCC has a long history of forks, and half the reason clang is becoming popular is because the downstream vendors didn't like GPL and wanted to make proprietary forks.
- pjmlp 7y agoAnd GCC only became popular because UNIX vendors, starting with Sun, decided to sell the UNIX SDK separately from the base OS.
- loeg 7y agoGood for everybody to have a non-monoculture and some friendly competition.
- pcwalton 7y agoWell, at this point Clang is the one more likely to create a monoculture, not GCC.
- chungy 7y agoProbably doubtful. I bet GCC is used at least 10× as much as Clang.
- comex 7y agoGCC is still dominant in the desktop Linux world and embedded. But Clang is the default compiler for: - Apple platforms - Android (at least for the NDK used by third-party developers) - PS4 - Nintendo Switch - WebAssembly (there's no official "default", but GCC doesn't support it) - eBPF (at least, GCC didn't support it until a few months ago) Oh, and Google uses Clang to build Chromium for all of its supported platforms (Windows, Mac, Linux).
- pjmlp 7y agoAndroid is fully clang nowadays, Google's fork of Linux kernel has been cleaned from GCC dependencies. There were a couple of talks about it a couple of years ago. 2017 LLVM Developers’ Meeting: “Compiling Android userspace and Linux kernel with LLVM", https://www.youtube.com/watch?v=6l4DtR5exwo https://www.youtube.com/watch?v=6l4DtR5exwo "LPC2018 - Clang+Linux", https://www.youtube.com/watch?v=SSWUrWqnSz0 https://www.youtube.com/watch?v=SSWUrWqnSz0 EDIT: typo and link for the mentioned talks.
- pjmlp 7y agoNot really, clang is very appealing for companies that aren't willing to give all their crown jewels to upstream. Everyone that can move away from basing their toolchains has already moved into clang, or is in process of doing so.
- jhasse 7y agoIt's bad for GCC, but good for C++ developers. GCC and MSVC will die and there will be only one compiler on all platforms (which is also the best one). Just have a look at Chrome and Firefox. They already use Clang on all platforms. On Windows they are working on replacing link with lld. Android has deprecated GCC completely. In the future it's gonna be clang + lld + libc++ all the way. And yeah, GDB and WinDbg will also be replaced by LLDB.
- voldacar 7y agoGCC still generates faster binaries (on average across a wide set of benchmarks) than clang as of last year
- loeg 7y agoBetter debuginfo (still), too.
- big_chungus 7y agoNot that much faster. Most benchmarks find that GCC is a little ahead, but not much: https://www.phoronix.com/scan.php?page=article&item=gcc9-clang8-hedt&num=6 https://www.phoronix.com/scan.php?page=article&item=gcc9-cla... https://medium.com/@alitech_2017/gcc-vs-clang-llvm-an-in-depth-comparison-of-c-c-compilers-899ede2be378 https://medium.com/@alitech_2017/gcc-vs-clang-llvm-an-in-dep... Remember that these are both Linux benchmarks; GCC on windows is a bit sketchy with MinGW. Things can usually be made to work, but Clang is the only real competitor to MSVC (unless you're counting Intel's crazy-expensive offering, which is not intended for general use).
- Santosh83 7y agoIf there is only one of something then it makes no sense to say it is the best... that's one reason why monopolies lead to worsening quality.
- zelly 7y ago> GDB and WinDbg will also be replaced by LLDB This is the longest shot of what you mentioned. I can see a future where the llvm toolchain dominates but people still use GDB because of muscle memory. (Unless LLDB changes its commands to match GDB.) Also GCC is guaranteed to live for at least 50 yrs because of freetards. GNU has die hard users and developers who would rather die than leave. LLVM has money, big money. It remains to be seen which matters more.
- rurban 7y agoI doubt that you can fault clang with this behavior, because clang has a proper constexpr detection in C also, gcc only on C++. So clang detects much more optimization opportunities with constant arguments, making it about 20x faster on the typical memcpy sizeof,... It's even faster than the glibc HW specific vectorized assembler optimizations, because the compiler knows much more than glibc, e.g. alignment, size. asm is an optimization barrier. This is probably the reason clang has a different bos check than gcc.
- kccqzy 7y agoHow does this relate to the address sanitizer? I believe ASan can catch all of the issues caught by _FORTIFY_SOURCE. Does the latter have fewer checks and better runtime performance? I'm guessing it is considered by most to be fine using _FORTIFY_SOURCE in production binaries but too much overhead for ASan?
- zzz11 7y ago_FORTIFY_SOURCE is a rather weak but fast mitigation for a narrow class of security issues. AddressSanitizer is a bug finding tool (2x CPU overhead!), for a different and much wider class of issues. Edit: there is some overlap, of course.