mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
Merge remote-tracking branch 'origin/trunk' into llvm-debug-info
This commit is contained in:
commit
2dbf430892
122 changed files with 6340 additions and 1392 deletions
|
@ -248,6 +248,16 @@ fn link_macos(
|
|||
}
|
||||
};
|
||||
|
||||
// This path only exists on macOS Big Sur, and it causes ld errors
|
||||
// on Catalina if it's specified with -L, so we replace it with a
|
||||
// redundant -lSystem if the directory isn't there.
|
||||
let big_sur_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib";
|
||||
let big_sur_fix = if Path::new(big_sur_path).exists() {
|
||||
format!("-L{}", big_sur_path)
|
||||
} else {
|
||||
String::from("-lSystem")
|
||||
};
|
||||
|
||||
Ok((
|
||||
// NOTE: order of arguments to `ld` matters here!
|
||||
// The `-l` flags should go after the `.o` arguments
|
||||
|
@ -263,7 +273,7 @@ fn link_macos(
|
|||
.args(&[
|
||||
// Libraries - see https://github.com/rtfeldman/roc/pull/554#discussion_r496392274
|
||||
// for discussion and further references
|
||||
"-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib",
|
||||
&big_sur_fix,
|
||||
"-lSystem",
|
||||
"-lresolv",
|
||||
"-lpthread",
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::target;
|
|||
use bumpalo::Bump;
|
||||
use inkwell::context::Context;
|
||||
use inkwell::targets::{CodeModel, FileType, RelocMode};
|
||||
use inkwell::values::FunctionValue;
|
||||
use roc_gen::llvm::build::{build_proc, build_proc_header, module_from_builtins, OptLevel, Scope};
|
||||
use roc_load::file::MonomorphizedModule;
|
||||
use roc_mono::layout::LayoutIds;
|
||||
|
@ -70,6 +71,15 @@ pub fn gen_from_mono_module(
|
|||
// strip Zig debug stuff
|
||||
// module.strip_debug_info();
|
||||
|
||||
// mark our zig-defined builtins as internal
|
||||
use inkwell::module::Linkage;
|
||||
for function in FunctionIterator::from_module(module) {
|
||||
let name = function.get_name().to_str().unwrap();
|
||||
if name.starts_with("roc_builtins") {
|
||||
function.set_linkage(Linkage::Internal);
|
||||
}
|
||||
}
|
||||
|
||||
let builder = context.create_builder();
|
||||
let (dibuilder, compile_unit) = roc_gen::llvm::build::Env::new_debug_info(module);
|
||||
let (mpm, fpm) = roc_gen::llvm::build::construct_optimization_passes(module, opt_level);
|
||||
|
@ -221,3 +231,30 @@ pub fn gen_from_mono_module(
|
|||
.write_to_file(&env.module, FileType::Object, &app_o_file)
|
||||
.expect("Writing .o file failed");
|
||||
}
|
||||
|
||||
pub struct FunctionIterator<'ctx> {
|
||||
next: Option<FunctionValue<'ctx>>,
|
||||
}
|
||||
|
||||
impl<'ctx> FunctionIterator<'ctx> {
|
||||
pub fn from_module(module: &inkwell::module::Module<'ctx>) -> Self {
|
||||
Self {
|
||||
next: module.get_first_function(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> Iterator for FunctionIterator<'ctx> {
|
||||
type Item = FunctionValue<'ctx>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
match self.next {
|
||||
Some(function) => {
|
||||
self.next = function.get_next_function();
|
||||
|
||||
Some(function)
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue