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

Basic rust indexing support. #50

Merged
merged 17 commits into from
Dec 29, 2017
Merged

Basic rust indexing support. #50

merged 17 commits into from
Dec 29, 2017

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Nov 17, 2017

Don't run it yet by default, since I haven't tested it on mozilla-central.

@emilio emilio mentioned this pull request Nov 18, 2017
@emilio emilio changed the title scripts: Add a simple rust analyzer script. Basic rust indexing support. Nov 18, 2017
Copy link
Contributor

@bill-mccloskey bill-mccloskey left a comment

Choose a reason for hiding this comment

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

This looks really nice.

@@ -0,0 +1,235 @@
#[macro_use]
extern crate clap;
extern crate rls_analysis as analysis;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's kind of confusing to do this since there's already an analysis module in tools. Can you leave it as rls_analysis?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, done.

if span.column_start == span.column_end {
return format!("{}:{}", span.line_start.0, span.column_start.0 - 1);
}
let len = span.column_end.0 - span.column_end.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, fixed it.

return format!("{}:{}", span.line_start.0, span.column_start.0 - 1);
}
let len = span.column_end.0 - span.column_end.0;
format!("{}:{}-{}", span.line_start.0, span.column_start.0 - 1, len)
Copy link
Contributor

Choose a reason for hiding this comment

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

In any case, the last argument should actually be span.column_end.0 - 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, that was the fix, thanks! :)

.args_from_usage(
"<src> 'Points to the source root'
<input> 'Points to the deps/save-analysis directory'
<output> 'Points to the directory where searchfox metadata should'",
Copy link
Contributor

Choose a reason for hiding this comment

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

where searchfox metadata should go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch :)

@emilio
Copy link
Contributor Author

emilio commented Nov 22, 2017

I'm trying to run it on central... though it may take a bit :)

@emilio
Copy link
Contributor Author

emilio commented Nov 22, 2017

I added a couple more commits that make this work in mozilla-central. r? @bill-mccloskey

@bill-mccloskey
Copy link
Contributor

I tried running this locally on mozilla-central, and I got a segfault while building some Rust code. This was the error.

14:11.94 error: failed to run custom build command for style v0.0.1 (file:///home/vagrant/mozilla-index/mozilla-central/gecko-dev/servo/components/style)
14:11.94 process didn't exit successfully: /home/vagrant/mozilla-index/mozilla-central/objdir/toolkit/library/debug/build/style-348820704fd2a9fe/build-script-build (signal: 11, SIGSEGV: invalid memory reference)
14:11.94 --- stdout
14:11.94 cargo:rerun-if-changed=build.rs
14:11.94 cargo:out_dir=/home/vagrant/mozilla-index/mozilla-central/objdir/toolkit/library/x86_64-unknown-linux-gnu/debug/build/style-1623c3e1c6bdb176/out
14:11.94 cargo:rerun-if-changed=properties/declaration_block.rs
14:11.94 cargo:rerun-if-changed=properties/properties.mako.rs
14:11.94 cargo:rerun-if-changed=properties/properties.html.mako

Everything else finished successfully, but I didn't get any indexing results for WebRender or Stylo. Some crates did have data, though (libcubeb and a few other things).

Did you see anything like this, Emilio?

@bill-mccloskey
Copy link
Contributor

The same thing happens without the -Zsave-analysis option. I wonder if the current Rust nightly is just unable to build Firefox right now? Or maybe it's an issue running inside Vagrant?

@bill-mccloskey
Copy link
Contributor

I did have one idea about how to address the issue of how to land this at the same time we want to index C++ code in TaskCluster. It looks like running mach cargo check gkrust will generate the save-analysis data. That means we could analyze C++ code in TaskCluster and just run mach cargo check gkrust during the Searchfox indexing run, to index only Rust code.

@emilio
Copy link
Contributor Author

emilio commented Nov 25, 2017

The issue you're seeing is rust-lang/rust#46239. I'm landing a workaround in mozilla-central right now.

@emilio
Copy link
Contributor Author

emilio commented Nov 25, 2017

I did have one idea about how to address the issue of how to land this at the same time we want to index C++ code in TaskCluster. It looks like running mach cargo check gkrust will generate the save-analysis data. That means we could analyze C++ code in TaskCluster and just run mach cargo check gkrust during the Searchfox indexing run, to index only Rust code.

That sounds ok to me, how's the taskcluster stuff happening? I'm happy to try to integrate it that way too.

@amccreight
Copy link
Contributor

Do you actually want my review on anything here?

@emilio emilio removed the request for review from amccreight November 28, 2017 11:14
@emilio
Copy link
Contributor Author

emilio commented Nov 28, 2017

I guess billm's review is enough

This allows the script to run on central.
Unfortunate, but this happens when indexing the `future` crate. I haven't
debugged it further, but it was in builtin definitions that don't have symbols
anyway.
It now works on mozilla-central!
@emilio
Copy link
Contributor Author

emilio commented Dec 10, 2017

Rebased and verified it still works. The failure on central was fixed long ago, too.

r? @bill-mccloskey

@staktrace
Copy link
Contributor

staktrace commented Dec 27, 2017

@emilio are there any other changes you want to make here? I looked over the changes (not in much detail though) and they look sane, at least to the point where I'm comfortable merging them and iterating further afterwards. I also created new AMIs with the nightly rust and ran an indexing run with these patches, so the instance up on dev.searchfox.org right now has these changes and they seem to work fine. So if you have no objections I'd like to merge these patches (and deploy the new AMIs as default).

@emilio
Copy link
Contributor Author

emilio commented Dec 28, 2017

That'd be great! IIRC @bill-mccloskey mentioned that this was blocked on some kind of infra issue regarding reprovisioning, but if you managed to get it working I think this is good to go.

@staktrace
Copy link
Contributor

I've deployed the reprovisioned servers to indexer-16.04 and web-server-16.04 so I think merging these patches should work for tomorrow's indexing run. If something goes wrong I'll investigate.

@staktrace staktrace merged commit 9201a6b into mozsearch:master Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants