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

rustc -o - crashes #26719

Closed
ghost opened this issue Jul 1, 2015 · 10 comments · Fixed by #131355
Closed

rustc -o - crashes #26719

ghost opened this issue Jul 1, 2015 · 10 comments · Fixed by #131355
Assignees
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@ghost
Copy link

ghost commented Jul 1, 2015

When I tried this, I was hoping it would output the executable to stdout. Saving it as a file called - would be reasonable behavior too.

$ ls
example.rs
$ rustc -o - example.rs
error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-m64" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "-" "-.o" "-Wl,--whole-archive" "-lmorestack" "-Wl,--no-whole-archive" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-7d23ff90.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-7d23ff90.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-7d23ff90.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-7d23ff90.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-7d23ff90.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-7d23ff90.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-7d23ff90.rlib" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/d/tmp/x/.rust/lib64/x86_64-unknown-linux-gnu" "-L" "/home/d/tmp/x/lib64/x86_64-unknown-linux-gnu" "-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-ldl" "-lpthread" "-lrt" "-lgcc_s" "-lpthread" "-lc" "-lm" "-lcompiler-rt"
note: cc: error: unrecognized command line option ‘-.o’

error: aborting due to previous error
$ ls
example.rs  -.metadata.o  -.o
@steveklabnik steveklabnik added the A-frontend Area: Compiler frontend (errors, parsing and HIR) label Jul 1, 2015
@steveklabnik
Copy link
Member

Triage: no change.

@Mark-Simulacrum
Copy link
Member

I almost want to say that this isn't a bug. Do gcc and clang handle this case? I feel like it would be odd to write the compiler's output (binary data) to stdout.

@ghost
Copy link
Author

ghost commented May 16, 2017

gcc and clang both output to a file called -:

$ ls
example.c
$ gcc -o - example.c
$ ls
-  example.c
$ ./-
Hello, world!
$ rm -- -
$ clang -o - example.c
$ ls
-  example.c

@steveklabnik
Copy link
Member

Triage: no change

@lenary
Copy link
Contributor

lenary commented Aug 6, 2019

It would be nice if we could still output to stdout in the case where rustc is writing printable output. If you do gcc -S -o - example.c, it should output to stdout, same with clang, and same for clang's -emit-llvm option.

@Enselic
Copy link
Member

Enselic commented Jul 24, 2023

The issue is fixed:

$ cat main.rs
fn main() {
    println!("yep, it works")
}
$ rustc -o - main.rs > ./does-it-work && chmod +x does-it-work && ./does-it-work
yep, it works

But it looks like the fix forgot to write a regression test for the non---emit case, i.e. plain rustc -o -.

We should add such a test before we close this issue.

@rustbot label E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 28, 2023
@ojoj42
Copy link

ojoj42 commented Aug 22, 2023

@rustbot claim

@fmease fmease added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Sep 3, 2024
@Josu-ke
Copy link

Josu-ke commented Sep 4, 2024

Hi team would like to contribute to the project as a beginner to rust. I see that the task is to add a unit test? Is this available?

@Josu-ke
Copy link

Josu-ke commented Sep 4, 2024

@rustbot claim

@Josu-ke
Copy link

Josu-ke commented Sep 4, 2024

I am going to give it a shot.
Seems the change should be to the Makefile in rust/tests/run-make/emit-to-stdout?

bors added a commit to rust-lang-ci/rust that referenced this issue Oct 7, 2024
Add tests for some old fixed issues

Closes rust-lang#30867
Closes rust-lang#30472
Closes rust-lang#28994
Closes rust-lang#26719 (and migrates the relevant test to the new run-make)
Closes rust-lang#23600

cc `@jieyouxu` for the run-make-support changes

try-job: x86_64-msvc
@bors bors closed this as completed in cc5a24c Oct 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 8, 2024
Rollup merge of rust-lang#131355 - clubby789:old-tests, r=jieyouxu

Add tests for some old fixed issues

Closes rust-lang#30867
Closes rust-lang#30472
Closes rust-lang#28994
Closes rust-lang#26719 (and migrates the relevant test to the new run-make)
Closes rust-lang#23600

cc `@jieyouxu` for the run-make-support changes

try-job: x86_64-msvc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants