TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Closing the gap: cross-language LTO between Rust and C/C++

267 pointsby pedrowover 5 years ago

6 comments

pornelover 5 years ago
It's nice to see such post on the LLVM blog (as opposed to typical Rust-only outlets). Feels like recognition that Rust is a serious and important LLVM user.
评论 #21018101 未加载
评论 #21019556 未加载
angrygoatover 5 years ago
This is awesome, especially with the gains for Firefox, but this bit seemed odd to me:<p>&gt; We quickly learned, however, that the LLVM linker plugin crashes with a segmentation fault when trying to perform another round of ThinLTO on a module that had already gone through the process.<p>It sounds like they worked around this, rather than fixing the segfault and putting some error handling in place? Might make it easier for the next bunch of people working in this part of clang.
评论 #21016361 未加载
azakaiover 5 years ago
The need to use &quot;compatible&quot; versions of LLVM between the C++ and Rust compilers is scary. Anything aside from the exact same LLVM revision could in theory lead to bad results, including bugs or security vulnerabilities (if LLVM changes the meaning of something in its IR).<p>This isn&#x27;t Rust or Clang&#x27;s fault, of course, it&#x27;s just a consequence of using LLVM IR as the data for LTO, that LLVM IR has no backwards compatibility guarantees, and that Rust is out-of-tree for LLVM.<p>In theory using a stable format for LTO would avoid issues like this. Wasm is one option that has working cross-language inlining already today, but on the other hand it has less rich an IR, and the optimizers are less powerful than LLVM.
评论 #21021572 未加载
bla3over 5 years ago
&gt; No problem, we thought and instructed the Rust compiler to disable its own ThinLTO pass when compiling for the cross-language case and indeed everything was fine -- until the segmentation faults mysteriously returned a few weeks later even though ThinLTO was still disabled. [...] Since then ThinLTO is turned off for libstd by default.<p>Instead of fixing the crash, they landed a workaround.<p>&gt; We learned that all LLVM versions involved really have to be a close match in order for things to work out. The Rust compiler&#x27;s documentation now offers a compatibility table for the various versions of Rust and Clang.<p>It&#x27;s cool they got it working, but it sounds like this is currently proof-of-concept quality and not very productionized yet. To me, the overall tone of the article sounds like they ran into a bunch of issues and opted for duct tape instead of systemic fixes. Which is fine to get things off the ground, of course! But I hope they take the time to go back and fix the underlying issues they ran into too.
评论 #21017162 未加载
评论 #21020186 未加载
评论 #21016572 未加载
评论 #21016607 未加载
zellyover 5 years ago
Rust needs easy interop with C++&#x27;s ABI. Easy as in I should be able to &quot;import Boost&quot; and have it all mapped to Rust structures without doing anything.<p>A big reason C++ took off was backward compatibility with C. Network effects. Today C++ has the role that C had in the 80s.<p>No one uses any other compiler but LLVM for Rust anyway, so who cares about compatibility with MSVC and others. This will also force adoption of LLVM, which can be a good incentive for LLVM to support it.
评论 #21026979 未加载
评论 #21023441 未加载
评论 #21023415 未加载
jokoonover 5 years ago
I&#x27;m not a huge fan of rust, but that would make rust much more attractive and simple to use.<p>Keeping C++ software while making sure important parts are bug free sounds awesome...
评论 #21023309 未加载