Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Mar 30, 2016

This fixes issues with --llvm-root in msys2.

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

}

#[cfg(windows)]
pub fn build_path(path: &str) -> PathBuf {
Copy link
Member

Choose a reason for hiding this comment

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

Hm this seems very suspicious about how this would be called, how are MSYS paths leaking into the configuration here? Are the makefiles encoding MSYS paths?

Also, this can probably be done in Rust like sanitize_sh rather than forking out to cygpath, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The configure script produces MSYS path, so we need to convert them when importing config.mk.

I'm not sure what the logic is to convert to Windows paths, so I'd rather avoid writing that.

Copy link
Member

Choose a reason for hiding this comment

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

The logic should be pretty simple, right? /a/foo translates to A:\foo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's only the Windows paths in msys form. There are also things like /home and even /h/path where /h as a directory and not a drive.

Copy link
Member

Choose a reason for hiding this comment

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

Right so this can cause problems, but this happens on every startup of the build system, so it would be best to spawn fewer processes and just catch up on edge cases over time. The vast majority of these paths will just be /c/foo or /other that we need to fix (which are all trivial to fix)

Copy link
Member

Choose a reason for hiding this comment

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

Or actually, even better, we should change the configure script to not emit MSYS paths, but rather use cygpath in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to touch that script though.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we can stomach all of these process spawns on every invocation of the build system, so this needs to be handled in some method.

@@ -180,6 +180,7 @@ def parse_nightly_dates(self):

def build_bootstrap(self):
env = os.environ.copy()
env["CARGO_HOME"] = os.path.join(self.build_dir, "cargo")
Copy link
Member

Choose a reason for hiding this comment

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

How come this was added? In theory this should pick up the same CARGO_HOME that it inherits?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added so rustbuild doesn't write to directories outside the build directory and the rust source.

Copy link
Member

Choose a reason for hiding this comment

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

Let's leave this out for now as it seems unrelated to this change, and this can always be set externally or we can add a configuration option for it.

@@ -78,6 +79,24 @@ pub fn check(build: &mut Build) {
panic!("the iOS target is only supported on OSX");
}

if cfg!(windows) {
Copy link
Member

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-config and the compiler by ensuring that the dynamically linked libraries are in PATH?

Copy link
Member

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 ldpath to handle the Unix/OSX cases?

Copy link
Contributor Author

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,

Copy link
Member

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-config at all? Or running the compiler if it's dynamically linked? I may be misunderstanding the purpose for this though?

Copy link
Contributor Author

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-config on 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).

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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 PATH but on Linux/OSX this id LD_LIBRARY_PATH and DYLD_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.

@bors
Copy link
Collaborator

bors commented Apr 9, 2016

☔ The latest upstream changes (presumably #32751) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to resubmit with a rebase!

@Zoxc Zoxc mentioned this pull request Oct 5, 2016
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.

4 participants