Skip to content

Rust should support a no extra attribute and flag. #7927

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
mstewartgallus opened this issue Jul 20, 2013 · 7 comments
Closed

Rust should support a no extra attribute and flag. #7927

mstewartgallus opened this issue Jul 20, 2013 · 7 comments

Comments

@mstewartgallus
Copy link
Contributor

Rust should support a no extra attribute and flag. This would be useful for me so I could:

  • compile my own hacked version of extra like rustc rust/src/libextra/extra.rs --output-dir .
  • compile a regressing benchmark like rustc -L . -Z no-extra rust/src/test/bench/msgsend-mutex-arcs.rs -o mutex-bench
  • and then run the benchmark file like ./mutex-bench

This would greatly speed up time hunting for the regression in mutex performance for my pull request #7701 .

@alexcrichton
Copy link
Member

I think that this should all work today anyway. Rust knows nothing about an "extra" library, so there's no need to add extra flags for it. It only so happens that the supplement of libstd is libextra. Sadly you can't quite accomplish what you wanted to do because you'd get conflicting messages about duplicate libextra files.

On the other hand, you could always modify extra.rs to have the name be something like extra2 and then have extern mod extra2 in your source file.

@alexcrichton
Copy link
Member

Basically the steps to achieve what you want sound like they can be accomplished with:

  1. Edit link(name=...) in src/libextra/extra.rs
  2. Compile to the current directory.
  3. Use extern mod extra2 or whatever name you used to link to it
  4. Compile code with -L .

Now those steps may be a bit complicated, so in my opinion the issue should be more about simplifying them possibly?

@mstewartgallus
Copy link
Contributor Author

Yes, the problem is the existing workaround is too complex. My idea about the flags is just one specific suggestion.

I think I should clarify the issue. The main problem is that the process of developing, and managing alternate versions of existing libraries is too complicated. I know the Haskell cabal package manager has a similar problem, and that people have various hacks so that they can switch between, and use separate Haskell build environments. Perhaps we can steal a good solution from there?

Also, this might be more a rustpkg problem than a rustc problem. Perhaps when rustpkg is more mature the process of automatically pulling in the extra directory could be pulled up a level of abstraction to rustpkg instead of rustc?

@Aatch
Copy link
Contributor

Aatch commented Jul 22, 2013

This is a build system problem. As @alexcrichton said, rust knows nothing about libextra. The only real issue I can see here is that if rustc can find multiple, matching crates then it bails out.

A possible solution would be making paths given on the command line take priority, so if multiple matching crates are found, it picks the highest priority one. It would still bail out if there are multiple "highest" libs though.

@huonw
Copy link
Member

huonw commented Jul 22, 2013

(@Aatch to be pedantic, it actually does, front::test inserts it automagically for --test.)

@mstewartgallus
Copy link
Contributor Author

Okay, here's my idea of how this could be solved by moving getting the extra library up a level to rustpkg. By default when RUST_PATH is unset, the location of the extra library is included in RUST_PATH. But one could set RUST_PATH to a different value, and point to a different extra library. Under this scheme rustc itself would know nothing about the extra library.

@thestinger
Copy link
Contributor

Closing in favour of #8784 which is as far as I know the unofficial official plan.

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

No branches or pull requests

5 participants