Skip to content

Commit 28b1dc0

Browse files
committed
Added disambiguation metadata to compilations.
This avoids errors from cargo regarding symbol resolution problems which were discussed in rust-lang#32. This commit should fix the issue.
1 parent e365ae2 commit 28b1dc0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/bin/cargo_semver.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use cargo::util::important_paths::find_root_manifest_for_wd;
1919

2020
use getopts::{Matches, Options};
2121

22+
use std::env;
2223
use std::io::Write;
2324
use std::path::PathBuf;
2425
use std::process::{Stdio, Command};
@@ -114,11 +115,21 @@ impl<'a> WorkInfo<'a> {
114115
}
115116

116117
/// Obtain the paths to the produced rlib and the dependency output directory.
117-
fn rlib_and_dep_output(&self, config: &'a Config, name: &str)
118+
fn rlib_and_dep_output(&self, config: &'a Config, name: &str, current: bool)
118119
-> CargoResult<(PathBuf, PathBuf)>
119120
{
120121
let opts = CompileOptions::default(config, CompileMode::Build);
122+
123+
if current {
124+
env::set_var("RUSTFLAGS", "-C metadata=new");
125+
} else {
126+
env::set_var("RUSTFLAGS", "-C metadata=old");
127+
}
128+
121129
let compilation = compile(&self.workspace, &opts)?;
130+
131+
env::remove_var("RUSTFLAGS");
132+
122133
let rlib = compilation.libraries[self.package.package_id()]
123134
.iter()
124135
.find(|t| t.0.name() == name)
@@ -185,8 +196,8 @@ fn do_main(config: &Config, matches: &Matches) -> CargoResult<()> {
185196
(work_info, stable_crate.max_version.clone())
186197
};
187198

188-
let (current_rlib, current_deps_output) = current.rlib_and_dep_output(config, &name)?;
189-
let (stable_rlib, stable_deps_output) = stable.rlib_and_dep_output(config, &name)?;
199+
let (current_rlib, current_deps_output) = current.rlib_and_dep_output(config, &name, true)?;
200+
let (stable_rlib, stable_deps_output) = stable.rlib_and_dep_output(config, &name, false)?;
190201

191202
if matches.opt_present("d") {
192203
println!("--extern old={} -L{} --extern new={} -L{}",

0 commit comments

Comments
 (0)