Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Synchronized with `polkadot-sdk/c40b36c3a7c208f9a6837b80812473af3d9ba7f7` ‒ [2102](https://github.com/use-ink/cargo-contract/pull/2102)
- Re-enable `rustc` overflow checks - [#2116](https://github.com/use-ink/cargo-contract/pull/2116)

### Removed
- Removed chain extension functionality ‒ [2120](https://github.com/use-ink/cargo-contract/pull/2120)
Expand Down
5 changes: 4 additions & 1 deletion crates/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,10 @@ fn exec_cargo_for_onchain_target(
if build_mode == &BuildMode::Debug {
features.push("ink/ink-debug".to_string());
} else {
args.push("-Zbuild-std-features=panic_immediate_abort".to_owned());
args.push(
"-Zbuild-std-features=panic_immediate_abort,compiler-builtins-mem"
.to_owned(),
);
}
features.append_to_args(&mut args);
let mut env = Vec::new();
Expand Down
10 changes: 1 addition & 9 deletions crates/build/src/workspace/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,11 @@ impl Manifest {
pub fn new(manifest_path: ManifestPath) -> Result<Manifest> {
let toml = fs::read_to_string(&manifest_path).context("Loading Cargo.toml")?;
let toml: value::Table = toml::from_str(&toml)?;
let mut manifest = Manifest {
let manifest = Manifest {
path: manifest_path,
toml,
metadata_package: false,
};
let profile = manifest.profile_release_table_mut()?;
if profile
.get("overflow-checks")
.and_then(|val| val.as_bool())
.unwrap_or(false)
{
anyhow::bail!("Overflow checks must be disabled. Cargo contract makes sure that no unchecked arithmetic is used.")
}
Ok(manifest)
}

Expand Down
6 changes: 6 additions & 0 deletions crates/build/src/workspace/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct Profile {
// `None` means use rustc default.
pub codegen_units: Option<u32>,
pub panic: Option<PanicStrategy>,
pub overflow_checks: Option<bool>,
}

impl Profile {
Expand All @@ -37,6 +38,7 @@ impl Profile {
lto: Some(Lto::Fat),
codegen_units: Some(1),
panic: Some(PanicStrategy::Abort),
overflow_checks: Some(true),
}
}

Expand Down Expand Up @@ -73,6 +75,7 @@ impl Profile {
self.panic.map(PanicStrategy::to_toml_value),
profile,
);
set_value_if_vacant("overflow-checks", self.overflow_checks, profile);
}
}

Expand Down Expand Up @@ -159,6 +162,7 @@ mod tests {
expected.insert("lto".into(), value::Value::String("fat".into()));
expected.insert("codegen-units".into(), value::Value::Integer(1));
expected.insert("panic".into(), value::Value::String("abort".into()));
expected.insert("overflow-checks".into(), value::Value::Boolean(true));

let mut manifest_profile = toml::from_str(manifest_toml).unwrap();

Expand All @@ -176,12 +180,14 @@ mod tests {
lto = false
opt-level = 3
codegen-units = 256
overflow-checks = false
"#;
let mut expected = value::Table::new();
expected.insert("opt-level".into(), value::Value::Integer(3));
expected.insert("lto".into(), value::Value::Boolean(false));
expected.insert("codegen-units".into(), value::Value::Integer(256));
expected.insert("panic".into(), value::Value::String("unwind".into()));
expected.insert("overflow-checks".into(), value::Value::Boolean(false));

let mut manifest_profile = toml::from_str(manifest_toml).unwrap();

Expand Down
Loading