-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for building programs completely from source. (#24)
And add an example showing how to do this.
- Loading branch information
1 parent
74bc0f1
commit bf27fa5
Showing
7 changed files
with
50 additions
and
4 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
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,2 @@ | ||
/target | ||
Cargo.lock |
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,17 @@ | ||
[package] | ||
name = "all-from-source" | ||
version = "0.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
# Disable the "use-compiler-builtins" feature, to ensure that we build | ||
# `memcpy` etc. from source instead of using the prebuilt library. | ||
eyra = { path = "../..", default-features = false, features = ["be-std", "threadsafe-setenv"] } | ||
|
||
[profile.release] | ||
lto = true | ||
codegen-units = 1 | ||
|
||
# This is just an example crate, and not part of the c-ward workspace. | ||
[workspace] |
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,12 @@ | ||
This example demonstrates building a program completely from source, without | ||
using any prebuilt libraries, if built with `-Zbuild-std`. | ||
|
||
For example, use `cargo rustc` to build the LLVM IR file and test that it has | ||
no external function declarations (other than LLVM intrinsics). | ||
|
||
``` | ||
$ cargo +nightly rustc -Zbuild-std --release --target=x86_64-unknown-linux-gnu -- --emit=llvm-ir | ||
[...] | ||
$ grep ^declare ./target/x86_64-unknown-linux-gnu/release/deps/all_from_source-*.ll | grep -v '@llvm' | ||
$ | ||
``` |
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,4 @@ | ||
fn main() { | ||
// Pass -nostartfiles to the linker. | ||
println!("cargo:rustc-link-arg=-nostartfiles"); | ||
} |
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,5 @@ | ||
extern crate eyra; | ||
|
||
fn main() { | ||
println!("Hello, world!"); | ||
} |