kaist-cp / cs420

KAIST CS420: Compiler Design (2023 Spring)
423 stars 28 forks source link

[HW7] Cannot run cargo test due to failure of riscv64-linux-gnu-gcc #509

Closed kingdoctor123 closed 1 year ago

kingdoctor123 commented 1 year ago

Hello I have a trouble with running the test. I believe that it was due to failure of riscv64-linux-gnu-gcc and I don't know why it happens. riscv64-linux-gnu-gcc works perfectly ok if I type the command manually on terminal. Can you help me with this problem?

Environment: provided server (+ same thing happens when I run the same command on my laptop) Command: RUST_MIN_STACK=33554432 cargo nextest run test_examples_asmgen_small Output:

running 1 test
[testing "examples/ir0/array3.ir"]
[testing "examples/ir0/foo2.ir"]
test_asmgen entered
path: examples/ir0/foo2.ir
asmgen begin
asmgen finished
checkpoint 0
checkpoint 1
compilation by riscv64-linux-gnu-gcc failed
asm_path_str: /tmp/.tmp8X2orl/temp.S, bin_path_str: /tmp/.tmp8X2orl/temp.asmgen

   Canceling due to test failure: 0 tests still running
------------
     Summary [   0.024s] 1 tests run: 0 passed, 1 failed, 11 skipped
        FAIL [   0.024s] kecc::test_examples test_examples_asmgen_small
error: test run failed

You might see some strange strings that I inserted for debugging purpose. I inserted some println! in test_asmgen() function in /src/opt/tests.rs. Here is a part of the code that you might be interested in:

// Create the assembly code
let mut buffer = File::create(asm_path.as_path()).expect("need to success creating file");
write(&asm, &mut buffer).unwrap();

// Compile the assembly code
if !Command::new("riscv64-linux-gnu-gcc")
    .args(["-static", &asm_path_str, "-o", &bin_path_str])
    .stderr(Stdio::null())
    .status()
    .unwrap()
    .success()
{
    println!("compilation by riscv64-linux-gnu-gcc failed"); // <-- Why do I get to this point? Does it mean that gcc failed to compile?
    println!("asm_path_str: {}, bin_path_str: {}", asm_path_str, bin_path_str);
    ::std::process::exit(SKIP_TEST);
}

Thank you in advance.

kingdoctor123 commented 1 year ago

I somehow got the reason and actually it was my fault. Sorry for the interrupt.