10 ms·
curious why people want this? I was under the impression that llvm is better than gcc?
by cschep 7y ago
curious why people want this? I was under the impression that llvm is better than gcc?
- kyllo 7y agoBetter how? There are plenty of benchmarks showing that gcc's optimizations are more performant than llvm's.
- saagarjha 7y agoAnd here are plenty that support the converse ;) I don't think there's anything that points to one being definitively better than the other in performance.
- vunie 7y ago>And here are plenty that support the converse Could you site sources please?
- StreamBright 7y agoLike the one where they turned off null checks? https://joelaro.wordpress.com/2015/09/30/gcc-optimization-fdelete-null-pointer-checks/ https://joelaro.wordpress.com/2015/09/30/gcc-optimization-fd...
- saagarjha 7y agoClang has this too.
- StreamBright 7y agoNot as much as GCC. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90949 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90949
- saagarjha 7y agoThat’s a bug, not an optimization.
- wumpus 7y agoEvery performant compiler on the SPECcpu benchmarks does this.
- MrBuddyCasino 7y agoSupport for more CPU types. LLVM is limited to the mainstream architectures.
- saagarjha 7y agoCan the semantics of Rust handle some of the stranger architectures that GCC supports?
- onei 7y agoIn theory, both GCC and LLVM take a front-end (in this case rust) and compile it down to an intermediate representation (IR). There will likely be some differences between the output from a front-end, but after successive optimisations have been applied this will likely disappear. By the time you get to generating assembly, you can't really tell the difference anymore so the semantics of the original language don't make an impact.
- saagarjha 7y agoI'm sure there are a number of "reasonable" assumptions that aren't true–probably things like the number of bits in a byte, or the size of a particular integral type, or support for a particular platform behavior.
- sanxiyn 7y agoGCC is better than LLVM for some things and vice versa.
- mcqueenjordan 7y agoIt's a good sign of stability if a language is supported by multiple compilers. I'll probably never use gcc for Rust, but I'm still happy to see it.
- Reelin 7y ago> curious why people want this? It's important for core infrastructure to have multiple competing implementations. On a related note, does Rust have a standard yet or are they still doing the reference implementation thing? > I was under the impression that llvm is better than gcc? And I thought that tabs were better than spaces, BSD beat Linux, Emacs was the one true god... what were we arguing about again?
- sanxiyn 7y agoRust has no reasonable specification yet although it is being worked on.
- bluejekyll 7y agoI would say that rust doesn’t have a formal specification, what it does have is close to or better than many languages “specs” with the “Rust Reference”: https://doc.rust-lang.org/stable/reference/ https://doc.rust-lang.org/stable/reference/ It really depends on how strictly you define the term specification. The Rust Reference is not required to be accurate. Though many other language compilers/implementations don’t fully implement their respective specs so, :shrug:.
- mjw1007 7y agoThe Rust Reference is very far from being complete, or even correct in what it does cover. If I have a question whose answer isn't obvious, it's far more likely that I have to go trawling around in RFCs than that there's an answer in the reference. I think most languages of a similar age (eg Go, Swift) are doing better.
- littlestymaar 7y agoRust is younger than Go (released in 2015 vs 2012) and way more ambitious, especially Rust 1.0 was released as kind of an MVP and many things have changed since then, which made the maintenance of such a reference an issue. The pace of change is slowing nowadays (that's especially visible if you look new and accepted RFCs), so I hope the reference will catch up eventually.
- chungy 7y agoI've been under the impression that GCC still has much better hardware optimizations than LLVM has.
- adev_ 7y ago> I've been under the impression that GCC still has much better hardware optimizations than LLVM has. That is my experience too. GCC for code with high level of nesting, meaning high potential for inlining (typically C++), is close to unbeatable. Including even compared Highly optimised compilers like Intel ICC.
- sanxiyn 7y agoLLVM developers are aware of this and they are working on a new inliner specifically to address this.
- earenndil 7y agoIt has not been mine. IME gcc can do slightly better than clang, sometimes, but it's generally a wash.
- sanxiyn 7y agoGoogle found GCC to be faster than Clang for their code, that's why they are rewriting LLVM inliner.
- etaioinshrdlu 7y agoGCC has a reputation of having confusing architecture. It is a very hard project to work on. LLVM is typically considered cleaner and more understandable. GCC is known to have still in 2019, a rather slight performance benefit. LLVM also has a stable IR named LLVM itself, while GCC refuses to do so over the decades for political and strategic reasons.
- gioele 7y ago> LLVM also has a stable IR named LLVM itself, LLVM's IR is not stable by design. [1, 2] [1] http://lists.llvm.org/pipermail/llvm-dev/2016-February/094877.html http://lists.llvm.org/pipermail/llvm-dev/2016-February/09487... [2] http://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility http://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compa... > while GCC refuses to do so over the decades for political and strategic reasons. That was a long time ago. Since GCC 4.5 (released in 2010) GCC supports external plugins. [3,4] These plugins, like the rest of GCC, use GENERIC and GIMPLE as their IR. [3] https://gcc.gnu.org/gcc-4.5/changes.html https://gcc.gnu.org/gcc-4.5/changes.html [4] https://gcc.gnu.org/onlinedocs/gccint/Plugins.html https://gcc.gnu.org/onlinedocs/gccint/Plugins.html
- deleted 7y ago[deleted]
- TazeTSchnitzel 7y agoLLVM IR is called “LLVM assembly language” in the documentation.
- tom_mellior 7y agoHaving worked with both, I don't know what you mean by "confusing architecture". Both are OK to work with, but both have some glaring holes in their documentation. LLVM's data structures are typically nicer to use than GCC's linked lists in a lot of places, that much is true.
- jeltz 7y agoGCC does some things better than LLVM. It supports more architectures, has a not broken implentation of restrict (which should be useful for Rust), and optimizes some code better. They both have their own pros and cons.
- cesarb 7y ago> has a not broken implementation of restrict (which should be useful for Rust) The most recent restrict bug the rustc developers found (which made they disable restrict again) was found in both LLVM and GCC (they made a C reproducer, so they could test in both). See: https://github.com/rust-lang/rust/issues/54878 https://github.com/rust-lang/rust/issues/54878 (rustc) https://bugs.llvm.org/show_bug.cgi?id=39282 https://bugs.llvm.org/show_bug.cgi?id=39282 (LLVM) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87609 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87609 (GCC).
- sanxiyn 7y agoNote that GCC bug is now fixed. LLVM bug isn't.
- cwzwarich 7y agoThe interiteration issue with LLVM's noalias has been known for years: https://reviews.llvm.org/D9375 https://reviews.llvm.org/D9375 I even filed a version of it myself: https://bugs.llvm.org/show_bug.cgi?id=27955 https://bugs.llvm.org/show_bug.cgi?id=27955 I'm actually surprised that Rust enabled noalias usage with this known outstanding issue. When I worked on Rust years ago, it was definitely common knowledge on the compiler "team" that this was broken. I'm equally surprised that GCC had that bug, since their pointer aliasing model is equipped to correctly handle this situation (and is why they were able to fix it quickly).
- Yoric 7y agoLlvm is better than gcc at modularity and extensibility (or at least it was when llvm was released, I haven't followed gcc evolutions in a while). People who work on new languages typically use llvm because it's designed to make such things simple. Now, in terms of end results, llvm and gcc each have their qualities. When llvm was released, gcc typically produced faster binaries but llvm optimizations were easier to understand. Since then, both have evolved and I haven't tried to catch up. Bottom line: having two back-ends for rust or any other language is good. Among other things, it's a good way to check for bugs within an implementation of the compiler, it can be used to increase the chances of finding subtle bugs in safety-critical code, etc.
- sanxiyn 7y agoOne thing GCC excels over LLVM is quality of debug information. If you switch from Clang to GCC, you will see less "optimized out" in GDB. This is pretty much guaranteed. https://robert.ocallahan.org/2018/11/comparing-quality-of-debug-information.html https://robert.ocallahan.org/2018/11/comparing-quality-of-de...
- cschep 7y agoI was honestly curious, I will learn to ask better next time to protect my points :)