Skip to content

Rename libstd.so to libruststd.so #999

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
brson opened this issue Oct 1, 2011 · 7 comments
Closed

Rename libstd.so to libruststd.so #999

brson opened this issue Oct 1, 2011 · 7 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Comments

@brson
Copy link
Contributor

brson commented Oct 1, 2011

This is a file we will be installing in /usr/lib. Simply calling it 'std' is not very nice. The crate can still be named 'std' - it will just have a friendlier file name.

lht added a commit to lht/rust that referenced this issue Oct 29, 2011
@lht
Copy link
Contributor

lht commented Oct 29, 2011

I admit this is a bit of hackish, but it seems works. :)

Please suggest if there is a better way to handle it with keeping the crate name unchanged.

@brson
Copy link
Contributor Author

brson commented Oct 29, 2011

Hi lht.

Thanks for investigating this. I agree that is hackish. The obstacle here is that we're interpreting the filename as crate metadata; in other words, when looking for a crate named 'foo', we expect it to be in a file named 'libfoo.so'. In all other respects we treat the crate metadata as actual metadata.

I think what we should try is to completely separate these two concepts, so the crate metadata is independent of the library name.

So in find_library_crate_aux the first sanity check we do is look for a library containing the crate_name. Instead I think this function should just verify that the file looks like a library, e.g. lib*.so on linux, etc. then inspect the metadata to check the crate name.

The thing you are going to run into is that the current code handles the case where the 'use' statement doesn't specify any metadata. In find_library_crate, when it's building the crate_name it uses either the 'name' meta-item, as in use std(name = "std");, or it falls back to the identifier used in the 'use' statement, as in use std;. If we were to just match the matadata in the library with the metadata provided in the use statement, then this would match any library to any use statement that doesn't explicitly specify metadata (so 'use std;' would end up matching libfoo.so).

To remedy this we'll need to implicitly create a "name"=val meta-item when the use statement doesn't provide one and match the library metadata against that.

This approach does pose a performance risk since we will end up opening every library on the search path. I suspect that this won't be an immediate problem since our default search paths are in rustc-specific directories; we're not searching /usr/lib. Nonetheless, we should probably time a full run of 'make check' both before and after this change to make sure there isn't a serious regression.

I checked in some additional logging to creader that might help debugging.

I hope that all made sense.

lht added a commit to lht/rust that referenced this issue Oct 30, 2011
@lht
Copy link
Contributor

lht commented Oct 30, 2011

Hi, Brian! Thanks a lot of such a thorough explanation! And I learnt using log fmt to help understand the code. Very useful! :)

$ git log --oneline -n 2
69e4ba4 Rename libstd.so to libruststd.so
28bec1d rustc: Find crates by matching the name metadata

I see some slow down after the commit.
before:1m18.574s
after: 1m18.832s
This only run single time, and there are 2 failed cases since commit 2cebef0.
failures:
io::buffered_file_buf_writer_bad_name
io::file_buf_writer_bad_name

I wonder is there a simple way to just compile tests but not running them?

@brson
Copy link
Contributor Author

brson commented Oct 30, 2011

Looks good! I compared the time for a full 'make check' before and after your patch and don't see a regression, so that's ok.

Merging this is going to require some temporary makefile tweaks and a new snapshot since the stage0 compiler is still using the old rules to find libstd.so (try doing a make clean then building and you'll see the stage0 compiler can't find the standard library with the new name). I will work on that and try to get this merged on Monday.

Which OS are you running on? None of the bots show those build failures. There's no way currently to compile the tests without running them.

@lht
Copy link
Contributor

lht commented Oct 31, 2011

I found there is actually a "/?" file exists. That's because I forgot to change owner of the root directory to "root" after migrating data from Btrfs to Ext4 months ago. Fix it and now all cases are passed.

Sorry for the false alarm!

@brson
Copy link
Contributor Author

brson commented Oct 31, 2011

Oh. Those tests are pretty bad then, since they will fail when running as root.

brson pushed a commit that referenced this issue Oct 31, 2011
@brson
Copy link
Contributor Author

brson commented Oct 31, 2011

OK. This is integrated. Thanks, lht.

@brson brson closed this as completed Oct 31, 2011
lht added a commit to lht/rust that referenced this issue Dec 3, 2011
lht added a commit to lht/rust that referenced this issue Dec 10, 2011
lht added a commit that referenced this issue Dec 12, 2011
lht added a commit that referenced this issue Dec 13, 2011
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
coastalwhite pushed a commit to coastalwhite/rust that referenced this issue Aug 5, 2023
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

2 participants