Skip to content

Commit 727b70d

Browse files
committed
auto merge of #10526 : itdaniher/rust/master, r=pcwalton
This commit fixes issue #10468. It propagate optimization level from PkgSrc to compile_crate as a rustc::driver::session::OptLevel enum. The 'opt' argument to compile_crate was previously hardcoded as boolean false, such that calls to session::options would always result in the session::No flag being used.
2 parents 15a8e62 + b60b411 commit 727b70d

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/librustpkg/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Context data structure used by rustpkg
1212

1313
use extra::workcache;
14-
use rustc::driver::session::{OptLevel, No};
14+
use rustc::driver::session;
1515

1616
use std::hashmap::HashSet;
1717

@@ -88,7 +88,7 @@ pub struct RustcFlags {
8888
// Extra arguments to pass to rustc with the --link-args flag
8989
link_args: Option<~str>,
9090
// Optimization level. 0 = default. -O = 2.
91-
optimization_level: OptLevel,
91+
optimization_level: session::OptLevel,
9292
// True if the user passed in --save-temps
9393
save_temps: bool,
9494
// Target (defaults to rustc's default target)
@@ -224,7 +224,7 @@ impl RustcFlags {
224224
linker: None,
225225
link_args: None,
226226
compile_upto: Nothing,
227-
optimization_level: No,
227+
optimization_level: session::Default,
228228
save_temps: false,
229229
target: None,
230230
target_cpu: None,

src/librustpkg/package_source.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ use workcache_support::{digest_only_date, digest_file_with_date, crate_tag};
2828
use extra::workcache;
2929
use extra::treemap::TreeMap;
3030

31+
use rustc::driver::session;
32+
3133
// An enumeration of the unpacked source of a package workspace.
3234
// This contains a list of files found in the source workspace.
3335
#[deriving(Clone)]
@@ -425,6 +427,7 @@ impl PkgSrc {
425427
}
426428
debug!("Compiling crate {}; its output will be in {}",
427429
subpath.display(), sub_dir.display());
430+
let opt: session::OptLevel = subcx.context.rustc_flags.optimization_level;
428431
let result = compile_crate(&subcx,
429432
exec,
430433
&id,
@@ -433,7 +436,7 @@ impl PkgSrc {
433436
&mut (sub_deps.clone()),
434437
sub_flags,
435438
subcfgs,
436-
false,
439+
opt,
437440
what);
438441
// XXX: result is an Option<Path>. The following code did not take that
439442
// into account. I'm not sure if the workcache really likes seeing the

src/librustpkg/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub fn compile_input(context: &BuildContext,
175175
deps: &mut DepMap,
176176
flags: &[~str],
177177
cfgs: &[~str],
178-
opt: bool,
178+
opt: session::OptLevel,
179179
what: OutputType) -> Option<Path> {
180180
assert!(in_file.component_iter().nth(1).is_some());
181181
let input = driver::file_input(in_file.clone());
@@ -241,7 +241,7 @@ pub fn compile_input(context: &BuildContext,
241241

242242
let options = @session::options {
243243
crate_type: crate_type,
244-
optimize: if opt { session::Aggressive } else { session::No },
244+
optimize: opt,
245245
test: what == Test || what == Bench,
246246
maybe_sysroot: Some(sysroot_to_use),
247247
addl_lib_search_paths: @mut context.additional_library_paths(),
@@ -408,7 +408,7 @@ pub fn compile_crate(ctxt: &BuildContext,
408408
deps: &mut DepMap,
409409
flags: &[~str],
410410
cfgs: &[~str],
411-
opt: bool,
411+
opt: session::OptLevel,
412412
what: OutputType) -> Option<Path> {
413413
debug!("compile_crate: crate={}, workspace={}", crate.display(), workspace.display());
414414
debug!("compile_crate: short_name = {}, flags =...", pkg_id.to_str());

0 commit comments

Comments
 (0)