Combine all libraries into libc.a, call pthread_init and pthread_terminate in libc

parent aefb4fb1
Pipeline #2460 failed with stages
in 15 minutes and 52 seconds
......@@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
[lib]
name = "c"
name = "relibc"
crate-type = ["staticlib"]
[workspace]
......
......@@ -76,7 +76,16 @@ sysroot: all
test: sysroot
make -C tests run
$(BUILD)/debug/libc.a: $(SRC)
$(BUILD)/release/libc.a: $(BUILD)/release/librelibc.a $(BUILD)/pthreads-emb/libpthread.a $(BUILD)/openlibm/libopenlibm.a
echo "create $@" > "$@.mri"
for lib in $^; do\
echo "addlib $$lib" >> "$@.mri"; \
done
echo "save" >> "$@.mri"
echo "end" >> "$@.mri"
ar -M < "$@.mri"
$(BUILD)/debug/librelibc.a: $(SRC)
$(CARGO) rustc $(CARGOFLAGS) -- $(RUSTCFLAGS)
touch $@
......@@ -84,7 +93,15 @@ $(BUILD)/debug/crt0.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
touch $@
$(BUILD)/release/libc.a: $(SRC)
$(BUILD)/debug/crti.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
touch $@
$(BUILD)/debug/crtn.o: $(SRC)
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ $(RUSTCFLAGS)
touch $@
$(BUILD)/release/librelibc.a: $(SRC)
$(CARGO) rustc --release $(CARGOFLAGS) -- $(RUSTCFLAGS)
touch $@
......
Subproject commit a12978ccca4c576f02971f5cfc2cbefe23e4daba
Subproject commit 91f0dd6e3f9c8ee81508f3a32e1d6f3e97e35726
......@@ -233,6 +233,7 @@ pub unsafe extern "C" fn exit(status: c_int) {
static __fini_array_start: extern "C" fn();
static __fini_array_end: extern "C" fn();
fn pthread_terminate();
fn _fini();
}
......@@ -251,6 +252,8 @@ pub unsafe extern "C" fn exit(status: c_int) {
_fini();
pthread_terminate();
Sys::exit(status);
}
......
......@@ -53,6 +53,7 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
static __init_array_start: extern "C" fn();
static __init_array_end: extern "C" fn();
fn pthread_init();
fn _init();
fn main(argc: isize, argv: *mut *mut c_char, envp: *mut *mut c_char) -> c_int;
}
......@@ -77,6 +78,8 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
stdio::stdout = stdio::default_stdout.get();
stdio::stderr = stdio::default_stderr.get();
pthread_init();
// Run preinit array
{
let mut f = &__preinit_array_start as *const _;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment