mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-05-29 09:58:55 -06:00
Build custom libgc
This commit is contained in:
@@ -5,7 +5,8 @@ jobs:
|
||||
- image: rust
|
||||
steps:
|
||||
- run: apt -y update --fix-missing
|
||||
- run: apt -y install libgc-dev
|
||||
- run: apt -y install cmake
|
||||
- checkout
|
||||
- run: git submodule update --init --recursive
|
||||
- run: cargo build
|
||||
- run: cd examples && ./test.sh
|
||||
|
||||
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "vendor/bdwgc"]
|
||||
path = vendor/bdwgc
|
||||
url = https://github.com/raviqqe/bdwgc
|
||||
[submodule "vendor/libatomic_ops"]
|
||||
path = vendor/libatomic_ops
|
||||
url = https://github.com/ivmai/libatomic_ops
|
||||
26
Cargo.lock
generated
26
Cargo.lock
generated
@@ -1,16 +1,42 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "autotools"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bdwgc-alloc"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "774fd1b2d459a939302a0bad631a3de176b8bd5f87cbfc28ceb1f6c18d731094"
|
||||
"checksum cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83"
|
||||
"checksum cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "96210eec534fc3fbfc0452a63769424eaa80205fda6cea98e5b61cb3d97bcec8"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
|
||||
@@ -6,6 +6,11 @@ authors = ["swgillespie <sean.william.g@gmail.com>", "Yota Toyama <raviqqe@gmail
|
||||
repository = "https://github.com/raviqqe/bdwgc-alloc"
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
autotools = "0.2"
|
||||
cmake = "0.1"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[](https://crates.io/crates/bdwgc-alloc)
|
||||
[](LICENSE)
|
||||
|
||||
[`GlobalAlloc`](https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html) implementation for [bdwgc](https://github.com/ivmai/bdwgc), the conservative garbage collector.
|
||||
[`GlobalAlloc`](https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html) implementation for [bdwgc](https://github.com/ivmai/bdwgc), the conservative garbage collector. This crate supports only Unix-like operating systems currently.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
37
build.rs
Normal file
37
build.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
extern crate cmake;
|
||||
|
||||
const LIB_ATOMIC_OPS_DIR: &str = "vendor/libatomic_ops";
|
||||
const LIB_GC_DIR: &str = "vendor/bdwgc";
|
||||
|
||||
fn main() {
|
||||
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
||||
std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!("cd {} && ./autogen.sh", dir))
|
||||
.output()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let dst = autotools::Config::new(LIB_ATOMIC_OPS_DIR)
|
||||
.cflag("-fPIC")
|
||||
.build();
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=atomic_ops");
|
||||
|
||||
let dst = autotools::Config::new(LIB_GC_DIR)
|
||||
.cflag(format!(
|
||||
"-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC",
|
||||
dst.join("include").display()
|
||||
))
|
||||
.build();
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=gc");
|
||||
}
|
||||
26
examples/borrow_check_free/Cargo.lock
generated
26
examples/borrow_check_free/Cargo.lock
generated
@@ -1,9 +1,19 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "autotools"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bdwgc-alloc"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -14,10 +24,26 @@ dependencies = [
|
||||
"bdwgc-alloc 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "774fd1b2d459a939302a0bad631a3de176b8bd5f87cbfc28ceb1f6c18d731094"
|
||||
"checksum cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83"
|
||||
"checksum cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "96210eec534fc3fbfc0452a63769424eaa80205fda6cea98e5b61cb3d97bcec8"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
|
||||
26
examples/dynamic_threads/Cargo.lock
generated
26
examples/dynamic_threads/Cargo.lock
generated
@@ -1,12 +1,35 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "autotools"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bdwgc-alloc"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dynamic_threads"
|
||||
version = "0.1.0"
|
||||
@@ -20,4 +43,7 @@ version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "774fd1b2d459a939302a0bad631a3de176b8bd5f87cbfc28ceb1f6c18d731094"
|
||||
"checksum cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83"
|
||||
"checksum cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "96210eec534fc3fbfc0452a63769424eaa80205fda6cea98e5b61cb3d97bcec8"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
|
||||
26
examples/gc_free/Cargo.lock
generated
26
examples/gc_free/Cargo.lock
generated
@@ -1,12 +1,35 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "autotools"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bdwgc-alloc"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gc_free"
|
||||
version = "0.1.0"
|
||||
@@ -20,4 +43,7 @@ version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "774fd1b2d459a939302a0bad631a3de176b8bd5f87cbfc28ceb1f6c18d731094"
|
||||
"checksum cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83"
|
||||
"checksum cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "96210eec534fc3fbfc0452a63769424eaa80205fda6cea98e5b61cb3d97bcec8"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
|
||||
26
examples/static_threads/Cargo.lock
generated
26
examples/static_threads/Cargo.lock
generated
@@ -1,12 +1,35 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "autotools"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bdwgc-alloc"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
@@ -20,4 +43,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum autotools 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "774fd1b2d459a939302a0bad631a3de176b8bd5f87cbfc28ceb1f6c18d731094"
|
||||
"checksum cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83"
|
||||
"checksum cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "96210eec534fc3fbfc0452a63769424eaa80205fda6cea98e5b61cb3d97bcec8"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
|
||||
@@ -13,7 +13,7 @@ struct GcStackBase {
|
||||
reg_base: *const c_void,
|
||||
}
|
||||
|
||||
#[link(name = "gc")]
|
||||
#[link(name = "gc", kind = "static")]
|
||||
extern "C" {
|
||||
fn GC_allow_register_threads() -> c_void;
|
||||
fn GC_free(ptr: *mut c_void);
|
||||
|
||||
1
vendor/bdwgc
vendored
Submodule
1
vendor/bdwgc
vendored
Submodule
Submodule vendor/bdwgc added at 51a44b9cdb
1
vendor/libatomic_ops
vendored
Submodule
1
vendor/libatomic_ops
vendored
Submodule
Submodule vendor/libatomic_ops added at 6287479564
Reference in New Issue
Block a user