parent
2d123d08c9
commit
bc8520d98e
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@ -53,7 +53,7 @@ jobs:
|
||||
- name: Build
|
||||
run: |
|
||||
./y.sh prepare --only-libcore
|
||||
./y.sh build --sysroot --release --release-sysroot
|
||||
EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot
|
||||
cargo test
|
||||
./y.sh clean all
|
||||
|
||||
@ -70,4 +70,4 @@ jobs:
|
||||
run: |
|
||||
# FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros.
|
||||
echo -n 'lto = "fat"' >> build_system/build_sysroot/Cargo.toml
|
||||
./y.sh test --release --clean --release-sysroot --build-sysroot ${{ matrix.commands }}
|
||||
EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot ${{ matrix.commands }}
|
||||
|
11
Readme.md
11
Readme.md
@ -119,6 +119,17 @@ $ CHANNEL="release" $CG_GCCJIT_DIR/y.sh cargo run
|
||||
|
||||
If you compiled cg_gccjit in debug mode (aka you didn't pass `--release` to `./y.sh test`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely.
|
||||
|
||||
### LTO
|
||||
|
||||
To use LTO, you need to set the variable `FAT_LTO=1` and `EMBED_LTO_BITCODE=1` in addition to setting `lto = "fat"` in the `Cargo.toml`.
|
||||
Don't set `FAT_LTO` when compiling the sysroot, though: only set `EMBED_LTO_BITCODE=1`.
|
||||
|
||||
Failing to set `EMBED_LTO_BITCODE` will give you the following error:
|
||||
|
||||
```
|
||||
error: failed to copy bitcode to object file: No such file or directory (os error 2)
|
||||
```
|
||||
|
||||
### Rustc
|
||||
|
||||
If you want to run `rustc` directly, you can do so with:
|
||||
|
@ -387,6 +387,12 @@ pub fn setup(
|
||||
rustflags.push("-Csymbol-mangling-version=v0".to_string());
|
||||
}
|
||||
|
||||
// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
|
||||
// TODO(antoyo): remove when we can handle ThinLTO.
|
||||
// TODO: remove:
|
||||
/*if !env.contains_key(&"FAT_LTO".to_string()) {
|
||||
rustflags.push("-Clto=off".to_string());
|
||||
}*/
|
||||
// FIXME(antoyo): remove once the atomic shim is gone
|
||||
if os_name == "Darwin" {
|
||||
rustflags.extend_from_slice(&[
|
||||
|
@ -307,7 +307,6 @@ fn fat_lto(
|
||||
match bc_decoded {
|
||||
SerializedModule::Local(ref module_buffer) => {
|
||||
module.module_llvm.should_combine_object_files = true;
|
||||
module.module_llvm.fat_lto = true;
|
||||
module
|
||||
.module_llvm
|
||||
.context
|
||||
@ -490,6 +489,7 @@ fn thin_lto(
|
||||
//let path = module_buffer.0.to_str().expect("path");
|
||||
//let my_path = PathBuf::from(path);
|
||||
//let exists = my_path.exists();
|
||||
//println!("Path: {:?}: {}", path, exists);
|
||||
/*module.module_llvm.should_combine_object_files = true;
|
||||
module
|
||||
.module_llvm
|
||||
@ -626,6 +626,11 @@ pub unsafe fn optimize_thin_module(
|
||||
match *module {
|
||||
SerializedModule::Local(ref module_buffer) => {
|
||||
let path = module_buffer.0.to_str().expect("path");
|
||||
|
||||
//let my_path = PathBuf::from(path);
|
||||
//let exists = my_path.exists();
|
||||
//println!("Path2: {:?}: {}", path, exists);
|
||||
|
||||
context.add_driver_option(path);
|
||||
should_combine_object_files = true;
|
||||
/*module.module_llvm.should_combine_object_files = true;
|
||||
@ -643,12 +648,7 @@ pub unsafe fn optimize_thin_module(
|
||||
}
|
||||
};
|
||||
let module = ModuleCodegen {
|
||||
module_llvm: GccContext {
|
||||
context,
|
||||
should_combine_object_files,
|
||||
fat_lto: false,
|
||||
temp_dir: None,
|
||||
},
|
||||
module_llvm: GccContext { context, should_combine_object_files, temp_dir: None },
|
||||
name: thin_module.name().to_string(),
|
||||
kind: ModuleKind::Regular,
|
||||
};
|
||||
|
@ -32,12 +32,12 @@ pub(crate) unsafe fn codegen(
|
||||
// NOTE: Only generate object files with GIMPLE when this environment variable is set for
|
||||
// now because this requires a particular setup (same gcc/lto1/lto-wrapper commit as libgccjit).
|
||||
// TODO: remove this environment variable.
|
||||
let fat_lto = module.module_llvm.fat_lto;
|
||||
let fat_lto = env::var("EMBED_LTO_BITCODE").as_deref() == Ok("1");
|
||||
|
||||
let bc_out = cgcx.output_filenames.temp_path(OutputType::Bitcode, module_name);
|
||||
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, module_name);
|
||||
|
||||
if config.bitcode_needed() {
|
||||
if config.bitcode_needed() && fat_lto {
|
||||
let _timer = cgcx
|
||||
.prof
|
||||
.generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name);
|
||||
@ -57,8 +57,6 @@ pub(crate) unsafe fn codegen(
|
||||
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
|
||||
context.add_command_line_option("-flto=auto");
|
||||
context.add_command_line_option("-flto-partition=one");
|
||||
// TODO: remove since we don't want fat objects when it is for Bitcode only.
|
||||
context.add_command_line_option("-ffat-lto-objects");
|
||||
context
|
||||
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
|
||||
}
|
||||
@ -120,11 +118,11 @@ pub(crate) unsafe fn codegen(
|
||||
if fat_lto {
|
||||
context.add_command_line_option("-flto=auto");
|
||||
context.add_command_line_option("-flto-partition=one");
|
||||
}
|
||||
|
||||
// NOTE: without -fuse-linker-plugin, we get the following error:
|
||||
// lto1: internal compiler error: decompressed stream: Destination buffer is too small
|
||||
//context.add_driver_option("-fuse-linker-plugin");
|
||||
context.add_driver_option("-fuse-linker-plugin");
|
||||
}
|
||||
|
||||
context.add_driver_option("-Wl,-r");
|
||||
// NOTE: we need -nostdlib, otherwise, we get the following error:
|
||||
@ -137,6 +135,7 @@ pub(crate) unsafe fn codegen(
|
||||
obj_out.to_str().expect("path to str"),
|
||||
);
|
||||
} else {
|
||||
//println!("Combining to object file");
|
||||
context.compile_to_file(
|
||||
OutputKind::ObjectFile,
|
||||
obj_out.to_str().expect("path to str"),
|
||||
|
@ -225,7 +225,6 @@ fn module_codegen(
|
||||
name: cgu_name.to_string(),
|
||||
module_llvm: GccContext {
|
||||
context: Arc::new(SyncContext::new(context)),
|
||||
fat_lto: false,
|
||||
should_combine_object_files: false,
|
||||
temp_dir: None,
|
||||
},
|
||||
|
@ -304,7 +304,6 @@ fn codegen_allocator(
|
||||
) -> Self::Module {
|
||||
let mut mods = GccContext {
|
||||
context: Arc::new(SyncContext::new(new_context(tcx))),
|
||||
fat_lto: false,
|
||||
should_combine_object_files: false,
|
||||
temp_dir: None,
|
||||
};
|
||||
@ -337,7 +336,6 @@ fn target_machine_factory(
|
||||
pub struct GccContext {
|
||||
context: Arc<SyncContext>,
|
||||
should_combine_object_files: bool,
|
||||
fat_lto: bool,
|
||||
// Temporary directory used by LTO. We keep it here so that it's not removed before linking.
|
||||
temp_dir: Option<TempDir>,
|
||||
}
|
||||
|
@ -94,4 +94,3 @@ tests/ui/consts/const-eval/parse_ints.rs
|
||||
tests/ui/simd/intrinsic/generic-arithmetic-pass.rs
|
||||
tests/ui/backtrace/backtrace.rs
|
||||
tests/ui/lifetimes/tail-expr-lock-poisoning.rs
|
||||
tests/ui/runtime/rt-explody-panic-payloads.rs
|
||||
|
Loading…
Reference in New Issue
Block a user