This commit is contained in:
Edgar 2024-07-26 11:39:03 +02:00
parent a49ff624e7
commit b3bd34a9bb
2 changed files with 9 additions and 12 deletions

View file

@ -6,7 +6,7 @@ use std::{
use edlang_ir as ir; use edlang_ir as ir;
use edlang_ir::DefId; use edlang_ir::DefId;
use edlang_session::Session; use edlang_session::{OptLevel, Session};
use edlang_span::Span; use edlang_span::Span;
use inkwell::{ use inkwell::{
builder::{Builder, BuilderError}, builder::{Builder, BuilderError},
@ -111,25 +111,19 @@ pub fn compile(session: &Session, program: &ProgramBody) -> Result<PathBuf, Box<
.canonicalize() .canonicalize()
.expect("failed to canonicalize file path"); .expect("failed to canonicalize file path");
let filename = file_path.file_name().unwrap().to_str().unwrap(); let filename = file_path.file_name().unwrap().to_str().unwrap();
let dirname = abs_file_path let dirname = abs_file_path.parent().unwrap().display().to_string();
.parent()
.unwrap()
.file_name()
.unwrap()
.to_str()
.unwrap();
let llvm_module = context.create_module(&module.name); let llvm_module = context.create_module(&module.name);
llvm_module.set_source_file_name(filename); llvm_module.set_source_file_name(filename);
llvm_module.set_triple(&triple); llvm_module.set_triple(&triple);
llvm_module.set_data_layout(&machine.get_target_data().get_data_layout()); llvm_module.set_data_layout(&machine.get_target_data().get_data_layout());
let (di_builder, di_unit) = llvm_module.create_debug_info_builder( let (di_builder, di_unit) = llvm_module.create_debug_info_builder(
true, false,
inkwell::debug_info::DWARFSourceLanguage::Rust, inkwell::debug_info::DWARFSourceLanguage::Rust,
filename, filename,
dirname, &dirname,
"edlang", "edlang",
true, !matches!(session.optlevel, OptLevel::None),
"", // compiler flags "", // compiler flags
1, 1,
"", // split name "", // split name
@ -298,7 +292,7 @@ fn compile_fn_signature(ctx: &ModuleCompileCtx<'_, '_>, fn_id: DefId, is_definit
ctx.di_unit.get_file(), ctx.di_unit.get_file(),
line as u32 + 1, line as u32 + 1,
di_type, di_type,
body.is_exported || body.is_extern, false, // body.is_exported || body.is_extern,
is_definition && !body.is_extern, is_definition && !body.is_extern,
line as u32 + 1, line as u32 + 1,
0, 0,

View file

@ -58,6 +58,9 @@ pub fn link_binary(objects: &[PathBuf], output_filename: &Path) -> std::io::Resu
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
{ {
let mut args = vec![ let mut args = vec![
"-demangle",
"-dynamic",
"-no_deduplicate",
"-L/usr/local/lib", "-L/usr/local/lib",
"-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib", "-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib",
]; ];