cvut / qtrvsim

RISC-V CPU simulator for education purposes
GNU General Public License v3.0
493 stars 65 forks source link

Fix Build Issues on macOS #94

Closed SConaway closed 10 months ago

SConaway commented 10 months ago

This PR addresses build issues in macOS.

First, the include directories of a system libelf needs to use the ${LIBELF_INCLUDE_DIR} variable, not just ${LIBELF_INCLUDE}.

Second, the libelf installed using homebrew doesn't define EM_RISCV:

/src/machine/programloader.cpp:62:32: error: use of undeclared identifier 'EM_RISCV'
    if (this->hdr.e_machine != EM_RISCV) {

It seems to be too old to include it.

jdupak commented 10 months ago

Hi @SConaway, thanks for raising the issue and suggesting sollution. There is one more issue we need to address: when libelf is installed (as dependency for something else) but it is unusable for us. It seems the best way would be to use https://cmake.org/cmake/help/latest/module/CheckSymbolExists.html to check RISCV compatibility.

If you have time, feel free to look into it. Otherwise I will try to find some time to add that myself.

Anyway, thanks.

SConaway commented 10 months ago

Yeah, I'll take care of that today or tomorrow. That'll solve the macOS build issue with libelf from brew.

SConaway commented 10 months ago

I've tested this on both my mac and on Fedora with elfutils-devel installed.