Skip to content

enable parallel codegen by default #18213

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

Merged
merged 1 commit into from
Oct 22, 2014
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
7 changes: 7 additions & 0 deletions mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ RUSTFLAGS_STAGE1 += -C prefer-dynamic
# by not emitting them.
RUSTFLAGS_STAGE0 += -Z no-landing-pads

# Go fast for stage0, and also for stage1/stage2 if optimization is off.
RUSTFLAGS_STAGE0 += -C codegen-units=4
ifdef CFG_DISABLE_OPTIMIZE
RUSTFLAGS_STAGE1 += -C codegen-units=4
RUSTFLAGS_STAGE2 += -C codegen-units=4
endif

# platform-specific auto-configuration
include $(CFG_SRC_DIR)mk/platform.mk

Expand Down
4 changes: 4 additions & 0 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,10 @@ CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS))
ifndef CFG_DISABLE_OPTIMIZE_TESTS
CTEST_RUSTC_FLAGS += -O
endif
# Force codegen-units=1 for compiletest tests. compiletest does its own
# parallelization internally, so rustc's default codegen-units=2 will actually
# slow things down.
CTEST_RUSTC_FLAGS += -C codegen-units=1

CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
--compile-lib-path $$(HLIB$(1)_H_$(3)) \
Expand Down
15 changes: 14 additions & 1 deletion src/librustc/driver/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,20 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
early_warn("the --crate-file-name argument has been renamed to \
--print-file-name");
}
let cg = build_codegen_options(matches);

let mut cg = build_codegen_options(matches);

if cg.codegen_units == 0 {
match opt_level {
// `-C lto` doesn't work with multiple codegen units.
_ if cg.lto => cg.codegen_units = 1,

No | Less => cg.codegen_units = 2,
Default | Aggressive => cg.codegen_units = 1,
}
}
let cg = cg;


if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
early_warn("-C remark will not show source locations without --debuginfo");
Expand Down