cxx: implement slice support for nostd #1123
Open
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.
OVERVIEW:
This patch adds experimental support for us to use
slicesin a nostd/freestanding environment, aim is to run c++ <=> cxx-rs <=> rust on a baremental target environment and use slices, with the intention of supporting more features later.CFG
In the application
Cargo.tomlfile, the following feature cfgs are required:Then build with:
Build Notes
and in the particular
.cppfile you may need to declare the followingFUNCTIONALITY:
Currently, this only supports slices (outside of trivial features).
TESTING:
Tested by compiling:
cargo test (run existing tests)
cxx/demo/ running it.
compiling with a arm toolchain setup with cmake/corrosion and running the binary on QEMU arm with basic logic assertions [1].
Current testing has been done in the direction of C++ -> Rust with a simple callback test to C++. A
simple test setup can be seen here [2].
TODO:
Get features such as
Results<Ok, Err>working.When we build for the none
stdcase (nodefault-features), instead of creating a symlink to the originalcxx.hfile, we copy it over and define the macro to disable stdlib dependencies. Perhaps there's a better way to do this?NOTES:
By default, all the standard features are enabled gaurded by the
#ifndef CXXBRIDGE1_RUST_STD, so this shoudn't break anything.[1] https://github.com/twilfredo/qemu_misc/tree/master/bm_arm
[2] https://github.com/twilfredo/qemu_misc/blob/master/bm_arm/main.cpp
Signed-off-by: Wilfred Mallawa wilfred.mallawa@wdc.com