Skip to content

Fix linker failure on windows #38949

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
Jan 17, 2017
Merged

Conversation

GuillaumeGomez
Copy link
Member

Fixes #38933.

r? @ollie27

@GuillaumeGomez GuillaumeGomez changed the title Fix linker failure Fix linker failure on windows Jan 9, 2017
@@ -667,7 +667,9 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
new_path.push(path);
}
}
env::set_var("PATH", &env::join_paths(new_path).unwrap());
if let Ok(p) = env::join_paths(new_path) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of not setting PATH altogether, we should just ignore the components that make construction of the PATH to fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would give an invalid PATH. Not sure this is what we want... At least, the current change doesn't set the variable at all if any path is not valid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would give an invalid PATH.

What? Of course it would become a valid PATH once you filter out all the parts that can’t be put into PATH. Maybe it would not be complete, but certainly valid.

What your current patch does, on the other hand, is making whatever function this code had not come into effect whenever there’s any path from any source that cannot be put into PATH.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I missed something then. In here, we just join 2 paths, if one is invalid, we should only keep the other one, right? I'll try to update in this way then.

@GuillaumeGomez
Copy link
Member Author

@nagisa: Better?

@nagisa
Copy link
Member

nagisa commented Jan 11, 2017

Remembering that $PATH and sess.host_filesearch(PathKind::All).get_dylib_search_paths() both are collection of pathes (i.e. vec![p1, p2, p3, ...] and vec![dsp1, dsp2, dsp3, ...]) and we want to merge them into a single $PATH… pathes from $PATH cannot be invalid as they are parsed from the same $PATH, but the dsp1.. could be. Even then you still want to join them as they have some purpose – not merging any of the dsp* in when only dsp42 is invalid seems lazy.

So here’s some implementation strategies I had in mind:

// validate pathes by joining them one by one:
env::join_paths(new_paths.filter(|p| env::join_paths(iter::once(path)).is_ok()));

or

// write an iterator such that
struct Iter<E: Clone> { last_yielded: E, other: ... }

loop {
let i = Iter { ... };
let r = env::join_paths(i);
if r.is_ok() { break; }
// i.last_yielded is the invalid path that cannot be included into $PATH, remove and retry.
}

does it make what I meant any clearer?

@GuillaumeGomez
Copy link
Member Author

Indeed. I'll just take your first example then.

@GuillaumeGomez
Copy link
Member Author

Updated.

@GuillaumeGomez
Copy link
Member Author

Any news @nagisa?

@nagisa
Copy link
Member

nagisa commented Jan 16, 2017

This approach LGTM to me.

@GuillaumeGomez
Copy link
Member Author

@bors: r=nagisa

@bors
Copy link
Collaborator

bors commented Jan 16, 2017

📌 Commit 6f58b7f has been approved by nagisa

@bors
Copy link
Collaborator

bors commented Jan 17, 2017

⌛ Testing commit 6f58b7f with merge 4ce7acc...

bors added a commit that referenced this pull request Jan 17, 2017
@bors
Copy link
Collaborator

bors commented Jan 17, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nagisa
Pushing 4ce7acc to master...

@bors bors merged commit 6f58b7f into rust-lang:master Jan 17, 2017
@GuillaumeGomez GuillaumeGomez deleted the fix_linker branch November 24, 2017 20:55
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