Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macros std pollution in feature resolution #164

Merged
merged 2 commits into from
Jul 5, 2022
Merged
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
14 changes: 3 additions & 11 deletions Cargo.lock

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

18 changes: 17 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,30 @@ resolver = "2"

members = [
"sdk",
"macros",
"examples/add_i32",
"examples/add_i64",
"examples/udt",
"examples/contract_data",
"examples/create_contract",
]

# Exclude proc-macro crates from the workspace so that when building the
# workspace their dependencies do not pollute the feature selection of other
# crates. Ordinarily when you build a proc-macro crate as a dependency of
# another crate, the proc-macro crate's dependencies are decoupled from the
# dependencies of other crates. This has an important side-effect of not
# unifiying the features selected in shared dependencies. When a proc-macro
# crate is part of a workspace and the workspace as a whole is built the
# proc-macro is seen as a first-class crate and its dependencies, including
# their feature selection, affects the overall dependency graph used to build
# all crates. This has an unfortunate side-effect for proc-macro crates, like
# 'macros', that depend on std features when other crates, like 'sdk',
# explicitly must not depend on std. Hopefully one day this will be fixed in:
# https://github.com/rust-lang/cargo/issues/10827
exclude = [
"macros"
]

[profile.dev]
overflow-checks = true
panic = "abort"
Expand Down
21 changes: 1 addition & 20 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,7 @@ edition = "2021"
proc-macro = true

[dependencies]

# NB: For the time being (until we find a better solution, or abandon `no-std`
# in the guest) we need to specify the stellar-xdr dependency for the the env
# crate (pulled in transitively from the SDK crate) and the macros (this crate)
# with _different versions_ of the stellar-xdr crate.
#
# To repeat (this is weird): ensure the rev="..." specified in this file is a
# _different_ rev than the one specified in
# https://github.com/stellar/rs-stellar-contract-env/blob/main/stellar-contract-env-common/Cargo.toml
#
# This is because the macros activate the `std` feature (as visible here) and
# the guest crate when compiled to wasm requires _not_ activating the `std`
# feature, to include a custom panic handler.
#
# If cargo resolves both dependencies to a single version of stellar-xdr, it
# will enable the `std` feature in that "shared" version. If on the other hand
# (as a total hack) we depend on two _different_ versions of stellar-xdr, we can
# configure them with separate features. Which is what we're doing (for now).

stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "277d41c", features = ["next", "std"] }
stellar-xdr = { git = "https://github.com/stellar/rs-stellar-xdr", rev = "0b8fe26", features = ["next", "std"] }
syn = {version="1.0",features=["full"]}
quote = "1.0"
proc-macro2 = "1.0"
Expand Down