mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
remove debugir
This commit is contained in:
parent
034b86973b
commit
fc09c3b002
4 changed files with 12 additions and 129 deletions
|
@ -76,7 +76,7 @@ To run the test suite (via `cargo test`), you additionally need to install:
|
|||
- [`valgrind`](https://www.valgrind.org/) (needs special treatment to [install on macOS](https://stackoverflow.com/a/61359781)
|
||||
Alternatively, you can use `cargo test --no-fail-fast` or `cargo test -p specific_tests` to skip over the valgrind failures & tests.
|
||||
|
||||
For debugging LLVM IR, we use [DebugIR](https://github.com/vaivaswatha/debugir). This dependency is only required to build with the `--debug` flag, and for normal development you should be fine without it.
|
||||
For emitting LLVM IR for debugging purposes, the `--emit-llvm-ir` flag can be used.
|
||||
|
||||
### libxcb libraries
|
||||
|
||||
|
|
|
@ -273,6 +273,11 @@ fn gen_from_mono_module_llvm<'a>(
|
|||
);
|
||||
}
|
||||
|
||||
if emit_llvm_ir {
|
||||
eprintln!("Emitting LLVM IR to {}", &app_ll_file.display());
|
||||
module.print_to_file(&app_ll_file).unwrap();
|
||||
}
|
||||
|
||||
// Uncomment this to see the module's optimized LLVM instruction output:
|
||||
// env.module.print_to_stderr();
|
||||
|
||||
|
@ -367,63 +372,6 @@ fn gen_from_mono_module_llvm<'a>(
|
|||
|
||||
assert!(bc_to_object.status.success(), "{bc_to_object:#?}");
|
||||
|
||||
MemoryBuffer::create_from_file(&app_o_file).expect("memory buffer creation works")
|
||||
} else if emit_llvm_ir {
|
||||
let mut app_ll_dbg_file = PathBuf::from(roc_file_path);
|
||||
app_ll_dbg_file.set_extension("dbg.ll");
|
||||
|
||||
let mut app_o_file = PathBuf::from(roc_file_path);
|
||||
app_o_file.set_extension("o");
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
// write the ll code to a file, so we can modify it
|
||||
module.print_to_file(&app_ll_file).unwrap();
|
||||
|
||||
// run the debugir https://github.com/vaivaswatha/debugir tool
|
||||
match Command::new("debugir")
|
||||
.args(["-instnamer", app_ll_file.to_str().unwrap()])
|
||||
.output()
|
||||
{
|
||||
Ok(_) => {}
|
||||
Err(error) => {
|
||||
use std::io::ErrorKind;
|
||||
match error.kind() {
|
||||
ErrorKind::NotFound => internal_error!(
|
||||
r"I could not find the `debugir` tool on the PATH, install it from https://github.com/vaivaswatha/debugir"
|
||||
),
|
||||
_ => internal_error!("{:?}", error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use target_lexicon::Architecture;
|
||||
match target.architecture {
|
||||
Architecture::X86_64
|
||||
| Architecture::X86_32(_)
|
||||
| Architecture::Aarch64(_)
|
||||
| Architecture::Wasm32 => {
|
||||
// write the .o file. Note that this builds the .o for the local machine,
|
||||
// and ignores the `target_machine` entirely.
|
||||
//
|
||||
// different systems name this executable differently, so we shotgun for
|
||||
// the most common ones and then give up.
|
||||
let ll_to_object = Command::new("llc")
|
||||
.args([
|
||||
"-relocation-model=pic",
|
||||
"-filetype=obj",
|
||||
app_ll_dbg_file.to_str().unwrap(),
|
||||
"-o",
|
||||
app_o_file.to_str().unwrap(),
|
||||
])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
assert!(ll_to_object.stderr.is_empty(), "{ll_to_object:#?}");
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
MemoryBuffer::create_from_file(&app_o_file).expect("memory buffer creation works")
|
||||
} else {
|
||||
// Emit the .o file
|
||||
|
|
|
@ -319,7 +319,7 @@ fn create_llvm_module<'a>(
|
|||
pub struct HelperConfig {
|
||||
pub mode: LlvmBackendMode,
|
||||
pub ignore_problems: bool,
|
||||
pub add_debug_info: bool,
|
||||
pub emit_debug_info: bool,
|
||||
pub opt_level: OptLevel,
|
||||
}
|
||||
|
||||
|
@ -337,56 +337,16 @@ pub fn helper<'a>(
|
|||
let (main_fn_name, delayed_errors, module) =
|
||||
create_llvm_module(arena, src, config, context, &target, function_kind);
|
||||
|
||||
let res_lib = if config.add_debug_info {
|
||||
let module = annotate_with_debug_info(module, context);
|
||||
llvm_module_to_dylib(&module, &target, config.opt_level)
|
||||
} else {
|
||||
llvm_module_to_dylib(module, &target, config.opt_level)
|
||||
};
|
||||
if !config.emit_debug_info {
|
||||
module.strip_debug_info();
|
||||
}
|
||||
let res_lib = llvm_module_to_dylib(&module, &target, config.opt_level);
|
||||
|
||||
let lib = res_lib.expect("Error loading compiled dylib for test");
|
||||
|
||||
(main_fn_name, delayed_errors, lib)
|
||||
}
|
||||
|
||||
fn annotate_with_debug_info<'ctx>(
|
||||
module: &Module<'ctx>,
|
||||
context: &'ctx inkwell::context::Context,
|
||||
) -> Module<'ctx> {
|
||||
use std::process::Command;
|
||||
|
||||
let app_ll_file = "/tmp/roc-debugir.ll";
|
||||
let app_dbg_ll_file = "/tmp/roc-debugir.dbg.ll";
|
||||
let app_bc_file = "/tmp/roc-debugir.bc";
|
||||
|
||||
// write the ll code to a file, so we can modify it
|
||||
module.print_to_file(app_ll_file).unwrap();
|
||||
|
||||
// run the debugir https://github.com/vaivaswatha/debugir tool
|
||||
match Command::new("debugir")
|
||||
.args(["-instnamer", app_ll_file])
|
||||
.output()
|
||||
{
|
||||
Ok(_) => {}
|
||||
Err(error) => {
|
||||
use std::io::ErrorKind;
|
||||
match error.kind() {
|
||||
ErrorKind::NotFound => panic!(
|
||||
r"I could not find the `debugir` tool on the PATH, install it from https://github.com/vaivaswatha/debugir"
|
||||
),
|
||||
_ => panic!("{error:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Command::new("llvm-as")
|
||||
.args([app_dbg_ll_file, "-o", app_bc_file])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
inkwell::module::Module::parse_bitcode_from_path(app_bc_file, context).unwrap()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn wasm32_target_tripple() -> Triple {
|
||||
use target_lexicon::{Architecture, BinaryFormat};
|
||||
|
@ -605,7 +565,7 @@ pub(crate) fn llvm_evals_to<T, U, F>(
|
|||
|
||||
let config = crate::helpers::llvm::HelperConfig {
|
||||
mode: LlvmBackendMode::GenTest,
|
||||
add_debug_info: false,
|
||||
emit_debug_info: false,
|
||||
ignore_problems,
|
||||
opt_level: crate::helpers::llvm::OPT_LEVEL,
|
||||
};
|
||||
|
|
25
flake.nix
25
flake.nix
|
@ -64,29 +64,6 @@
|
|||
curl # for wasm-bindgen-cli libcurl (see ./ci/www-repl.sh)
|
||||
]);
|
||||
|
||||
# For debugging LLVM IR
|
||||
debugir = pkgs.stdenv.mkDerivation {
|
||||
name = "debugir";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "vaivaswatha";
|
||||
repo = "debugir";
|
||||
rev = "b981e0b74872d9896ba447dd6391dfeb63332b80";
|
||||
sha256 = "Gzey0SF0NZkpiObk5e29nbc41dn4Olv1dx+6YixaZH0=";
|
||||
};
|
||||
buildInputs = with pkgs; [ cmake libxml2 llvmPkgs.llvm.dev ];
|
||||
buildPhase = ''
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DLLVM_DIR=${llvmPkgs.llvm.dev} -DCMAKE_BUILD_TYPE=Release ../
|
||||
cmake --build ../
|
||||
cp ../debugir .
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp debugir $out/bin
|
||||
'';
|
||||
};
|
||||
|
||||
sharedInputs = (with pkgs; [
|
||||
# build libraries
|
||||
cmake
|
||||
|
@ -109,8 +86,6 @@
|
|||
python3
|
||||
libiconv # for examples/gui
|
||||
libxkbcommon # for examples/gui
|
||||
# debugir needs to be updated to llvm 15
|
||||
# debugir # used in crates/compiler/build/src/program.rs
|
||||
cargo-criterion # for benchmarks
|
||||
simple-http-server # to view roc website when trying out edits
|
||||
wasm-pack # for repl_wasm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue