Meta changes from #321 #322
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Blocks
#324 Meta changes from #301
M-Labs/nac3
Reference: M-Labs/nac3#322
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "meta-changes-from-issue-315"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Various changes that are made during the debugging process for #321 but is not relevant to the fix.
This PR contains infrastructural improvements, including updated Rust dependencies, replacement of deprecated LLVM intrinsics,
implementation ofand improved documentation.__nac3_raise
in Standalone, C implementation of thedemo
library andlli
support,Please get rid of nac3standalone/demo/demo.c. We don't want to maintain both Rust and C versions. Can't rustc emit LLVM IR?
And we don't want two C compilers either so please use clang not GCC. If GCC gets pulled as dependency somewhere then that's a bug in flake.nix that needs to be fixed.
@ -65,2 +65,3 @@
name: Option<&str>,
) -> BasicValueEnum<'ctx> {
unsafe { self.builder.build_load(self.builder.build_gep(ptr, index, "gep"), "load") }
unsafe { self.builder.build_load(self.builder.build_gep(ptr, index, ""), name.unwrap_or_default()) }
I think unsafe can be restricted to build_gep?
Please add invokations to run_demo_lli in the tests, otherwise it'll bitrot.
Where is that?
rustc can emit LLVM IR, but a number of things will go wrong when using
demo.rs
for the implementation.demo.rs
(rustc -O --emit=llvm-bc demo.rs
):rustc -O --emit=obj demo.rs
):This is why I opted to implement a minimal version of
demo.rs
in C to minimize the dependencies forlli
.For some reason Clang is not able to find headers for the C standard library.
I can think of two ways to workaround this issue. We either (1) hardcode the necessary function prototypes into
demo.c
, or (2) we write a script to (a) lookup the path of GCC with respect to Nix, and (b) include those directories in the header search path.I believe that it is rustc which is pulling GCC as a dependency, as any linker errors emitted by
rustc -o demo demo.rs -Crelocation-model=static -Clink-arg=./module.o
inrun_demo.sh
is prefixed withcc:
, which is an indication that the linking process between Rust-generated code and external object files are performed by the GCC compiler.I dropped this commit because I realized more work needs to be done in handling exceptions (the original implementation directly exits the program with no regards to
except
blocks). Updated the description to reflect this.The reason is those headers are provided to Clang by the Nix wrapper. But we are using clang-unwrapped for compiling IRRT since we don't actually want the system libraries there.
Have you tried making demo.rs a no_std Rust program? It's a very simple one so I don't think Rust should emit complicated IR, except for the standard library which we can do away with.
If it's really not possible to keep it in Rust then the alternative is to use only the C version and remove the Rust one.
v3: Dropped
lli
changes, restricted unsafe tobuild_gep