-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the framework for compiling and running musl app (#4)
* [app] Add testcases for musl libc * [feat] Support for loading musl app and entering main function * [syscall] Add some necessary syscalls for base musl applications * [ci] Add deploy CI and update test CI * [syscall] Split syscalls into multiple files according to the syscall categories * [build] Add configuration for user space * [loader] Move IO methods to axmem module and simplify codes. * [CI] Continue on error for clippy and fmt test * [CI] Update dependencies for qemu build * [style] Fix code style according to the PR content * [fix] Set the base address for static-ELF as 0 by default * [feat] Support complie and test musl app on rv64 and aarch64 * [config] Fix the format for config file * [style] format the code style * [style] format crate import style: ```rust mod sub_mod1; mod sub_mod2; use core::foo::Bar; use alloc::bar::Foo; use ext_crate::bar; use crate::baz; use self::sub_mod1::foo; use super::sup_mod::qux; pub use ... ``` * [style] format code style
- Loading branch information
1 parent
5a2d23e
commit 8e3afa9
Showing
45 changed files
with
2,221 additions
and
178 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
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,34 @@ | ||
name: Build & Deploy docs | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
rust-toolchain: nightly-2024-05-02 | ||
|
||
jobs: | ||
doc: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
permissions: | ||
contents: write | ||
env: | ||
default-branch: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
toolchain: ${{ env.rust-toolchain }} | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo install cargo-binutils | ||
- run: ./scripts/get_deps.sh | ||
- name: Build docs | ||
continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }} | ||
run: make doc_check_missing | ||
- name: Deploy to Github Pages | ||
if: ${{ github.ref == env.default-branch }} | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
single-commit: true | ||
branch: gh-pages | ||
folder: target/doc |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
/target | ||
/.vscode | ||
/.arceos | ||
/.cargo | ||
.DS_Store | ||
Cargo.lock | ||
*.elf | ||
*.bin | ||
apps/*/build/ | ||
**/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
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,76 @@ | ||
# Build testcases for rust and c programs | ||
|
||
ARCH ?= x86_64 | ||
# Whether cross-compiling | ||
TARGET ?= musl | ||
|
||
# Build target for c programs | ||
CC := $(ARCH)-linux-$(TARGET)-gcc | ||
|
||
# Build target for rust programs | ||
ifeq ($(TARGET),musl) | ||
CFLAGS := -static -no-pie | ||
ifeq ($(ARCH),x86_64) | ||
RUST_TARGET := x86_64-unknown-linux-musl | ||
RUSTFLAGS := | ||
else ifeq ($(ARCH),aarch64) | ||
RUST_TARGET := aarch64-unknown-linux-musl | ||
RUSTFLAGS := -C linker=aarch64-linux-musl-ld | ||
else ifeq ($(ARCH),riscv64) | ||
$(warning "Warn: Rust musl target not supported for riscv64") | ||
RUST_TARGET := "" | ||
RUSTFLAGS := | ||
else | ||
$(error "Unknown ARCH") | ||
endif | ||
else ifeq ($(TARGET),gnu) | ||
CFLAGS := | ||
ifeq ($(ARCH),x86_64) | ||
RUST_TARGET := x86_64-unknown-linux-gnu | ||
else ifeq ($(ARCH),aarch64) | ||
RUST_TARGET := aarch64-unknown-linux-gnu | ||
else ifeq ($(ARCH),riscv64) | ||
RUST_TARGET := riscv64gc-unknown-linux-gnu | ||
else | ||
$(error "Unknown ARCH") | ||
endif | ||
else | ||
$(error "Unknown TARGET") | ||
endif | ||
|
||
$(info RUSTFLAGS: "$(RUSTFLAGS)") | ||
export RUSTFLAGS | ||
|
||
all: build | ||
|
||
build: build_dir build_c build_rust | ||
|
||
build_dir: | ||
@mkdir -p build | ||
@mkdir -p build/$(ARCH) | ||
|
||
build_c: | ||
@for app in $(wildcard c/*/*.c); do \ | ||
echo "Building $${app%.c}"; \ | ||
app_name=$$(basename $$(dirname $${app})); \ | ||
$(CC) -o build/$(ARCH)/$${app_name}_c $${app} $(CFLAGS); \ | ||
done | ||
|
||
build_rust: | ||
if [ -n $(RUST_TARGET) ]; then \ | ||
for app in $(shell find rust -name Cargo.toml); do \ | ||
echo "Building $$(dirname $${app})"; \ | ||
app_name=$$(basename $$(dirname $${app})); \ | ||
cargo build --release --target $(RUST_TARGET) --manifest-path $${app} ; \ | ||
cp $$(dirname $${app})/target/$(RUST_TARGET)/release/$${app_name} build/$(ARCH)/$${app_name}_rust ; \ | ||
done \ | ||
fi | ||
|
||
clean: | ||
@rm -rf build | ||
@for app in $(shell find rust -name Cargo.toml); do \ | ||
app_name=$$(basename $$(dirname $${app})); \ | ||
cargo clean --manifest-path $${app} ; \ | ||
done | ||
|
||
.PHONY: all build_dir build_c build_rust clean |
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,6 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
printf("Hello, World!\n"); | ||
return 0; | ||
} |
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,9 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
printf("Sleeping for 5 seconds...\n"); | ||
sleep(5); | ||
printf("Done!\n"); | ||
return 0; | ||
} |
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,7 @@ | ||
smp = 1 | ||
build_mode = release | ||
log_level = off | ||
|
||
Hello, World! | ||
Sleeping for 5 seconds... | ||
Done! |
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,6 @@ | ||
[package] | ||
name = "helloworld" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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,3 @@ | ||
fn main() { | ||
println!("Hello world from Rust!"); | ||
} |
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,6 @@ | ||
[package] | ||
name = "sleep" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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,6 @@ | ||
fn main() { | ||
println!("Sleep for 5 seconds from Rust!"); | ||
let duration = std::time::Duration::from_secs(5); | ||
std::thread::sleep(duration); | ||
println!("Woke up from sleep!"); | ||
} |
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 @@ | ||
test_one "LOG=off FEATURES=fp_simd" "expect_off.out" |
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 @@ | ||
helloworld_c | ||
sleep_c |
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,11 @@ | ||
#define __NR_read 63 | ||
#define __NR_write 64 | ||
#define __NR_exit 93 | ||
#define __NR_yield 124 | ||
#define __NR_getpid 172 | ||
#define __NR_clone 220 | ||
#define __NR_fork 220 | ||
#define __NR_exec 221 | ||
#define __NR_waitpid 260 | ||
#define __NR_clock_gettime 403 | ||
#define __NR_clock_nanosleep 407 |
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,11 @@ | ||
#define __NR_read 63 | ||
#define __NR_write 64 | ||
#define __NR_exit 93 | ||
#define __NR_yield 124 | ||
#define __NR_getpid 172 | ||
#define __NR_clone 220 | ||
#define __NR_fork 220 | ||
#define __NR_exec 221 | ||
#define __NR_waitpid 260 | ||
#define __NR_clock_gettime 403 | ||
#define __NR_clock_nanosleep 407 |
Oops, something went wrong.