Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refs #2. Prepares for #3.
The root crate exported the C symbols of libmpdec unconditionally (480
#[no_mangle]items, including internal functions) and was always built as astaticlib. With this PR, the crate exports no C symbols by default. The upstream C testsenable the new feature
capi.This also makes the differential fuzz tests of #3 simpler: the crate can be linked into the same binary as C libmpdec without renaming either side's symbols.
Commits
mpdecimalis left for a Rust-friendly API crate on top of it, as suggested in On splitting into core and sys crates by purpose #2.crate-type = ["staticlib", "rlib"].c2rust/test-short.shandc2rust/test-long.shbuild the root crate withcargo rustc --lib --crate-type staticlib.crate-typecannot depend on a feature, and this way no separate crate is needed for the staticlib.
#[no_mangle]insrc/becomes#[cfg_attr(feature = "capi", no_mangle)].test-hooksimpliescapi.extern "C"and#[repr(C)]are kept, since the crate is a 1:1 port of the C code and the C tests rely on its layouts. Only the C names exposed to the linker are behindcapi.src/is now edited by hand, soc2rust/install.pyrefuses to overwrite it (its existing check againstc2rust/out/installed.sha256). The per-target translations inc2rust/outare unchanged.Verification (macOS aarch64, uint128)
mpd_*symbols in the staticlib: 0 withoutcapi, 360 withcapi.runshort.sh,runshort_alloc.sh) pass withCRATE=root, with and withoutFEATURES=test-hooks.test_transpose,ppro_mulmod) pass.