Skip to content

Commit b5eee91

Browse files
committed
Add back error for ThinLTO
1 parent 5892dd1 commit b5eee91

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

build_sysroot/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-st
1717

1818
[profile.release]
1919
debug = true
20+
# FIXME: is this actually needed?
2021
lto = "fat"

locales/en-US.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ codegen_gcc_unwinding_inline_asm =
22
GCC backend does not support unwinding from inline asm
33
44
codegen_gcc_lto_not_supported =
5-
LTO is not supported. You may get a linker error.
5+
Thin LTO is not supported. You may get a linker error.
66
77
codegen_gcc_invalid_monomorphization_basic_integer =
88
invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`

src/back/lto.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// FIXME:
2+
// fat-lto UI test fail with:
3+
// x86_64-pc-linux-gnu-gcc-13.1.0: fatal error: ‘-fuse-linker-plugin’, but liblto_plugin.so not found
4+
//
15
// Fix these warnings:
26
// /usr/bin/ld: warning: type of symbol `_RNvNvNvNtCs5JWOrf9uCus_5rayon11thread_pool19WORKER_THREAD_STATE7___getit5___KEY' changed from 1 to 6 in /tmp/ccKeUSiR.ltrans0.ltrans.o
37
// /usr/bin/ld: warning: type of symbol `_RNvNvNvNvNtNtNtCsAj5i4SGTR7_3std4sync4mpmc5waker17current_thread_id5DUMMY7___getit5___KEY' changed from 1 to 6 in /tmp/ccKeUSiR.ltrans0.ltrans.o

src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// TODO: rebase on master.
2-
31
/*
42
* TODO(antoyo): implement equality in libgccjit based on https://zpz.github.io/blog/overloading-equality-operator-in-cpp-class-hierarchy/ (for type equality?)
53
* TODO(antoyo): support #[inline] attributes.
64
* TODO(antoyo): support LTO (gcc's equivalent to Full LTO is -flto -flto-partition=one — https://documentation.suse.com/sbp/all/html/SBP-GCC-10/index.html).
5+
* For Thin LTO, this might be helpful:
6+
* In gcc 4.6 -fwhopr was removed and became default with -flto. The non-whopr path can still be executed via -flto-partition=none.
77
*
88
* TODO(antoyo): remove the patches.
99
*/
@@ -71,6 +71,7 @@ use std::any::Any;
7171
use std::sync::atomic::AtomicBool;
7272
use std::sync::{Arc, Mutex};
7373

74+
use errors::LTONotSupported;
7475
use gccjit::{Context, OptimizationLevel, CType};
7576
use rustc_ast::expand::allocator::AllocatorKind;
7677
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen};
@@ -86,7 +87,7 @@ use rustc_metadata::EncodedMetadata;
8687
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
8788
use rustc_middle::ty::TyCtxt;
8889
use rustc_middle::ty::query::Providers;
89-
use rustc_session::config::{OptLevel, OutputFilenames};
90+
use rustc_session::config::{Lto, OptLevel, OutputFilenames};
9091
use rustc_session::Session;
9192
use rustc_span::Symbol;
9293
use rustc_span::fatal_error::FatalError;
@@ -117,9 +118,12 @@ impl CodegenBackend for GccCodegenBackend {
117118
crate::DEFAULT_LOCALE_RESOURCE
118119
}
119120

120-
fn init(&self, _sess: &Session) {
121+
fn init(&self, sess: &Session) {
121122
#[cfg(feature="master")]
122123
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
124+
if sess.lto() == Lto::Thin {
125+
sess.emit_warning(LTONotSupported {});
126+
}
123127

124128
let temp_dir = TempDir::new().expect("cannot create temporary directory");
125129
let temp_file = temp_dir.into_path().join("result.asm");

0 commit comments

Comments
 (0)