-
Notifications
You must be signed in to change notification settings - Fork 1
Use inf-llc for codegen
#44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
84d43c9
WIP
0xGeorgii f818965
Update build script logging and enhance WASM test execution with memo…
0xGeorgii dde01c3
Refactor WASM compilation process and update dependencies
0xGeorgii c531e14
Add mutable globals support in WASM compilation and include actual WA…
0xGeorgii b3caf0a
Add `rust-lld` invokation
0xGeorgii 37abbef
Adding `non-det` support WIP
0xGeorgii be39e7b
Add `inf-blocks` support
0xGeorgii 9ec129b
WIP constant declaration statement
0xGeorgii 277276f
Finalize minimal tests for inf blocks
0xGeorgii a85d9fc
Update core/wasm-codegen/src/compiler.rs
0xGeorgii 8e4c9e3
Add unit test for `uzumaki_i64`
0xGeorgii ab74736
Binaries access refactoring
0xGeorgii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,4 @@ Cargo.lock | |
| *.wat | ||
| out | ||
| test_data/**/*.json | ||
| .* | ||
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| use std::env; | ||
| use std::fs; | ||
| use std::path::PathBuf; | ||
|
|
||
| fn main() { | ||
| let platform = if cfg!(target_os = "linux") { | ||
| "linux" | ||
| } else if cfg!(target_os = "macos") { | ||
| "macos" | ||
| } else if cfg!(target_os = "windows") { | ||
| "windows" | ||
| } else { | ||
| panic!("Unsupported platform"); | ||
| }; | ||
|
|
||
| let exe_suffix = std::env::consts::EXE_SUFFIX; | ||
| let llc_binary = format!("inf-llc{exe_suffix}"); | ||
| let rust_lld_binary = format!("rust-lld{exe_suffix}"); | ||
|
|
||
| let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); | ||
| let workspace_root = manifest_dir | ||
| .parent() // core/ | ||
| .and_then(|p| p.parent()) // workspace root | ||
| .expect("Failed to determine workspace root"); | ||
|
|
||
| let source_llc = workspace_root.join("bin").join(platform).join(&llc_binary); | ||
| let source_rust_lld = workspace_root | ||
| .join("bin") | ||
| .join(platform) | ||
| .join(&rust_lld_binary); | ||
|
|
||
| let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
| let target_profile_dir = out_dir | ||
| .parent() // build/<crate-name>-<hash> | ||
| .and_then(|p| p.parent()) // build/ | ||
| .and_then(|p| p.parent()) // target/<profile>/ | ||
| .expect("Failed to determine target profile directory"); | ||
|
|
||
| let bin_dir = target_profile_dir.join("bin"); | ||
| let dest_llc = bin_dir.join(&llc_binary); | ||
| let dest_rust_lld = bin_dir.join(&rust_lld_binary); | ||
|
|
||
| if source_llc.exists() { | ||
| if !bin_dir.exists() { | ||
| fs::create_dir_all(&bin_dir).expect("Failed to create bin directory"); | ||
| } | ||
|
|
||
| fs::copy(&source_llc, &dest_llc).unwrap_or_else(|e| { | ||
| panic!( | ||
| "Failed to copy inf-llc from {} to {}: {}", | ||
| source_llc.display(), | ||
| dest_llc.display(), | ||
| e | ||
| ) | ||
| }); | ||
|
|
||
| #[cfg(unix)] | ||
| { | ||
| use std::os::unix::fs::PermissionsExt; | ||
| let mut perms = fs::metadata(&dest_llc) | ||
| .expect("Failed to read inf-llc metadata") | ||
| .permissions(); | ||
| perms.set_mode(0o755); | ||
| fs::set_permissions(&dest_llc, perms).expect("Failed to set executable permissions"); | ||
| } | ||
|
|
||
| println!("cargo:info=Copied inf-llc to {}", dest_llc.display()); | ||
| } else { | ||
| println!( | ||
| "cargo:info=inf-llc not found at {}, skipping copy", | ||
| source_llc.display() | ||
| ); | ||
| } | ||
|
|
||
| if source_rust_lld.exists() { | ||
| if !bin_dir.exists() { | ||
| fs::create_dir_all(&bin_dir).expect("Failed to create bin directory"); | ||
| } | ||
|
|
||
| fs::copy(&source_rust_lld, &dest_rust_lld).unwrap_or_else(|e| { | ||
| panic!( | ||
| "Failed to copy rust-lld from {} to {}: {}", | ||
| source_rust_lld.display(), | ||
| dest_rust_lld.display(), | ||
| e | ||
| ) | ||
| }); | ||
|
|
||
| #[cfg(unix)] | ||
| { | ||
| use std::os::unix::fs::PermissionsExt; | ||
| let mut perms = fs::metadata(&dest_rust_lld) | ||
| .expect("Failed to read rust-lld metadata") | ||
| .permissions(); | ||
| perms.set_mode(0o755); | ||
| fs::set_permissions(&dest_rust_lld, perms) | ||
| .expect("Failed to set executable permissions"); | ||
| } | ||
|
|
||
| println!("cargo:info=Copied rust-lld to {}", dest_rust_lld.display()); | ||
| } else { | ||
| println!( | ||
| "cargo:info=rust-lld not found at {}, skipping copy", | ||
| source_rust_lld.display() | ||
| ); | ||
| } | ||
|
|
||
| println!("cargo:rerun-if-changed={}", source_llc.display()); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment acknowledges the implementation is hacky. Since type inference is a critical part of the compiler, consider filing an issue to refactor this properly or documenting what a proper solution would look like.