Skip to content
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

Add help for target CPUs, features, relocation and code models. #34845

Merged
merged 10 commits into from
Aug 11, 2016

Conversation

bitshifter
Copy link
Contributor

Fix for #30961. Requires PR rust-lang/llvm#45 to be accepted first, and the .gitmodules for llvm to be updated before this can be merged.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Aatch (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@@ -1,6 +1,6 @@
[submodule "src/llvm"]
path = src/llvm
url = https://github.com/rust-lang/llvm.git
url = https://github.com/bitshifter/llvm.git
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needs to be updated once llvm PR is accepted.

@bitshifter
Copy link
Contributor Author

bitshifter commented Jul 16, 2016

It looks like the travis build didn't get my llvm branch - https://travis-ci.org/rust-lang/rust/builds/145171124#L1179

@bitshifter bitshifter changed the title Issue 30961 Fix for issue 30961 Jul 16, 2016
@bitshifter
Copy link
Contributor Author

I'm a bit stumped at this point why the travis build is failing due to my llvm change not being there. My last commit 87ed467 is pointing the llvm git submodule at rust-lang/llvm@a3c12a7 which looks right. Can anyone else see what's going wrong here?

@alexcrichton
Copy link
Member

@bitshifter oh travis doesn't actually use the LLVM submodule b/c it takes too long to build, but it brings up an important point that we'd still want builds with external LLVM to continue to work. Perhaps the LLVM support here can be disabled if --llvm-root is specified?

@bitshifter
Copy link
Contributor Author

@alexcrichton Ah I see, I'll look into it.

@bitshifter
Copy link
Contributor Author

bitshifter commented Jul 23, 2016

@alexcrichton is there any way of determining if --llvm-root is set at C++ compile time. I figure I could just disable this code path if the system llvm was being used. I was looking at the -D flags passed to the compiler and didn't see anything that differentiated between system llvm and Rust's llvm. Perhaps there's a define in the rust-llvm I can look for?

Alternatively I could add a temporary #define to MCSubtargetInfo.h in the rust-lllvm branch that I can check. Even if this patch makes it into LLVM, some kind of preprocessor check for it's existence will be necessary until it makes it into a release and Rust upgrades to that release.

Remove duplication code gen options and updated help to reflect
changes.
If using system llvm don't try use modifications made in the fork.
@bitshifter
Copy link
Contributor Author

bitshifter commented Jul 24, 2016

Got past the compile error, now there is a segfault running the test. I noticed a similar segfault on another recent commit (https://travis-ci.org/rust-lang/rust/builds/146766819 - which I don't think I have) so perhaps it's unrelated to my changes?

edit: running ./configure --llvm-root=/usr/lib/llvm-3.7 && make tidy && make check-notidy -j8 locally all tests passed for me.

@Aatch Aatch changed the title Fix for issue 30961 Add help for target CPUs, features, relocation and code models. Jul 24, 2016
@Aatch
Copy link
Contributor

Aatch commented Jul 24, 2016

I updated the title, since "fixes this other issue" isn't very informative.

@alexcrichton
Copy link
Member

@bitshifter Right now I don't think there's a define for that but you can check for CFG_LLVM_ROOT in the makefiles and the build script for these files should also have a good entry point for adding a define.

@bitshifter
Copy link
Contributor Author

@alexcrichton thanks, I've added -DLLVM_RUSTLLVM based on an absence of CFG_LLVM_ROOT in ce50bed. I guess I should add something similar when using --enable-rustbuild?

@alexcrichton
Copy link
Member

@bitshifter yeah you'll want to tweak this build script. The LLVM_CONFIG variable is set here and you can use similar logic as here to set some other environment variable to indicate whether it's a custom or rust llvm

@alexcrichton
Copy link
Member

@bors: r+ fc210a8

Thanks!

@bors
Copy link
Contributor

bors commented Jul 29, 2016

⌛ Testing commit fc210a8 with merge 58bdec2...

@brson
Copy link
Contributor

brson commented Jul 30, 2016

@bors retry force clean

@bors
Copy link
Contributor

bors commented Jul 30, 2016

⌛ Testing commit fc210a8 with merge 8d2f6ea...

@bors
Copy link
Contributor

bors commented Jul 30, 2016

💔 Test failed - auto-linux-64-cargotest

@bors
Copy link
Contributor

bors commented Aug 1, 2016

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

@bitshifter
Copy link
Contributor Author

I'm on vacation at the moment, I'll take a look later in the week.

@bitshifter
Copy link
Contributor Author

bitshifter commented Aug 6, 2016

@alexcrichton I've had a little look into why the @bors homu build failed. On the homu build there was no CMake build of LLVM in the logs. So I assume that it is using an old version. I think part of the CMake build copies headers from src/llvm/include to build/x86_64-unknown-linux-gnu/llvm/include - probably a make install step. I think this is not picking up that LLVM has changed and needs to bu rebuilt. I've had this happen a bit on my local machine and have just been cleaning to fix it but I guess a better solution is required. Are you familiar with this part of the build at all? I'm not sure how to force LLVM to pick up that it needs to rebuild (perhaps when the git revision changes).

I'm also addressing the new conflicts and will submit a new PR for rust-lang/llvm shortly.

Edit: It looks like I need to edit src/rustllvm/llvm-auto-clean-trigger to fix the bors problem.

@@ -1,4 +1,4 @@
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
2016-07-25b
2016-07-25c
Copy link
Member

Choose a reason for hiding this comment

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

Oh you can actually just change this to today's date, the b was just because it was modified twice in the same day

@alexcrichton
Copy link
Member

Looks and sounds good to me, thanks for the investigation!

@@ -198,6 +198,10 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
if !build.unstable_features {
cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1");
}
// Flag that rust llvm is in use
if build.config.target_config.get(target).is_none() {
Copy link
Member

Choose a reason for hiding this comment

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

I think that this needs to check the llvm-config field in the returned table, as this is currently checking if there is any configuration at all for the target.

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 strange thing is that there seems to be no target returned at this point if --llvm-root has not been specified. If --llvm-root is specified then there is a target and it has an llvm_config set. I could make this code check for no target or a target with no llvm_config, but it seems like maybe there being no target is unexpected?

How do you usually debug this? For now I've just been printf debugging with println! or panic! calls.

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 for parsing ./configure's --llvm-root option lives here so it only sets it for one target but it should be there?

Copy link
Contributor Author

@bitshifter bitshifter Aug 9, 2016

Choose a reason for hiding this comment

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

Looking a bit closer, there are a bunch of code paths that lazily insert a default target into the target_config HashMap but none are being hit it this particular case, e.g. the code you linked to:

let target = self.target_config.entry(self.build.clone())
.or_insert(Target::default());

At the point I'm performing the check, nothing has done this although it could be created if other config.mk variables that lazily insert a target are in use.

In any case as you pointed out, the current code won't work correctly if target does exist, I'll look into a fix tonight.

@alexcrichton
Copy link
Member

@bitshifter thanks! Could you also squash the commits?

@alexcrichton alexcrichton assigned alexcrichton and unassigned Aatch Aug 8, 2016
@bitshifter
Copy link
Contributor Author

@alexcrichton Sure! How do I squash the commits? :)

Make a new branch, merge into it and make a new PR?

@alexcrichton
Copy link
Member

Oh sure, no problem! You shouldn't have to make a new PR, I think these instructions should suffice?

@bitshifter
Copy link
Contributor Author

Oh, I thought it wasn't a good idea to rebase things that have been pushed already?

From linked article:

Note: do not squash commits that you’ve already shared with others. You’re changing history and it will cause trouble for others.

@alexcrichton
Copy link
Member

Yeah for us that's fine as we define "sharing with others" as published to the master branch of rust-lang/rust. Your own local branch is only used as the PR here, so it's not necessarily "shared" yet in the sense of people relying on the commit SHAs

Point llvm @bitshifter branch until PR accepted

Use today's date for LLVM auto clean trigger

Update LLVM submodule to point at rust-lang fork.

Handle case when target is set
@bitshifter
Copy link
Contributor Author

bitshifter commented Aug 10, 2016

I think I've fixed up the target llvm-config check.

I squashed the last 5 commits, since I last merged with master.

I'm not sure if I should try and squash the other commits, since they're intermingled with merges.

@alexcrichton
Copy link
Member

@bors: r+ 05045da

Ah it's ok, no worries!

@bors
Copy link
Contributor

bors commented Aug 11, 2016

⌛ Testing commit 05045da with merge 1222f5d...

bors added a commit that referenced this pull request Aug 11, 2016
Add help for target CPUs, features, relocation and code models.

Fix for #30961. Requires PR rust-lang/llvm#45 to be accepted first, and the .gitmodules for llvm to be updated before this can be merged.
@bors bors merged commit 05045da into rust-lang:master Aug 11, 2016
@bitshifter bitshifter deleted the issue-30961 branch August 11, 2016 09:08
@bluss bluss added the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants