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

RFC: remove linkage attributes #8523

Closed
catamorphism opened this issue Aug 15, 2013 · 10 comments
Closed

RFC: remove linkage attributes #8523

catamorphism opened this issue Aug 15, 2013 · 10 comments
Labels
A-frontend Area: frontend (errors, parsing and HIR) A-linkage Area: linking into static, shared libraries and binaries

Comments

@catamorphism
Copy link
Contributor

#[link(name="foo", version="3.1415927", uuid=xxxxxxxx)] is an artifact of the pre-rustpkg days. rustpkg infers the link name from the package ID, and the version from version control if it's available. @graydon and I suggest that we warn if linkage attributes are present, and eventually start ignoring them as well as warning.

@brson
Copy link
Contributor

brson commented Aug 15, 2013

where does rustc get the name and version? how will this impact non-rustpkg crates?

@graydon
Copy link
Contributor

graydon commented Aug 15, 2013

I'm ok keeping support for the name and vers attributes in the compiler for non-rustpkg crates. Rustpkg should warn on them though, as they override (possibly break) those provided by it, and we should remove all uses as we convert to rustpkg. Uuid and url should go entirely, though I don't think we even use them for anything presently.

@emberian
Copy link
Member

@catamorphism I'm going to need some guidance on emberian/rustdoc_ng#15 if this goes through.

@catamorphism
Copy link
Contributor Author

@brson I'm ok with @graydon's suggestion to keep support in rustc but have rustpkg warn about them.

@metajack
Copy link
Contributor

I think that's fine, although I think version is the exception here. Maybe only warn if it's inferrable and set?

@catamorphism
Copy link
Contributor Author

We decided to allow name and version in both non-rustpkg and rustpkg crates, but rustpkg will check that the name is the same as the inferred name, and the version is the same as the inferred version, and error out if either is inconsistent. We will eliminate any code that recognizes "uuid" and "url" specially, but we will still allow arbitrary additional attributes (these get used to compute the hash from the link attributes).

@ghost ghost assigned catamorphism Sep 24, 2013
@Kimundi
Copy link
Member

Kimundi commented Sep 24, 2013

So if you leave those two off in a library, will rustc emit the current warning about assuming name=bin name and version=0.1, but if compiled with rustpkg it won't because it inferred?

And you can just add additional attributes to allow distinguishing versions of the library beyond the default fields?

@catamorphism
Copy link
Contributor Author

@Kimundi The first is a good question. I'm inclined not to change the current behavior, so then the answer would be yes.

And yes, you'll still be able to add additional attributes to allow distinguishing versions of the library.

@catamorphism
Copy link
Contributor Author

@metajack points out that our proposed solution has a problem: if you compile the same package with both rustc and rustpkg, you have to remove the name attribute, but in that case rustc will always treat the link name as "lib".

@catamorphism
Copy link
Contributor Author

As an interim step, rustpkg should at least always inject a package ID; currently, it doesn't do that if you supply your own name and vers, causing confusion.

metajack added a commit to metajack/rust that referenced this issue Nov 21, 2013
This replaces the link meta attributes with a pkgid attribute and uses a hash
of this as the crate hash. This makes the crate hash computable by things
other than the Rust compiler. It also switches the hash function ot SHA1 since
that is much more likely to be available in shell, Python, etc than SipHash.

Fixes rust-lang#10188, rust-lang#8523.
metajack added a commit to metajack/rust that referenced this issue Dec 11, 2013
This replaces the link meta attributes with a pkgid attribute and uses a hash
of this as the crate hash. This makes the crate hash computable by things
other than the Rust compiler. It also switches the hash function ot SHA1 since
that is much more likely to be available in shell, Python, etc than SipHash.

Fixes rust-lang#10188, rust-lang#8523.
bors added a commit that referenced this issue Dec 11, 2013
This replaces the link meta attributes with a pkgid attribute and uses a hash
of this as the crate hash. This makes the crate hash computable by things
other than the Rust compiler. It also switches the hash function ot SHA1 since
that is much more likely to be available in shell, Python, etc than SipHash.

Fixes #10188, #8523.
@sanxiyn sanxiyn closed this as completed Jan 7, 2014
@catamorphism catamorphism removed their assignment Jun 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: frontend (errors, parsing and HIR) A-linkage Area: linking into static, shared libraries and binaries
Projects
None yet
Development

No branches or pull requests

7 participants