riscv-software-src / riscv-isa-sim

Spike, a RISC-V ISA Simulator
Other
2.39k stars 839 forks source link

SPIKE + PK C++ `iostream` support #1778

Open mp-17 opened 1 month ago

mp-17 commented 1 month ago

Does spike + pk support C++ iostream?

For example, can this program be run with spike pk?

#include <iostream>

int main(int argc, char* argv[]) {

  std::cout << "Hello, World!";

  return 0;
}

I statically compile it, but during simulation, I get:

The futex facility returned an unexpected error code.

The error appears just by including iostream. If I replace the stream with a printf, the simulation works ONLY IF I also remove the #include <iostream> directive.

Thank you for the support!

muhammadtalhasami commented 1 month ago

Does spike + pk support C++ iostream?

For example, can this program be run with spike pk?

#include <iostream>

int main(int argc, char* argv[]) {

  std::cout << "Hello, World!";

  return 0;
}

I statically compile it, but during simulation, I get:

The futex facility returned an unexpected error code.

The error appears just by including iostream. If I replace the stream with a printf, the simulation works ONLY IF I also remove the #include <iostream> directive.

Thank you for the support!

Screenshot from 2024-08-26 00-08-33

muhammadtalhasami commented 1 month ago

@mp-17 for the c++ used this commamd riscv64-unknown-elf-g++ filename.cpp -o filename and for c use this riscv64-unknown-elf-gcc filename.c -o filename and then simply run it with spike + pk