mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 20:20:00 +00:00
Fix rust crate for big-endian targets (#5229)
Thanks for tackling this, @tymcauley ! * big endian docker test -- wip * tweaks * tweaks * tweaks * docker tweaks * fix conditional compilation issues * reactivate other docker tests * try some more cross-platform config (from tymcauley) * Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1 Co-Authored-By: rw <rw@users.noreply.github.com> * Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1 Co-Authored-By: rw <rw@users.noreply.github.com> * Update tests/docker/languages/Dockerfile.testing.rust.big_endian.1_30_1 Co-Authored-By: rw <rw@users.noreply.github.com> * Resolved Rust warnings during big-endian builds. * Unify Rust test suites for x86 and MIPS builds. Note that I had to add four extra packages to the MIPS `Dockerfile`: `libexpat1`, `libmagic1`, `libmpdec2`, and `libreadline7`. For a reason I couldn't identify, even the simplest Rust MIPS binaries run with `qemu-mips` would fail with a segfault when run through this `Dockerfile`. After installing the `gdb-multiarch` package to attempt to debug the issue, the binaries ran successfully. I pared down the packages installed by `gdb-multiarch`, and these four packages are the minimum subset necessary to get Rust MIPS binaries running under `qemu-mips`. * Changed Rust tests to use `Vector`s instead of direct-slice-access. The direct-slice-access method is not available on big-endian targets, but `flatbuffers::Vector`s provide an array interface that is available on all platforms. * Resolved FooStruct endianness issues using explicit struct constructor. This more closely resembles how FlatBuffers structs are constructed in generated Rust code. * Added explanation of how `FooStruct` parallels generated struct code. Also collected duplicate implementations of `FooStruct` into a common location.
This commit is contained in:
@@ -15,8 +15,14 @@ set -e
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if [[ "$1" == "mips-unknown-linux-gnu" ]]; then
|
||||
TARGET_FLAG="--target mips-unknown-linux-gnu"
|
||||
export CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc
|
||||
export CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu"
|
||||
fi
|
||||
|
||||
cd ./rust_usage_test
|
||||
cargo test -- --quiet
|
||||
cargo test $TARGET_FLAG -- --quiet
|
||||
TEST_RESULT=$?
|
||||
if [[ $TEST_RESULT == 0 ]]; then
|
||||
echo "OK: Rust tests passed."
|
||||
@@ -25,7 +31,7 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo run --bin=alloc_check
|
||||
cargo run $TARGET_FLAG --bin=alloc_check
|
||||
TEST_RESULT=$?
|
||||
if [[ $TEST_RESULT == 0 ]]; then
|
||||
echo "OK: Rust heap alloc test passed."
|
||||
@@ -34,4 +40,4 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo bench
|
||||
cargo bench $TARGET_FLAG
|
||||
|
||||
Reference in New Issue
Block a user