Skip to content

Commit

Permalink
Added disambiguation metadata to compilations.
Browse files Browse the repository at this point in the history
This avoids errors from cargo regarding symbol resolution problems which
were discussed in rust-lang#32. This commit should fix the issue.
  • Loading branch information
ibabushkin committed Jan 26, 2018
1 parent e365ae2 commit 28b1dc0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/bin/cargo_semver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use cargo::util::important_paths::find_root_manifest_for_wd;

use getopts::{Matches, Options};

use std::env;
use std::io::Write;
use std::path::PathBuf;
use std::process::{Stdio, Command};
Expand Down Expand Up @@ -114,11 +115,21 @@ impl<'a> WorkInfo<'a> {
}

/// Obtain the paths to the produced rlib and the dependency output directory.
fn rlib_and_dep_output(&self, config: &'a Config, name: &str)
fn rlib_and_dep_output(&self, config: &'a Config, name: &str, current: bool)
-> CargoResult<(PathBuf, PathBuf)>
{
let opts = CompileOptions::default(config, CompileMode::Build);

if current {
env::set_var("RUSTFLAGS", "-C metadata=new");
} else {
env::set_var("RUSTFLAGS", "-C metadata=old");
}

let compilation = compile(&self.workspace, &opts)?;

env::remove_var("RUSTFLAGS");

let rlib = compilation.libraries[self.package.package_id()]
.iter()
.find(|t| t.0.name() == name)
Expand Down Expand Up @@ -185,8 +196,8 @@ fn do_main(config: &Config, matches: &Matches) -> CargoResult<()> {
(work_info, stable_crate.max_version.clone())
};

let (current_rlib, current_deps_output) = current.rlib_and_dep_output(config, &name)?;
let (stable_rlib, stable_deps_output) = stable.rlib_and_dep_output(config, &name)?;
let (current_rlib, current_deps_output) = current.rlib_and_dep_output(config, &name, true)?;
let (stable_rlib, stable_deps_output) = stable.rlib_and_dep_output(config, &name, false)?;

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

0 comments on commit 28b1dc0

Please sign in to comment.