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

librustc cannot be used as a library? #11026

Closed
killerswan opened this issue Dec 17, 2013 · 5 comments
Closed

librustc cannot be used as a library? #11026

killerswan opened this issue Dec 17, 2013 · 5 comments

Comments

@killerswan
Copy link
Contributor

When running my program:

meow $ make run_loop
./bin/testloop ./src/demo.rs --test
<<<< building tests >>>>
error: multiple input filenames provided
task 'rustc' failed at 'explicit failure', /Users/kevin/code/rust/src/librustc/driver/driver.rs:1054
task '<main>' failed at 'explicit failure', /Users/kevin/code/rust/src/librustc/lib.rs:398
make: *** [run_loop] Error 101

The "multiple input filenames provided" error is due to using the same arguments with librustc::main_args as I was using with the rustc executable. :(

https://github.com/killerswan/meow/compare/librustc#diff-7df04b77326b8a50f8284f3ac22257e3L119

That's pretty weird considering that the function I'm using is called like so inside rustc:

pub fn main() {
    std::os::set_exit_status(main_args(std::os::args()));
}
@huonw
Copy link
Member

huonw commented Dec 17, 2013

std::os::args() includes the current executable name, i.e. ./foo bar baz gives args() == ~[~"./foo", ~"bar", ~"baz"], so this is as if you were calling rustc like rustc ./bin/testloop ./src/demo.rs --test. Try removing/slicing out the first element of args().

(Closing, feel free to reopen if the above doesn't fix it.)

@huonw huonw closed this as completed Dec 17, 2013
@huonw
Copy link
Member

huonw commented Dec 17, 2013

Wait, I misinterpreted your code sample; sorry.

@huonw huonw reopened this Dec 17, 2013
@killerswan
Copy link
Contributor Author

@alexcrichton
Copy link
Member

In that last diff you posted, args[0] must be the executable name, not the -o flag (hence you have two inputs on the command line), so closing as working-as-intended.

@killerswan
Copy link
Contributor Author

Ahhh, so it is the opposite of what @huonw was thinking at first glance!

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

3 participants