-
Notifications
You must be signed in to change notification settings - Fork 14.1k
rustbuild changes to build LLVM #32599
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,29 @@ use std::process::Command; | |
| use bootstrap::{dylib_path, dylib_path_var}; | ||
| use filetime::FileTime; | ||
|
|
||
| #[cfg(not(windows))] | ||
| pub fn build_path(path: &str) -> PathBuf { | ||
| PathBuf::from(path) | ||
| } | ||
|
|
||
| #[cfg(windows)] | ||
| pub fn build_path(path: &str) -> PathBuf { | ||
|
||
| use std::io::{stderr, Write}; | ||
| use build_helper::output; | ||
|
|
||
| if path.chars().next() == Some('/') { | ||
| let output = output(&mut Command::new("cygpath").arg("-w").arg(path)); | ||
| let win_path = output.trim_right(); | ||
| writeln!(&mut stderr(), | ||
| "note: Converted Unix path '{}' to Windows path '{}'", | ||
| path, | ||
| win_path).ok(); | ||
| PathBuf::from(win_path) | ||
| } else { | ||
| PathBuf::from(path) | ||
| } | ||
| } | ||
|
|
||
| pub fn staticlib(name: &str, target: &str) -> String { | ||
| if target.contains("windows-msvc") { | ||
| format!("{}.lib", name) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment to this explaining that this is just ensuring that we can run binaries like
llvm-configand the compiler by ensuring that the dynamically linked libraries are inPATH?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also seems relevant for all platforms (not just Windows), so perhaps this could create a variable like
ldpathto handle the Unix/OSX cases?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed on Linux atleast, since it links using full paths and not just the filename,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this needed for running
llvm-configat all? Or running the compiler if it's dynamically linked? I may be misunderstanding the purpose for this though?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not need for
llvm-configon Windows, since it's in the directory with the DLLs. It is needed for executables which are not in the LLVM's binary directory which link dynamically to LLVM (like rustc).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but that's not a Windows specific limitation, right? If rustc ever dynamically links to LLVM (on any platform) we need the library directory to be in the dynamic library path?
It looks like the difference is just that the dynamic library directory on Windows happens to be the same as the binaries directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is Windows specific, as you link with filenames on Windows and not paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I think I'm not being clear enough. So if you're liking with an external LLVM that is itself dynamically linked, then the only hope we have of working correctly is to ensure that the directory with that LLVM dynamic library is in the runtime linker lookup path. On Windows this just happens to be
PATHbut on Linux/OSX this idLD_LIBRARY_PATHandDYLD_LIBRARY_PATH.Which is to say, if we link to a dynamically linked LLVM on any platform, we need to run this logic to ensure that the relevant directory is in the relevant environment variable.