An experiment in static, refcounted, procedural language with ownership
1

Configure Feed

Select the types of activity you want to include in your feed.

wip

r0nsha (Mar 23, 2024, 1:38 PM +0200) 83c770dd 4a874356

+2 -54
+2 -54
compiler_backend_c/src/lib.rs
··· 15 15 16 16 use compiler_core::{ 17 17 db::{build_options::EmitOption, Db, ExternLib}, 18 - target::{Arch, Os}, 18 + target::Os, 19 19 }; 20 20 use compiler_mir::Mir; 21 21 ··· 60 60 61 61 fn compile(db: &Db, c_file_path: &Utf8Path, exe_file_path: &Utf8Path) { 62 62 let libs = Libraries::new(db); 63 - let target_metrics = db.target_metrics(); 64 - 65 - let link_flags = match target_metrics.arch { 66 - Arch::Amd64 => match target_metrics.os { 67 - Os::Windows => vec!["/machine:x64"], 68 - Os::Linux | Os::FreeBSD => vec!["-march=x86_64"], 69 - _ => vec![], 70 - }, 71 - Arch::_386 => match target_metrics.os { 72 - Os::Windows => vec!["/machine:x86"], 73 - Os::Darwin => panic!("unsupported architecture"), 74 - Os::Linux | Os::FreeBSD => vec!["-march=x86"], 75 - _ => vec![], 76 - }, 77 - Arch::Arm64 => match target_metrics.os { 78 - Os::Darwin => vec!["-march=arm64"], 79 - Os::Linux => vec!["-march=aarch64"], 80 - _ => vec![], 81 - }, 82 - Arch::Wasm32 | Arch::Wasm64 => { 83 - let mut link_flags = vec!["--allow-undefined"]; 84 - 85 - if matches!(target_metrics.arch, Arch::Wasm64) { 86 - link_flags.push("-mwas64"); 87 - } 88 - 89 - if matches!(target_metrics.os, Os::Freestanding) { 90 - link_flags.push("--no-entry"); 91 - } 92 - 93 - link_flags 94 - } 95 - }; 96 63 97 64 // #[cfg(windows)] 98 65 // { ··· 111 78 // lib_paths.push(path.to_string().unwrap()); 112 79 // } 113 80 // 114 - // Command::new("lld-link") 115 - // .arg(format!("/out:{}", exe_file_path)) 116 - // .arg("/entry:mainCRTStartup") 117 - // .arg("/defaultlib:libcmt") 118 - // .arg("/nologo") 119 - // .arg("/incremental:no") 120 - // .arg("/opt:ref") 121 - // .arg("/threads:8") 122 - // .arg("/subsystem:CONSOLE") 123 - // .args(lib_paths.iter().map(|path| format!("/libpath:{}", path))) 124 - // .arg(c_file_path.to_str().unwrap()) 125 - // .args(libs) 126 - // .args(link_flags) 127 - // .execute_output() 128 - // .expect("linking to work"); 129 - // } 130 81 131 82 // #[cfg(not(windows))] 132 - 133 83 let mut cmd = Command::new("zig"); 134 84 135 85 cmd ··· 141 91 .args(libs.paths.into_iter().map(|path| format!("-L{path}"))) 142 92 .args(libs.libs.into_iter().map(|path| format!("-l{path}"))) 143 93 .args(libs.includes.into_iter().map(|path| format!("-I{path}"))) 144 - .arg("-lc") 145 94 .arg("-no-pie") 146 95 // .arg("-static") 147 96 // .arg("-O1") 148 - .arg("-g") 149 - .args(link_flags); 97 + .arg("-g"); 150 98 151 99 //println!("{:?}", cmd); 152 100