refactor: Introduce a virtual manifest

Move the workspace configuration to a virtual manifest. This
reorganization makes a more clear separation between package contents
and support files that don't get distributed. It will also make it
easier to merge this repository with `compiler-builtins` which is
planned (builtins had a similar update done in [1]).

LICENSE.txt and README.md are symlinkedinto the new directory to ensure
they get included in the package.

[1]: https://github.com/rust-lang/compiler-builtins/pull/702
This commit is contained in:
Trevor Gross 2025-04-09 01:21:44 +00:00 committed by Trevor Gross
parent 7077daa6ad
commit 3a0b9c9f51
7 changed files with 305 additions and 302 deletions

View file

@ -0,0 +1,37 @@
[workspace]
resolver = "2"
members = [
"libm",
"crates/libm-macros",
"crates/libm-test",
"crates/musl-math-sys",
"crates/util",
]
default-members = [
"libm",
"crates/libm-macros",
"crates/libm-test"
]
exclude = [
# Requires `panic = abort` so can't be a member of the workspace
"crates/compiler-builtins-smoke-test",
]
# The default release profile is unchanged.
# Release mode with debug assertions
[profile.release-checked]
inherits = "release"
debug-assertions = true
overflow-checks = true
# Release with maximum optimizations, which is very slow to build. This is also
# what is needed to check `no-panic`.
[profile.release-opt]
inherits = "release"
codegen-units = 1
lto = "fat"
[profile.bench]
# Required for iai-callgrind
debug = true

View file

@ -25,7 +25,7 @@ USAGE = cleandoc(
COMMAND:
generate-matrix
Calculate a matrix of which functions had source change, print that as
a JSON object.
a JSON object.
locate-baseline [--download] [--extract]
Locate the most recent benchmark baseline available in CI and, if flags

File diff suppressed because it is too large Load diff

View file

@ -18,10 +18,10 @@ from typing import Any, Callable, TypeAlias
SELF_PATH = Path(__file__)
ETC_DIR = SELF_PATH.parent
LIBM_DIR = ETC_DIR.parent.joinpath("libm")
ROOT_DIR = ETC_DIR.parent
# These files do not trigger a retest.
IGNORED_SOURCES = ["src/libm_helper.rs", "src/math/support/float_traits.rs"]
IGNORED_SOURCES = ["libm/src/libm_helper.rs", "libm/src/math/support/float_traits.rs"]
IndexTy: TypeAlias = dict[str, dict[str, Any]]
"""Type of the `index` item in rustdoc's JSON output"""
@ -66,7 +66,7 @@ class Crate:
j = sp.check_output(
[
"rustdoc",
"src/lib.rs",
"libm/src/lib.rs",
"--edition=2021",
"--document-private-items",
"--output-format=json",
@ -75,7 +75,7 @@ class Crate:
"-Zunstable-options",
"-o-",
],
cwd=LIBM_DIR,
cwd=ROOT_DIR,
text=True,
)
j = json.loads(j)
@ -94,7 +94,9 @@ class Crate:
# Collect a list of source IDs for reexported items in `lib.rs` or `mod math`.
use = (i for i in public if "use" in i["inner"])
use = (
i for i in use if i["span"]["filename"] in ["src/math/mod.rs", "src/lib.rs"]
i
for i in use
if i["span"]["filename"] in ["libm/src/math/mod.rs", "libm/src/lib.rs"]
)
reexported_ids = [item["inner"]["use"]["id"] for item in use]
@ -121,8 +123,8 @@ class Crate:
# A lot of the `arch` module is often configured out so doesn't show up in docs. Use
# string matching as a fallback.
for fname in glob("src/math/arch/**.rs", root_dir=LIBM_DIR):
contents = (LIBM_DIR.joinpath(fname)).read_text()
for fname in glob("libm/src/math/arch/**.rs", root_dir=ROOT_DIR):
contents = (ROOT_DIR.joinpath(fname)).read_text()
for name in self.public_functions:
if f"fn {name}" in contents:
@ -188,10 +190,10 @@ class Crate:
include all public API.
"""
flist = sp.check_output(["git", "ls-files"], cwd=LIBM_DIR, text=True)
flist = sp.check_output(["git", "ls-files"], cwd=ROOT_DIR, text=True)
for path in flist.splitlines():
fpath = LIBM_DIR.joinpath(path)
fpath = ROOT_DIR.joinpath(path)
if fpath.is_dir() or fpath == SELF_PATH:
continue
@ -229,7 +231,7 @@ class Crate:
if len(not_found) == 0:
return
relpath = fpath.relative_to(LIBM_DIR)
relpath = fpath.relative_to(ROOT_DIR)
eprint(f"functions not found at {relpath}:{line_num}: {not_found}")
exit(1)
@ -244,7 +246,7 @@ def validate_delimited_block(
"""Identify blocks of code wrapped within `start` and `end`, collect their contents
to a list of strings, and call `validate` for each of those lists.
"""
relpath = fpath.relative_to(LIBM_DIR)
relpath = fpath.relative_to(ROOT_DIR)
block_lines = []
block_start_line: None | int = None
for line_num, line in enumerate(lines):
@ -274,7 +276,7 @@ def validate_delimited_block(
def ensure_sorted(fpath: Path, block_start_line: int, lines: list[str]) -> None:
"""Ensure that a list of lines is sorted, otherwise print a diff and exit."""
relpath = fpath.relative_to(LIBM_DIR)
relpath = fpath.relative_to(ROOT_DIR)
diff_and_exit(
"\n".join(lines),
"\n".join(sorted(lines)),

View file

@ -10,7 +10,6 @@ readme = "README.md"
repository = "https://github.com/rust-lang/libm"
version = "0.2.11"
edition = "2021"
exclude = ["/ci/", "/.github/workflows/"]
rust-version = "1.63"
[features]
@ -40,24 +39,6 @@ unstable-float = []
# hard float operations.
force-soft-floats = []
[workspace]
resolver = "2"
members = [
"crates/libm-macros",
"crates/libm-test",
"crates/musl-math-sys",
"crates/util",
]
default-members = [
".",
"crates/libm-macros",
"crates/libm-test",
]
exclude = [
# Requires `panic = abort` so can't be a member of the workspace
"crates/compiler-builtins-smoke-test",
]
[dev-dependencies]
no-panic = "0.1.35"
@ -66,22 +47,3 @@ unexpected_cfgs = { level = "warn", check-cfg = [
# compiler-builtins sets this feature, but we use it in `libm`
'cfg(feature, values("compiler-builtins"))',
] }
# The default release profile is unchanged.
# Release mode with debug assertions
[profile.release-checked]
inherits = "release"
debug-assertions = true
overflow-checks = true
# Release with maximum optimizations, which is very slow to build. This is also
# what is needed to check `no-panic`.
[profile.release-opt]
inherits = "release"
codegen-units = 1
lto = "fat"
[profile.bench]
# Required for iai-callgrind
debug = true

View file

@ -0,0 +1 @@
../LICENSE.txt

View file

@ -0,0 +1 @@
../README.md