esl-epfl / x-heep

eXtendable Heterogeneous Energy-Efficient Platform based on RISC-V
Other
141 stars 75 forks source link

Added C++ support for GCC #518

Closed beeeeep closed 2 months ago

beeeeep commented 4 months ago
  1. Minor edits in the sw/device/ files to avoid any errors caused due differences in C and C++
  2. Changes in CMakeLists.txt to include C++ projects and .cpp files. Additionally some compile flags for C++ were added
  3. Addition of some c++ oriented syscall and heap functions in the heap.cpp and syscalls_cpp.cpp files
  4. In example_cpp, changed main.c to main.cpp
JoseCalero commented 4 months ago

thanks for the porting! Generally, it is OK. Let's try to fix these initial comments, then we need to check why the building is failing (see the CI) --> i know that the changes of the CMakeLists.txt are maybe failing at some point --> could you check that all apps are compiling? (see the test_all.sh script under the util folder)

JoseCalero commented 3 months ago

thanks for the porting! Generally, it is OK. Let's try to fix these initial comments, then we need to check why the building is failing (see the CI) --> i know that the changes of the CMakeLists.txt are maybe failing at some point --> could you check that all apps are compiling? (see the test_all.sh script under the util folder)

@beeeeep can you check the comments i left? otherwise, i will close the PR, replicate in another PR and try to merge a version of it (maybe without too many code compilation optimizations)

beeeeep commented 3 months ago

Sorry for the delay, but I was away these days. have done most of the changes required. Now I just have to figure out why some apps do not compile, it has to do with CMAKE. I'll get to it from Monday.

beeeeep commented 3 months ago

Hello, I've finished with the changes and brought the fork up to date as well. All the applications have been tested in the sim with test_all.sh

JuanSapriza commented 3 months ago

From what I understand from the title, the idea is to be able to compile applications in C++ with gcc. But what is going to happen with clang or the ohw-gcc?

CMake Error at CMakeLists.txt:381 (add_executable):
  Cannot find source file:

    /__w/x-heep/x-heep/sw/applications/example_cpp/main.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at CMakeLists.txt:381 (add_executable):
  No SOURCES given to target: main.elf

CMake Generate step failed.  Build files cannot be regenerated correctly.
-- Configuring done
make[1]: *** [cmake/targets.mak:26: build/Makefile] Error 1
make[1]: Leaving directory '/__w/x-heep/x-heep/sw'
make: *** [Makefile:149: app] Error 2
================================================================================
Failure building example_cpp using Clang
================================================================================
beeeeep commented 3 months ago

From what I understand from the title, the idea is to be able to compile applications in C++ with gcc. But what is going to happen with clang or the ohw-gcc?

CMake Error at CMakeLists.txt:381 (add_executable):
  Cannot find source file:

    /__w/x-heep/x-heep/sw/applications/example_cpp/main.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at CMakeLists.txt:381 (add_executable):
  No SOURCES given to target: main.elf

CMake Generate step failed.  Build files cannot be regenerated correctly.
-- Configuring done
make[1]: *** [cmake/targets.mak:26: build/Makefile] Error 1
make[1]: Leaving directory '/__w/x-heep/x-heep/sw'
make: *** [Makefile:149: app] Error 2
================================================================================
Failure building example_cpp using Clang
================================================================================

I thought that the tests were separate for GCC and Clang, I am working on a fix for Clang at the moment.

beeeeep commented 3 months ago

Hello, unfortunately we do not have time to work with the clang integration at the moment, we might be able to pick it up again in one month or so. One solution would be remove the exampe_cpp test for clang, or close the pull request and make another one in the future.

JuanSapriza commented 3 months ago

Hello! I opened a PR with @beeeeep fixing the CI to exclude this cpp file. It also supports multi-source projects now. @davideschiavone

Maybe a quick look from @JoseCalero once it's merged? (it should appear automatically in this PR once merged on beeeeep's)

JoseCalero commented 3 months ago

I will do a final check and will merge today

JoseCalero commented 3 months ago

Everything OK, @JuanSapriza can you test the spi apps in the FPGA? After that we can merge

JuanSapriza commented 2 months ago

example_sdk_spi_flash - :ballot_box_with_check: example_spi_read - :ballot_box_withcheck: (in the test_apps.py blacklist)_

example_spi_host_dma_power_gate- :x: Stuck after Launched, might make sense tho _(in the test_apps.py blacklist)_

example_spi_write - :x: Wrong results on every address _(in the test_apps.py blacklist)_ :warning: BUT WORKS ON MAIN

@JoseCalero

davideschiavone commented 2 months ago

thanks a lot @beeeeep :) appreciated a lot