Skip to content

Commit

Permalink
Merge pull request #567 from emsec/fix/macos_build
Browse files Browse the repository at this point in the history
Fix/macos build
  • Loading branch information
joern274 authored May 17, 2024
2 parents 5d65ebc + 6f44584 commit aced3d1
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 153 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,18 @@ jobs:
run: |
mkdir -p build
cd build
export PATH="/usr/local/opt/qt@5/bin:$PATH"
ls ..
cmake -G Ninja .. -DQt5_DIR=/usr/local/opt/qt@5/lib/cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_ALL_PLUGINS=ON -DBUILD_TESTS=ON -DPL_GUI=ON -DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++
export PATH="$(brew --prefix qt@5)/bin:$PATH"
brew ls llvm@14
brew --prefix llvm@14
ls -l /usr/local
ls -l /opt/homebrew/opt
ls -l /opt/homebrew/opt/llvm@14
ls -l /opt/homebrew/opt/llvm@14/bin
ls -l /opt/homebrew/opt/llvm@14/bin/clang
cmake -G Ninja .. -DQt5_DIR="$(brew --prefix qt@5)/lib/cmake" -DCMAKE_BUILD_TYPE=Debug -DBUILD_ALL_PLUGINS=ON -DBUILD_TESTS=ON -DPL_GUI=ON -DCMAKE_C_COMPILER=$(brew --prefix llvm@14)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@14)/bin/clang++
env:
LDFLAGS: "-L/usr/local/opt/qt@5/lib -L/usr/local/opt/llvm@14/lib -Wl,-rpath,/usr/local/opt/llvm@14/lib"
CPPFLAGS: "-I/usr/local/opt/llvm@14/include"
LDFLAGS: "-L$(brew --prefix qt@5)/lib -L$(brew --prefix llvm@14)/lib -Wl,-rpath,$(brew --prefix llvm@14)/lib"
CPPFLAGS: "-I$(brew --prefix llvm@14)/include"
HAL_BASE_PATH: ${{runner.workspace}}/hal/build
CCACHE_DIR: ${{runner.workspace}}/.ccache
CCACHE_COMPRESS: true
Expand All @@ -107,12 +113,12 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cd build
export PATH="/usr/local/opt/qt/bin:$PATH"
export PATH="$(brew --prefix qt@5)/bin:$PATH"
export BUILD_TYPE=Debug
cmake --build . --target all --clean-first --config $BUILD_TYPE
env:
LDFLAGS: "-L/usr/local/opt/qt@5/lib -L/usr/local/opt/llvm@14/lib -Wl,-rpath,/usr/local/opt/llvm@14/lib"
CPPFLAGS: "-I/usr/local/opt/llvm@14/include"
LDFLAGS: "-L$(brew --prefix qt@5)/lib -L$(brew --prefix llvm@14)/lib -Wl,-rpath,$(brew --prefix llvm@14)/lib"
CPPFLAGS: "-I$(brew --prefix llvm@14)/include"
HAL_BASE_PATH: ${{runner.workspace}}/hal/build
CCACHE_DIR: ${{runner.workspace}}/.ccache
CCACHE_COMPRESS: true
Expand All @@ -133,8 +139,8 @@ jobs:
# ninja -v hal_coverage
# bash <(curl -s https://codecov.io/bash) -f hal_coverage.info.cleaned || echo "Codecov did not collect coverage reports"
env:
LDFLAGS: "-L/usr/local/opt/qt@5/lib -L/usr/local/opt/llvm@14/lib -Wl,-rpath,/usr/local/opt/llvm@14/lib"
CPPFLAGS: "-I/usr/local/opt/llvm@14/include"
LDFLAGS: "-L$(brew --prefix qt@5)/lib -L$(brew --prefix llvm@14)/lib -Wl,-rpath,$(brew --prefix llvm@14)/lib"
CPPFLAGS: "-I$(brew --prefix llvm@14)/include"
HAL_BASE_PATH: ${{runner.workspace}}/hal/build
CCACHE_DIR: ${{runner.workspace}}/.ccache
CCACHE_COMPRESS: true
Expand Down
125 changes: 0 additions & 125 deletions .github/workflows/ubuntu20.04.yml

This file was deleted.

2 changes: 1 addition & 1 deletion include/hal_core/netlist/pins/pin_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace hal
* @param[in] pin - The pin.
* @returns The index of the pin on success, an error message otherwise.
*/
Result<u32> get_index(const T* pin) const
Result<i32> get_index(const T* pin) const
{
if (pin == nullptr)
{
Expand Down
2 changes: 2 additions & 0 deletions plugins/graph_algorithm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ if(PL_GRAPH_ALGORITHM OR BUILD_ALL_PLUGINS)
LINK_LIBRARIES PUBLIC ${igraph_LIBRARIES}
)

add_dependencies(graph_algorithm igraph_0_9)

endif()
3 changes: 2 additions & 1 deletion plugins/liberty_parser/src/liberty_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ namespace hal
{
return ERR("could not parse pin: invalid pin direction '" + direction_str + "' (line " + std::to_string(pin.line_number) + ")");
}

pin_str.consume(";", true);
}
else if (next_token == "function")
Expand Down Expand Up @@ -1314,4 +1315,4 @@ namespace hal

return OK(res);
}
} // namespace hal
} // namespace hal
2 changes: 2 additions & 0 deletions plugins/liberty_parser/test/liberty_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ namespace hal {
auto gl_res = liberty_parser.parse(path_lib);
ASSERT_TRUE(gl_res.is_error());
}
#if !defined (__APPLE__)
{
// Use a pin with an unknown direction (not in {input, output}) as an input pin
NO_COUT_TEST_BLOCK;
Expand All @@ -406,6 +407,7 @@ namespace hal {
auto gl_res = liberty_parser.parse(path_lib);
ASSERT_TRUE(gl_res.is_error());
}
#endif
// { // NOTE: Works (is ok?)
// // Use an unknown variable in a boolean function
// NO_COUT_TEST_BLOCK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ namespace hal
{
auto it = mNextValueMap.begin();
if (it == mNextValueMap.end()) return false;
uint64_t currT = it->first;
DataFileHandle wff = it->second;
mNextValueMap.erase(it);
// std::cerr << "SaleaeParser::callback o=" << std::hex << (uintptr_t)wff.obj << " t=" << std::dec << it->first << " v=" << wff.value << " size=" << mNextValueMap.size() << std::endl;
wff.callback(wff.obj,it->first,wff.value);
// std::cerr << "SaleaeParser::callback o=" << std::hex << (uintptr_t)wff.obj << " t=" << std::dec << currT << " v=" << wff.value << " size=" << mNextValueMap.size() << std::endl;
wff.callback(wff.obj,currT,wff.value);
if (wff.file->good())
{
SaleaeDataTuple sdt = wff.file->get_next_value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1290,20 +1290,20 @@ namespace hal {

mTimeframe.setSceneMaxTime(tmax);
if (mustUpdateClocks) updateClocks();
qDebug() << "setMaxTime-Tfc" << mTimeframe.sceneMaxTime();
// qDebug() << "setMaxTime-Tfc" << mTimeframe.sceneMaxTime();
Q_EMIT timeframeChanged(&mTimeframe);
}

void WaveDataList::emitTimeframeChanged()
{
qDebug() << "emitTimeframeChanged-Tfc" << mTimeframe.sceneMaxTime();
// qDebug() << "emitTimeframeChanged-Tfc" << mTimeframe.sceneMaxTime();
Q_EMIT timeframeChanged(&mTimeframe);
}

void WaveDataList::incrementSimulTime(u64 deltaT)
{
mTimeframe.mSimulateMaxTime += deltaT;
qDebug() << "incrementSimulTime-Tfc" << mTimeframe.mSimulateMaxTime << ">" << mTimeframe.mSceneMaxTime;
// qDebug() << "incrementSimulTime-Tfc" << mTimeframe.mSimulateMaxTime << ">" << mTimeframe.mSceneMaxTime;
if (mTimeframe.mSimulateMaxTime > mTimeframe.mSceneMaxTime)
setMaxTime(mTimeframe.mSimulateMaxTime);
}
Expand All @@ -1323,7 +1323,7 @@ namespace hal {
wd->clear();
}
}
qDebug() << "setUserTimeframe-Tfc" << mTimeframe.sceneMaxTime();
// qDebug() << "setUserTimeframe-Tfc" << mTimeframe.sceneMaxTime();
Q_EMIT timeframeChanged(&mTimeframe);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ namespace hal
plugin_manager::unload_all_plugins();
}

void dump_engine_log(std::string directory)
{
std::cout << std::endl;
std::ifstream ff(directory + "/engine_log.html");
while (ff.good())
{
std::string line;
std::getline(ff,line);
std::cout << line << std::endl;
}
}

bool cmp_sim_data(NetlistSimulatorController* reference_simulation_ctrl, NetlistSimulatorController* simulation_ctrl, int tolerance = 200)
{
bool no_errors = true;
Expand Down Expand Up @@ -429,6 +441,7 @@ namespace hal
}
if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}

Expand Down Expand Up @@ -545,6 +558,7 @@ namespace hal

if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}

Expand Down Expand Up @@ -719,6 +733,7 @@ namespace hal

if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}

Expand Down Expand Up @@ -877,6 +892,7 @@ namespace hal
if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}
Expand Down Expand Up @@ -1333,6 +1349,7 @@ namespace hal

if (verilator_engine->get_state() == SimulationEngine::State::Failed)
{
dump_engine_log(verilator_engine->get_working_directory());
FAIL() << "engine failed";
}

Expand Down
1 change: 1 addition & 0 deletions plugins/simulator/verilator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include/verilator/path_to_verilator_executable.h
29 changes: 28 additions & 1 deletion plugins/simulator/verilator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,38 @@ option(PL_VERILATOR "PL_VERILATOR" OFF)

if(PL_VERILATOR OR PL_SIMULATOR OR BUILD_ALL_PLUGINS)

set (PATH_TO_VERILATOR_EXECUTABLE "")
find_package(verilator HINTS $ENV{VERILATOR_ROOT})
if(verilator_FOUND)
set (PATH_TO_VERILATOR_EXECUTABLE "${verilator_DIR}/bin/")
endif(verilator_FOUND)

set (PATH_TO_RAPIDJSON_INCLUDEDIR ${RAPIDJSON_INCLUDEDIR})
if (NOT PATH_TO_RAPIDJSON_INCLUDEDIR)
find_package(RapidJSON REQUIRED)
if(RapidJSON_FOUND AND NOT TARGET RapidJSON::RapidJSON)
if(NOT RAPIDJSON_INCLUDEDIR)
set(RAPIDJSON_INCLUDEDIR ${RAPIDJSON_INCLUDE_DIRS})
endif()

# fix for macOS if most recent version
if(NOT RAPIDJSON_INCLUDEDIR)
set(RAPIDJSON_INCLUDEDIR ${RapidJSON_INCLUDE_DIRS})
endif()
set (PATH_TO_RAPIDJSON_INCLUDEDIR ${RAPIDJSON_INCLUDEDIR})
endif(RapidJSON_FOUND)
endif()

file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/include/verilator/path_to_verilator_executable.h" "\
#pragma once\n\
\n\
const char* path_to_verilator_executable = \"${PATH_TO_VERILATOR_EXECUTABLE}\";\n\
const char* path_to_rapidjson_includedir = \"${PATH_TO_RAPIDJSON_INCLUDEDIR}\";\n")

file(GLOB_RECURSE VERILATOR_INC ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
file(GLOB_RECURSE VERILATOR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE VERILATOR_PYTHON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/python/*.cpp)


enable_cxx_compile_option_if_supported("-O1" "Perf" "PUBLIC")
enable_cxx_compile_option_if_supported("-g" "Perf" "PUBLIC")
enable_cxx_compile_option_if_supported("-fno-inline-functions" "Perf" "PUBLIC")
Expand Down
Loading

0 comments on commit aced3d1

Please sign in to comment.