Skip to content

Commit

Permalink
Beta 5
Browse files Browse the repository at this point in the history
- Update docs to indicate that Julia 1.9 is now the  stable version.

- Update CI to use Julia 1.9.

- Update bindings.

- Add jlrs_typeof to jlrs_cc to handle recent changes in accessing the
type of a value.

- Bump version number of jl_sys to 0.21.0, and jlrs to 0.18.0-beta.5.
  • Loading branch information
Taaitaaiger committed May 10, 2023
1 parent ac703d6 commit 50c84c6
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 90 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Julia environment
uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand All @@ -36,7 +36,7 @@ jobs:
run: |
export JULIA_DIR="$(dirname $(dirname $(which julia)))"
export LD_LIBRARY_PATH="${JULIA_DIR}/lib:${JULIA_DIR}/lib/julia:${LD_LIBRARY_PATH}"
cargo test --features full,julia-1-8 --verbose
cargo test --features full,julia-1-9 --verbose
test-macos:
runs-on: macos-latest
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Setup Julia environment
uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand All @@ -65,7 +65,7 @@ jobs:
run: |
export JULIA_DIR="$(dirname $(dirname $(which julia)))"
export DYLD_LIBRARY_PATH="${JULIA_DIR}/lib:${JULIA_DIR}/lib/julia:${DYLD_LIBRARY_PATH}"
cargo test --features full,julia-1-8 --verbose
cargo test --features full,julia-1-9 --verbose
test-windows-gnu:
runs-on: windows-latest
Expand All @@ -83,15 +83,15 @@ jobs:
- name: Setup Julia environment
uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- name: Run tests
run: cargo test --features full,julia-1-8 --verbose
run: cargo test --features full,julia-1-9 --verbose

test-windows-msvc:
runs-on: windows-latest
Expand All @@ -110,7 +110,7 @@ jobs:
id: setup-julia
uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'

- uses: ilammy/msvc-dev-cmd@v1

Expand All @@ -120,7 +120,7 @@ jobs:
toolchain: ${{ matrix.rust }}

- name: Run tests
run: cargo test --features full,julia-1-8 --verbose
run: cargo test --features full,julia-1-9 --verbose

test-linux-lts:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -235,7 +235,7 @@ jobs:
- name: Setup Julia environment
uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand All @@ -251,7 +251,7 @@ jobs:
- name: Run module tests
run: |
cd julia_module_test
cargo build --features julia-1-8
cargo build --features julia-1-9
cp ./target/debug/libjulia_module_test.so .
julia JuliaModuleTest.jl
Expand All @@ -265,7 +265,7 @@ jobs:
- name: Setup Julia environment
uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand All @@ -275,7 +275,7 @@ jobs:
- name: Run module tests
run: |
cd julia_module_test
cargo build --features julia-1-8
cargo build --features julia-1-9
cp ./target/debug/julia_module_test.* libjulia_module_test.dll
julia JuliaModuleTest.jl
Expand All @@ -288,7 +288,7 @@ jobs:
- name: Setup Julia environment
uses: julia-actions/setup-julia@v1
with:
version: '1.8'
version: '1.9'

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand All @@ -300,7 +300,7 @@ jobs:
export JULIA_DIR="$(dirname $(dirname $(which julia)))"
export DYLD_LIBRARY_PATH="${JULIA_DIR}/lib:${JULIA_DIR}/lib/julia:${DYLD_LIBRARY_PATH}"
cd julia_module_test
cargo build --features julia-1-8
cargo build --features julia-1-9
cp ./target/debug/libjulia_module_test.* .
julia JuliaModuleTest.jl
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

jlrs is a crate that provides access to most of the Julia C API, it can be used to embed Julia
in Rust applications and to use functionality it provides when writing `ccall`able
functions in Rust. Currently this crate is only tested in combination with Julia 1.6 and 1.8,
but also supports Julia 1.7 and 1.9. Using the current stable version is highly recommended.
functions in Rust. Currently this crate is only tested in combination with Julia 1.6 and 1.9,
but also supports Julia 1.7 and 1.8. Using the current stable version is highly recommended.
The minimum supported Rust version is currently 1.65.

The documentation assumes you're already familiar with the Julia and Rust programming
Expand Down Expand Up @@ -227,11 +227,11 @@ enabling the `full` feature.
If you want to embed Julia in a Rust application, you must enable a runtime and a version
feature:

`jlrs = {version = "0.18.0-beta.4", features = ["sync-rt", "julia-1-8"]}`
`jlrs = {version = "0.18.0-beta.5", features = ["sync-rt", "julia-1-8"]}`

`jlrs = {version = "0.18.0-beta.4", features = ["tokio-rt", "julia-1-8"]}`
`jlrs = {version = "0.18.0-beta.5", features = ["tokio-rt", "julia-1-8"]}`

`jlrs = {version = "0.18.0-beta.4", features = ["async-std-rt", "julia-1-8"]}`
`jlrs = {version = "0.18.0-beta.5", features = ["async-std-rt", "julia-1-8"]}`

When Julia is embedded in an application, it must be initialized before it can be used. The
following snippet initializes the sync runtime:
Expand Down
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publish = false
edition = "2018"

[dev-dependencies]
jlrs = { version = "0.18.0-beta.4", path = "../jlrs", features = ["full"] }
jlrs = { version = "0.18.0-beta.5", path = "../jlrs", features = ["full"] }
crossbeam-channel = "0.5"
async-std = { version = "1", features = ["unstable", "attributes"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"]}
Expand Down
2 changes: 1 addition & 1 deletion jl_sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jl-sys"
version = "0.20.2"
version = "0.21.0"
authors = ["Thomas van Doornmalen <[email protected]>"]
description = """
jl-sys contains the generated bindings for the Julia C API used by jlrs.
Expand Down
1 change: 1 addition & 0 deletions jl_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ fn generate_bindings(julia_dir: &str) {
.allowlist_function("jl_yield")
.allowlist_function("jlrs_catch_wrapper")
.allowlist_function("jlrs_lock")
.allowlist_function("jlrs_typeof")
.allowlist_function("jlrs_unlock")
.allowlist_function("jlrs_array_data_owner_offset")
.allowlist_function("jlrs_gc_queue_multiroot")
Expand Down
63 changes: 42 additions & 21 deletions jl_sys/generate_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function print_help() {
echo "default paths can be overridden with environment variables:"
echo ""
echo -e "\033[1m Version Default path${spacing}Override\033[0m"
echo " Linux 64-bit 1.9 $HOME/julia-1.9.0 JULIA_1_9_DIR"
echo " Linux 64-bit 1.8 $HOME/julia-1.8.5 JULIA_1_8_DIR"
echo " Linux 64-bit 1.7 $HOME/julia-1.7.3 JULIA_1_7_DIR"
echo " Linux 64-bit 1.6 $HOME/julia-1.6.7 JULIA_1_6_DIR"
Expand All @@ -79,7 +80,7 @@ function print_help() {
echo "When the beta flag is set, the following is expected:"
echo ""
echo -e "\033[1m Version Default path${spacing}Override\033[0m"
echo " Linux 64-bit 1.9 $HOME/julia-1.9.0-rc3 JULIA_1_9_DIR"
echo " - - -"
echo ""
echo ""
echo "All dependencies must have been installed before running this script. The"
Expand Down Expand Up @@ -123,31 +124,40 @@ if [ "${NIGHTLY}" = "y" -o "${ALL}" = "y" ]; then
fi

if [ "${BETA}" = "y" -o "${ALL}" = "y" ]; then
if [ -z "$JULIA_1_9_DIR" ]; then
JULIA_1_9_DIR=${HOME}/julia-1.9.0-rc3
fi
if [ ! -d "$JULIA_1_9_DIR" ]; then
echo "Error: $JULIA_1_9_DIR does not exist" >&2
exit 1
fi

cargo clean
JULIA_VERSION=$($JULIA_1_9_DIR/bin/julia --version)
JULIA_DIR=$JULIA_1_9_DIR cargo build --features use-bindgen,julia-1-9
echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_9_64.rs
cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_9_64.rs

cargo clean
JULIA_DIR=$JULIA_1_9_DIR cargo build --features use-bindgen,i686,julia-1-9 --target i686-unknown-linux-gnu
echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_9_32.rs
cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_9_32.rs

# if [ -z "$JULIA_BETA_DIR" ]; then
# JULIA_BETA_DIR=${HOME}/julia-1.9.0-rc3
# fi
# if [ ! -d "$JULIA_BETA_DIR" ]; then
# echo "Error: $JULIA_BETA_DIR does not exist" >&2
# exit 1
# fi

# cargo clean
# JULIA_VERSION=$($JULIA_BETA_DIR/bin/julia --version)
# JULIA_DIR=$JULIA_BETA_DIR cargo build --features use-bindgen,julia-1-9
# echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_9_64.rs
# cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_9_64.rs

# cargo clean
# JULIA_DIR=$JULIA_BETA_DIR cargo build --features use-bindgen,i686,julia-1-9 --target i686-unknown-linux-gnu
# echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_9_32.rs
# cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_9_32.rs

echo "Warning: there is no known beta version. Skipping beta bindings" >&2
if [ "${ALL}" != "y" ]; then
cargo +nightly fmt -- ./src/bindings/bindings_*
# cargo +nightly fmt -- ./src/bindings/bindings_*
exit
fi
fi

if [ -z "$JULIA_1_9_DIR" ]; then
JULIA_1_9_DIR=${HOME}/julia-1.9.0
fi
if [ ! -d "$JULIA_1_9_DIR" ]; then
echo "Error: $JULIA_1_9_DIR does not exist" >&2
exit 1
fi

if [ -z "$JULIA_1_8_DIR" ]; then
JULIA_1_8_DIR=${HOME}/julia-1.8.5
fi
Expand Down Expand Up @@ -205,4 +215,15 @@ JULIA_DIR=$JULIA_1_8_DIR cargo build --features use-bindgen,i686,julia-1-8 --tar
echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_8_32.rs
cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_8_32.rs

cargo clean
JULIA_VERSION=$($JULIA_1_9_DIR/bin/julia --version)
JULIA_DIR=$JULIA_1_9_DIR cargo build --features use-bindgen,julia-1-9
echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_9_64.rs
cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_9_64.rs

cargo clean
JULIA_DIR=$JULIA_1_9_DIR cargo build --features use-bindgen,i686,julia-1-9 --target i686-unknown-linux-gnu
echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_9_32.rs
cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_9_32.rs

cargo +nightly fmt -- ./src/bindings/bindings_*
47 changes: 33 additions & 14 deletions jl_sys/src/bindings/bindings_1_10_32.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* generated from julia version 1.10.0-DEV (Commit: 7cf01e57a1 2023-05-06 04:37 UTC) */
/* generated from julia version 1.10.0-DEV (Commit: 056112e5c2 2023-05-10 16:54 UTC) */
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage> {
Expand Down Expand Up @@ -126,21 +126,33 @@ impl _jl_taggedvalue_bits {
}
}
#[inline]
pub fn padding(&self) -> usize {
unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 29u8) as u32) }
pub fn unused(&self) -> usize {
unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) }
}
#[inline]
pub fn set_padding(&mut self, val: usize) {
pub fn set_unused(&mut self, val: usize) {
unsafe {
let val: u32 = ::std::mem::transmute(val);
self._bitfield_1.set(3usize, 29u8, val as u64)
self._bitfield_1.set(3usize, 1u8, val as u64)
}
}
#[inline]
pub fn tag(&self) -> usize {
unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 28u8) as u32) }
}
#[inline]
pub fn set_tag(&mut self, val: usize) {
unsafe {
let val: u32 = ::std::mem::transmute(val);
self._bitfield_1.set(4usize, 28u8, val as u64)
}
}
#[inline]
pub fn new_bitfield_1(
gc: usize,
in_image: usize,
padding: usize,
unused: usize,
tag: usize,
) -> __BindgenBitfieldUnit<[u8; 4usize]> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default();
__bindgen_bitfield_unit.set(0usize, 2u8, {
Expand All @@ -151,9 +163,13 @@ impl _jl_taggedvalue_bits {
let in_image: u32 = unsafe { ::std::mem::transmute(in_image) };
in_image as u64
});
__bindgen_bitfield_unit.set(3usize, 29u8, {
let padding: u32 = unsafe { ::std::mem::transmute(padding) };
padding as u64
__bindgen_bitfield_unit.set(3usize, 1u8, {
let unused: u32 = unsafe { ::std::mem::transmute(unused) };
unused as u64
});
__bindgen_bitfield_unit.set(4usize, 28u8, {
let tag: u32 = unsafe { ::std::mem::transmute(tag) };
tag as u64
});
__bindgen_bitfield_unit
}
Expand Down Expand Up @@ -1018,11 +1034,11 @@ impl _jl_datatype_t {
}
}
#[inline]
pub fn padding(&self) -> u16 {
pub fn smalltag(&self) -> u16 {
unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 6u8) as u16) }
}
#[inline]
pub fn set_padding(&mut self, val: u16) {
pub fn set_smalltag(&mut self, val: u16) {
unsafe {
let val: u16 = ::std::mem::transmute(val);
self._bitfield_1.set(10usize, 6u8, val as u64)
Expand All @@ -1040,7 +1056,7 @@ impl _jl_datatype_t {
isprimitivetype: u16,
ismutationfree: u16,
isidentityfree: u16,
padding: u16,
smalltag: u16,
) -> __BindgenBitfieldUnit<[u8; 2usize]> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default();
__bindgen_bitfield_unit.set(0usize, 1u8, {
Expand Down Expand Up @@ -1085,8 +1101,8 @@ impl _jl_datatype_t {
isidentityfree as u64
});
__bindgen_bitfield_unit.set(10usize, 6u8, {
let padding: u16 = unsafe { ::std::mem::transmute(padding) };
padding as u64
let smalltag: u16 = unsafe { ::std::mem::transmute(smalltag) };
smalltag as u64
});
__bindgen_bitfield_unit
}
Expand Down Expand Up @@ -2375,6 +2391,9 @@ extern "C" {
extern "C" {
pub fn jl_exit_threaded_region();
}
extern "C" {
pub fn jlrs_typeof(v: *mut jl_value_t) -> *mut jl_datatype_t;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _jl_value_t {
Expand Down
Loading

0 comments on commit 50c84c6

Please sign in to comment.