Skip to content

build: customize opt-level to avoid building some crates twice#2788

Merged
bors[bot] merged 1 commit intonervosnetwork:developfrom
chaoticlonghair:pr/smaller-target
Jun 28, 2021
Merged

build: customize opt-level to avoid building some crates twice#2788
bors[bot] merged 1 commit intonervosnetwork:developfrom
chaoticlonghair:pr/smaller-target

Conversation

@chaoticlonghair
Copy link
Contributor

@chaoticlonghair chaoticlonghair commented Jun 25, 2021

Purpose

Since "Cargo PR-8500" merged, as "Cargo Issue-8502" said: "if a crate will also be built as a runtime dependency, that would result in Cargo building it twice, once with opt-level 0 and once with opt-level 3."

So, in this PR I customize the opt-level to the default values, to make sure each crates only be compiled once.

Results

When make prod for v0.42.0:

  • This PR can reduce the number of compiled dependencies 9.56% (596 -> 544).
  • This PR can reduce the size of target directory 14.2% (1_813_100 bytes -> 1_587_780 bytes).
  • Save total compile time.

Notice: the size of final binary won't be chaneged.

References

@quake
Copy link
Member

quake commented Jun 27, 2021

bors r=quake,driftluo

@bors
Copy link
Contributor

bors bot commented Jun 28, 2021

Build succeeded:

@bors bors bot merged commit 6844fa4 into nervosnetwork:develop Jun 28, 2021
@chaoticlonghair chaoticlonghair deleted the pr/smaller-target branch June 28, 2021 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants