-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
blockaddress
to reference non-locals
This commit changes the `GetBlockAddressStatement` to allow it to reference non-local function pointers via name, rather than requiring the reference target to always be a local `BlockId`. The previous implementation of the function pointer compilation was not able to generate relocatable function pointers to functions that are declared but not defined in the current translation unit. This commit changes that to now make this case work properly. This is the first point at which `alloc` is able to be compiled from LLVM IR to FLO without any crashes or missing features being encountered. It also fixes the building of the transient IR input artifacts for testing the compiler to allow it to work properly on CI. This was not caught before as there were no tests yet depending on their presence. The new approach uses a `build.rs` build script to copy them in, and has also removed one that had accidentally been committed.
- Loading branch information
1 parent
a69e352
commit bad1da4
Showing
9 changed files
with
240 additions
and
141 deletions.
There are no files selected for viewing
This file contains 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 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,61 @@ | ||
use std::{fs, path::Path}; | ||
|
||
/// The environment variable that we get the input files from. | ||
const SOURCE_FILE_ENV_VAR: &str = "RUST_TEST_INPUTS"; | ||
|
||
/// The target directory in the project where the artefacts should end up. | ||
const TARGET_DIR: &str = "input/compilation"; | ||
|
||
/// Executes to copy the compilation inputs into the correct place in the build | ||
/// directory if they do not exist. | ||
#[allow(clippy::permissions_set_readonly_false)] // We do not care if it is world-writable | ||
fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
||
// We do want to continue if they are missing, at least for compilation. | ||
let env_val = std::env::var(SOURCE_FILE_ENV_VAR).unwrap_or("".into()); | ||
if env_val.is_empty() { | ||
return; | ||
} | ||
|
||
// Grab our path | ||
let path = Path::new(&env_val); | ||
|
||
// If it is not a directory but is set we just continue. | ||
if !path.is_dir() { | ||
return; | ||
} | ||
|
||
// Now we can loop over the entries in the directory. | ||
for entry in path | ||
.read_dir() | ||
.expect("Path known to be a directory was not a directory") | ||
.flatten() | ||
{ | ||
let path = entry.path(); | ||
let filename = path.file_name().expect("Path known to be a file had no filename"); | ||
let target_path = Path::new(TARGET_DIR).join(filename); | ||
|
||
// Make it writable if it exists so we can overwrite if needed. | ||
if target_path.exists() { | ||
let mut perms = target_path | ||
.metadata() | ||
.expect("No permissions found for the target path") | ||
.permissions(); | ||
perms.set_readonly(false); | ||
fs::set_permissions(&target_path, perms.clone()).expect("Could not set permissions"); | ||
} | ||
|
||
// Actually copy the file. | ||
fs::copy(path, &target_path).expect("Could not copy file known to exist"); | ||
|
||
// Make it writable after the copy in case it retained the read-only properties | ||
// from the nix store. | ||
let mut perms = target_path | ||
.metadata() | ||
.expect("No permissions found for the target path") | ||
.permissions(); | ||
perms.set_readonly(false); | ||
fs::set_permissions(&target_path, perms.clone()).expect("Could not set permissions"); | ||
} | ||
} |
This file contains 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
115 changes: 0 additions & 115 deletions
115
crates/compiler/input/compilation/hieratika_rust_test_input.ll
This file was deleted.
Oops, something went wrong.
This file contains 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 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
Oops, something went wrong.