Skip to content

Commit

Permalink
v6.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
p-avital committed Jun 25, 2024
1 parent 090178e commit 228c6a6
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 23 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# 6.1.1
# 6.1.1 (api=1.0.0, abi=1.0.0)
- Add support for multi-fields variants in `repr(C, u*)` enums.
- Deprecate support for `repr(C)` by deprecating any enum that uses it without also specifying a determinant size.
- Remove `CompilerVersion_X_Y_Z` types and their `CurrentCompilerVersion` type alias: the former were hard to keep up to date and the latter could break your code if you upgraded to a version of the compiler that `stabby` didn't know of.
- Add support for `Result<T, core::conver::Infallible>`, which is fully identical to `T` down to its reports.
- Remove `CompilerVersion_X_Y_Z` types: keeping them up to date with new compiler release was too much maintenance.
- Remove `CurrentCompilerVersion` type alias: as it could break your code if you upgraded to a version of the compiler that `stabby` didn't know of.
- Prepare integration of `stabby` and [`safer-ffi`](https://crates.io/crates/safer-ffi) by adding `CType` and `is_invalid` to `IStable`.
- Switch versioning system to [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` as the key.
- [RFC 3633](https://github.com/rust-lang/rfcs/pull/3633) which seeks to address the breaking change in Rust 1.78 is scheduled to be discussed in July 2024.

# 5.1.0
- Introducing `stabby::collections::arc_btree`, a set of copy-on-write btrees:
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ license = " EPL-2.0 OR Apache-2.0"
categories = ["development-tools::ffi", "no-std::no-alloc"]
repository = "https://github.com/ZettaScaleLabs/stabby"
readme = "stabby/README.md"
version = "6.1.1"
version = "6.1.1" # Track

[workspace.dependencies]
stabby-macros = { path = "./stabby-macros/", version = "6.1.1", default-features = false }
stabby-abi = { path = "./stabby-abi/", version = "6.1.1", default-features = false }
stabby = { path = "./stabby/", version = "6.1.1", default-features = false }
stabby-macros = { path = "./stabby-macros/", version = "6.1.1", default-features = false } # Track
stabby-abi = { path = "./stabby-abi/", version = "6.1.1", default-features = false } # Track
stabby = { path = "./stabby/", version = "6.1.1", default-features = false } # Track

abi_stable = "0.11.2"
criterion = "0.5.1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ My hope with `stabby` comes in two flavors:
# `stabby`'s SemVer policy
Stabby includes all of its `stabby_abi::IStable` implementation in its public API: any change to an `IStable` type's memory representation is a breaking change which will lead to a `MAJOR` version change.

From `6.1.1` onwards, Stabby follows [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` key. Here's a few ways you can interpret that:
From `6.1.1` onwards, Stabby follows [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` as the key. Here's a few ways you can interpret that:
- `stabby.version[level] = 2^(api[level]) * 3^(abi[level])` lets you compute the exact versions of stabby's ABI and API.
- When upgrading stabby, you can check what has changed by dividing the new version by the previous one: if the division result is a multiple of 2, the change affected API; and it affected ABI if it's a multiple of 3.
- ABI versioning:
Expand Down
4 changes: 2 additions & 2 deletions examples/dynlinkage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ version = "0.1.0"
edition = "2021"

[dependencies]
stabby = { path = "../../stabby/" }
library = { path = "../library/" } # This ensures proper compilation order
stabby.workspace = true
library = { path = "../library/" } # This ensures proper compilation order
2 changes: 1 addition & 1 deletion examples/libloading/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
stabby = { path = "../../stabby/", features = ["libloading"] }
stabby = { workspace = true, features = ["libloading"] }
libloading = "0.8"
2 changes: 1 addition & 1 deletion examples/library/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ crate-type = ["cdylib", "staticlib"]


[dependencies]
stabby = { path = "../../stabby/" }
stabby.workspace = true
40 changes: 30 additions & 10 deletions release.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import sys, os, re
ws_root = os.path.dirname(__file__)
crates = ["stabby-macros", "stabby-abi", "stabby"]

def factor(x, base):
n = 0
while x > 1 and x % base == 0:
x /= base
n += 1
return n

def factor_version(version, base):
return ".".join([str(factor(int(x), base)) for x in version.split(".")])

if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "publish":
for crate in crates:
Expand All @@ -9,19 +20,28 @@
raise f"Failed to release {crate}, stopping publication"
else:
changelog = f"{ws_root}/CHANGELOG.md"
print("Close the CHANGELOG to continue, the topmost version will be picked")
os.system(f"code --wait {changelog}")
version = None
changelog_text = None
with open(changelog) as clog:
while version is None:
line = clog.readline()
versions = re.findall("^#\s+([^:\n]+)", line)
changelog_text = clog.read()
for line in changelog_text.splitlines():
versions = re.findall(r"^#\s+([\d\.]+)", line)
version = versions[0] if len(versions) else None
if version is not None:
break
header = f"# {version} (api={factor_version(version, 2)}, abi={factor_version(version, 3)})"
print(header)
changelog_text = re.sub(r"^#\s+([\d\.]+)\s*(\(api[^\)]+\))?", header, changelog_text)
with open(changelog, "w") as clog:
clog.write(changelog_text)

print(f"Updating Cargo.tomls with version={version}")
for crate in crates:
vupdate = f"""sed -i -E 's/^version\s*=.*/version = \"{version}\"/g' {ws_root}/{crate}/Cargo.toml"""
os.system(vupdate)
print(vupdate)
dupdate = f"""sed -i -E 's/(stabby-.*version\s*=\s*)\"[^\"]*\"(.*)/\\1\"{version}\"\\2/g' {ws_root}/{crate}/Cargo.toml"""
print(dupdate)
os.system(dupdate)

ws_toml = None
with open(f"{ws_root}/Cargo.toml") as toml:
ws_toml = toml.read()
ws_toml = re.sub(r"version\s*=\s*\"[^\"]+(?P<rest>\".*Track)", f"version = \"{version}\\g<rest>", ws_toml)
with open(f"{ws_root}/Cargo.toml", "w") as toml:
toml.write(ws_toml)
6 changes: 6 additions & 0 deletions stabby-abi/src/stable_impls/abi_stable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ unsafe impl<T: IStable> IStable for abi_stable::std_types::RVec<T> {
type UnusedBits = End;
type HasExactlyOneNiche = B1;
type ContainsIndirections = B1;
type CType = [*const T; 4];
primitive_report!("abi_stable::std_types::RVec", T);
}
check!(abi_stable::std_types::RVec<u8>);
Expand All @@ -41,6 +42,7 @@ unsafe impl<'a, T: IStable> IStable for abi_stable::std_types::RSlice<'a, T> {
type UnusedBits = End;
type HasExactlyOneNiche = B0;
type ContainsIndirections = B1;
type CType = [*const T; 2];
primitive_report!("abi_stable::std_types::RSlice", T);
}
check!(abi_stable::std_types::RSlice<u8>);
Expand All @@ -59,6 +61,7 @@ unsafe impl<'a, T: IStable> IStable for abi_stable::std_types::RSliceMut<'a, T>
type UnusedBits = End;
type HasExactlyOneNiche = B0;
type ContainsIndirections = B1;
type CType = [*const T; 2];
primitive_report!("abi_stable::std_types::RSliceMut", T);
}
check!(abi_stable::std_types::RSliceMut<u8>);
Expand All @@ -73,6 +76,7 @@ where
type UnusedBits = End;
type HasExactlyOneNiche = B1;
type ContainsIndirections = B1;
type CType = [*const (); 3];
primitive_report!("abi_stable::std_types::RHashMap", Tuple<K, V>);
}
check!(abi_stable::std_types::RHashMap<u8, u64>);
Expand All @@ -91,6 +95,7 @@ unsafe impl<T: IStable> IStable for abi_stable::std_types::RBox<T> {
type UnusedBits = End;
type HasExactlyOneNiche = B1;
type ContainsIndirections = B1;
type CType = [*const T; 2];
primitive_report!("abi_stable::std_types::RBox", T);
}
check!(abi_stable::std_types::RBox<u8>);
Expand All @@ -102,6 +107,7 @@ unsafe impl IStable for abi_stable::std_types::RBoxError {
type UnusedBits = End;
type HasExactlyOneNiche = B1;
type ContainsIndirections = B1;
type CType = [*const (); 3];
primitive_report!("abi_stable::std_types::RBoxError");
}
check!(abi_stable::std_types::RBoxError);
Expand Down
8 changes: 8 additions & 0 deletions stabby-abi/src/stable_impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,14 @@ unsafe impl<T: IStable> IStable for HasExactlyOneNiche<core::option::Option<T>,
};
const ID: u64 = crate::report::gen_id(Self::REPORT);
}

unsafe impl<T: IStable> IStable for core::result::Result<T, core::convert::Infallible> {
same_as!(T);
type ContainsIndirections = T::ContainsIndirections;
const REPORT: &'static report::TypeReport = T::REPORT;
const ID: u64 = T::ID;
}

unsafe impl<Ok: IStable, Err: IStable> IStable for core::result::Result<Ok, Err>
where
HasExactlyOneNiche<Self, (Ok::HasExactlyOneNiche, Err::Size)>: IStable,
Expand Down
4 changes: 2 additions & 2 deletions stabby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ My hope with `stabby` comes in two flavors:
# `stabby`'s SemVer policy
Stabby includes all of its `stabby_abi::IStable` implementation in its public API: any change to an `IStable` type's memory representation is a breaking change which will lead to a `MAJOR` version change.

From `6.1.1` onwards, Stabby follows [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` key. Here's a few ways you can interpret that:
- `stabby.version[level] = 2^(api[level]) * 3^(abi[level])` lets you compute the exact versions of stabby's ABI and API, there's a decoder for that [here](https://p-avital.github.io/semver-prime#:~:text=semver%20prime%20translation).
From `6.1.1` onwards, Stabby follows [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` as the key. Here's a few ways you can interpret that:
- `stabby.version[level] = 2^(api[level]) * 3^(abi[level])` lets you compute the exact versions of stabby's ABI and API.
- When upgrading stabby, you can check what has changed by dividing the new version by the previous one: if the division result is a multiple of 2, the change affected API; and it affected ABI if it's a multiple of 3.
- ABI versioning:
- Adding a new type to the set of ABI stable type will bump ABI patch.
Expand Down

0 comments on commit 228c6a6

Please sign in to comment.