Skip to content

Commit ea362b2

Browse files
committed
Fix to remove messages to stderr when LTO is not suppported by using the new API gccjit::is_lto_supported
1 parent 81bbe14 commit ea362b2

File tree

3 files changed

+8
-34
lines changed

3 files changed

+8
-34
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ dependencies = [
5656

5757
[[package]]
5858
name = "gccjit"
59-
version = "2.9.0"
59+
version = "2.10.0"
6060
source = "registry+https://github.com/rust-lang/crates.io-index"
61-
checksum = "4a0e310ef75f396cd11b2443b353d55376656ca92c13cba36f92b7aff346ac1a"
61+
checksum = "60362e038e71e4bdc1a5b23fb45e1aba587b5947fe0db58f4871d95608f89eca"
6262
dependencies = [
6363
"gccjit_sys",
6464
]
6565

6666
[[package]]
6767
name = "gccjit_sys"
68-
version = "0.8.2"
68+
version = "0.9.0"
6969
source = "registry+https://github.com/rust-lang/crates.io-index"
70-
checksum = "95ed7572b30cd32430294dde6fb70822d58e67c6846a548647e8739776a0125b"
70+
checksum = "ddd542c8414e122217551c6af6b7d33acf51a227aee85276f218c087525e01bb"
7171
dependencies = [
7272
"libc",
7373
]

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ default = ["master"]
2424
[dependencies]
2525
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
2626
tempfile = "3.20"
27-
gccjit = "2.8"
27+
gccjit = "2.10"
2828
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs" }
2929

3030
# Local copy.
@@ -33,7 +33,6 @@ gccjit = "2.8"
3333
[dev-dependencies]
3434
boml = "0.3.1"
3535
lang_tester = "0.8.0"
36-
tempfile = "3.20.0"
3736

3837
[profile.dev]
3938
# By compiling dependencies with optimizations, performing tests gets much faster.

src/lib.rs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -202,39 +202,14 @@ impl CodegenBackend for GccCodegenBackend {
202202
**self.target_info.info.lock().expect("lock") = context.get_target_info();
203203
}
204204

205-
// While not required by the API, we gate this code on the master feature to make sure we
206-
// don't abort the process while checking if LTO is supported.
207-
// The following could will emit a fatal error if LTO is not supported and older versions
208-
// of libgccjit (the ones without this commit:
209-
// https://github.com/rust-lang/gcc/commit/a073b06800f064b3917a6113d4cc2a0c19a10fda) will
210-
// abort on fatal errors.
211205
#[cfg(feature = "master")]
212206
{
213-
// NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode.
214-
let temp_dir = TempDir::new().expect("cannot create temporary directory");
215-
let temp_file = temp_dir.keep().join("result.asm");
216-
let context = Context::default();
217-
let object_file_path = temp_file.to_str().expect("path to str");
218-
context.compile_to_file(gccjit::OutputKind::ObjectFile, object_file_path);
219-
220-
//let temp_dir = TempDir::new().expect("cannot create temporary directory");
221-
//let temp_file = temp_dir.into_path().join("result.asm");
222-
let check_context = Context::default();
223-
check_context.add_driver_option("-x");
224-
check_context.add_driver_option("lto");
225-
check_context.add_driver_option(object_file_path);
226-
check_context.set_print_errors_to_stderr(false);
227-
//context.compile_to_file(gccjit::OutputKind::ObjectFile, temp_file.to_str().expect("path to str"));
228-
// FIXME: compile gives the error as expected, but compile_to_file doesn't.
229-
check_context.compile();
230-
let error = check_context.get_last_error();
231-
let lto_supported = error == Ok(None);
207+
let lto_supported = gccjit::is_lto_supported();
232208
LTO_SUPPORTED.store(lto_supported, Ordering::SeqCst);
233209
self.lto_supported.store(lto_supported, Ordering::SeqCst);
234-
}
235210

236-
#[cfg(feature = "master")]
237-
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
211+
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
212+
}
238213

239214
#[cfg(not(feature = "master"))]
240215
{

0 commit comments

Comments
 (0)