Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ See https://clang.llvm.org/docs/AddressSanitizer.html for more information.

*Note*: ASan will ignore any memory errors in Rust code unless you build with
Rust's ASan support. And building with Rust's ASan support requires configuring
with `--enable-unified-rust-unsafe-for-production`. See below on "unified Rust
with `--enable-fastdev-unsafe-for-production`. See below on "fastdev Rust
builds".

*Note*: Rust's ASan support also requires a nightly compiler and the rust-src
Expand Down Expand Up @@ -156,7 +156,7 @@ See https://clang.llvm.org/docs/ThreadSanitizer.html for more information.
*Note*: Since Rust code is run on multiple threads and those threads are
launched _from C++_ TSan will report races in Rust code unless you build with
Rust's TSan support. And building with Rust's TSan support requires configuring
with `--enable-unified-rust-unsafe-for-production`.
with `--enable-fastdev-unsafe-for-production`.

*Note*: Rust's ASan support also requires a nightly compiler and the rust-src
component. Install these with:
Expand Down Expand Up @@ -294,7 +294,7 @@ files. You should then inspect to see that only the transactions you expected to
see change did so. If so, commit the changes as a new set of baselines for
future tests.

## Unified and non-unified Rust builds
## Fastdev and non-unified Rust builds

As of protocol 20, some components of stellar-core are written in Rust (notably
soroban).
Expand Down Expand Up @@ -331,23 +331,29 @@ and it _usually_ works. But there are two cases you might not want it.
the stdlib and producing some sort of link-time dependency on crates that
are only used as procedural macros).

For both of these cases, we've added the ability to (optionally) switch back to
the normal way Rust expects you to build a crate that links multiple versions of
a dependency: with a single "unified" cargo invocation, at the top level. There
are two different ways to enable this:
For both of these cases, we've added a fastdev mode that switches back to the
normal way Rust expects you to build a crate, with a single cargo invocation at
the top level and only the current and next Soroban hosts compiled in. There are
two different ways to enable this:

- By configuring with `--enable-unified-rust-unsafe-for-production`, if one
wants to _build_ a stellar-core with unified rust.
- By configuring with `--enable-fastdev-unsafe-for-production`, if one wants
to _build_ a stellar-core with fastdev rust.

- By toggling the "unified" feature flag in the IDE (eg. using the "Rust
- By toggling the "fastdev" feature flag in the IDE (eg. using the "Rust
Feature Toggler" editor extension in VS code) if one merely wants to _edit_
a stellar-core with unified rust.
a stellar-core with fastdev rust.

The configure flag has got such a long and unwieldy name because _it will build
soroban with slightly different versions of transitive dependencies_, a
configuration we do _not_ want to ship in production builds.
soroban with fewer host versions and slightly different versions of transitive
dependencies_, a configuration we do _not_ want to ship in production builds.

It is fine for debugging though. In practice those different versions of
transitive dependencies are rarely "all that different". You will _probably_ not
be able to observe any differences. We just don't want to chance it in
production.

To reduce the set of possible configurations and flags, fastdev also acts as
a superset of `--enable-next-protocol-version-unsafe-for-production` (i.e. it
also turns on the `next` feature and links in whatever the next-protocol soroban
host is).

32 changes: 23 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ lto = true
# (or you can build with `make RUST_PROFILE=dev` to get them built with
# debug-and-no-opt).
debug = true

[profile.fastdev]
inherits = "release"
lto = false
debug = "line-tables-only"
codegen-units = 16
split-debuginfo = "unpacked"
36 changes: 28 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,24 @@ AX_APPEND_COMPILE_FLAGS($WFLAGS)
AX_APPEND_COMPILE_FLAGS([-pthread])
AC_LANG_POP(C)

AC_ARG_ENABLE(unified-rust-unsafe-for-production,
AS_HELP_STRING([--enable-unified-rust-unsafe-for-production],
[Build rust crates as a single cargo library, risking version drift]))
AM_CONDITIONAL(UNIFIED_RUST, [test "x$enable_unified_rust_unsafe_for_production" = "xyes"])
AC_ARG_ENABLE(fastdev-unsafe-for-production,
AS_HELP_STRING([--enable-fastdev-unsafe-for-production],
[Build in fast development mode UNSAFE FOR PRODUCTION]))
AS_IF([test "x$enable_fastdev_unsafe_for_production" = "xyes"], [
AC_MSG_NOTICE([enabling fastdev build profile UNSAFE FOR PRODUCTION])
fastdev_cxx_version=`$CXX --version 2>/dev/null`
case "$fastdev_cxx_version" in
*clang*)
CXXFLAGS="$CXXFLAGS -gline-tables-only"
AC_MSG_NOTICE([added -gline-tables-only to CXXFLAGS])
;;
*)
AC_MSG_ERROR([fastdev build requires clang compiler])
;;
esac
])
AM_CONDITIONAL(ENABLE_FASTDEV_UNSAFE_FOR_PRODUCTION,
[test "x$enable_fastdev_unsafe_for_production" = "xyes"])
Comment on lines +100 to +117

unset sanitizeopts

Expand All @@ -110,8 +124,8 @@ AC_ARG_ENABLE([asan],
AS_IF([test "x$enable_asan" = "xyes"], [
AC_MSG_NOTICE([ Enabling asan, see https://clang.llvm.org/docs/AddressSanitizer.html ])

AS_IF([test "xyes" != "x$enable_unified_rust_unsafe_for_production"], [
AC_MSG_WARN(Asan will not instrument rust without --enable-unified-rust-unsafe-for-production)
AS_IF([test "xyes" != "x$enable_fastdev_unsafe_for_production"], [
AC_MSG_WARN(Asan will not instrument rust without --enable-fastdev-unsafe-for-production)
])

sanitizeopts="address"
Expand All @@ -134,8 +148,8 @@ AC_ARG_ENABLE([threadsanitizer],
AS_IF([test "x$enable_threadsanitizer" = "xyes"], [
AC_MSG_NOTICE([ enabling thread-sanitizer, see https://clang.llvm.org/docs/ThreadSanitizer.html ])

AS_IF([test "xyes" != "x$enable_unified_rust_unsafe_for_production"], [
AC_MSG_ERROR(Enabling tsan requires --enable-unified-rust-unsafe-for-production)
AS_IF([test "xyes" != "x$enable_fastdev_unsafe_for_production"], [
AC_MSG_ERROR(Enabling tsan requires --enable-fastdev-unsafe-for-production)
])
AS_IF([test x != "x$sanitizeopts"], [
AC_MSG_ERROR(Cannot enable multiple sanitizers at once)
Expand Down Expand Up @@ -558,6 +572,12 @@ AM_CONDITIONAL(USE_SPDLOG, [test x$enable_spdlog != xno])
AC_ARG_ENABLE(next-protocol-version-unsafe-for-production,
AS_HELP_STRING([--enable-next-protocol-version-unsafe-for-production],
[Enable next protocol version UNSAFE FOR PRODUCTION]))
AS_IF([test "x$enable_fastdev_unsafe_for_production" = "xyes"], [
AS_IF([test "x$enable_next_protocol_version_unsafe_for_production" != "xyes"], [
AC_MSG_NOTICE([enabling next protocol version due to fastdev build profile])
])
enable_next_protocol_version_unsafe_for_production=yes
])
AM_CONDITIONAL(ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION,
[test x$enable_next_protocol_version_unsafe_for_production = xyes])

Expand Down
Loading
Loading