summaryrefslogtreecommitdiff
path: root/pkgs/force-riscv
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/force-riscv')
-rw-r--r--pkgs/force-riscv/default.nix67
-rw-r--r--pkgs/force-riscv/imageio-include-string.patch12
-rw-r--r--pkgs/force-riscv/remove-pyeval-initthreads.patch12
-rw-r--r--pkgs/force-riscv/testio-include-string.patch12
-rw-r--r--pkgs/force-riscv/urbg-static-constexpr-min-max.patch15
-rw-r--r--pkgs/force-riscv/wno-error-range-loop-construct.patch13
6 files changed, 131 insertions, 0 deletions
diff --git a/pkgs/force-riscv/default.nix b/pkgs/force-riscv/default.nix
new file mode 100644
index 0000000..35907ce
--- /dev/null
+++ b/pkgs/force-riscv/default.nix
@@ -0,0 +1,67 @@
+{ fetchFromGitHub, lib, makeWrapper, python3, stdenv }:
+with lib; stdenv.mkDerivation {
+ pname = "force-riscv";
+ version = "master-2023-01-31";
+
+ src = fetchFromGitHub {
+ repo = "force-riscv";
+ owner = "openhwgroup";
+
+ rev = "192bcc15e0dde8aaf25621da4317569b3f374047";
+ sha256 = "sha256-Eol973IMGRVAuw/rsYiK61+KVYkmbqq9yudaNbMCzJ0=";
+ };
+
+ buildInputs = [ python3 ];
+ nativeBuildInputs = [ makeWrapper ];
+
+ patches = [
+ ./remove-pyeval-initthreads.patch
+ ./wno-error-range-loop-construct.patch
+ ./imageio-include-string.patch
+ ./testio-include-string.patch
+ ./urbg-static-constexpr-min-max.patch
+ ];
+
+ postPatch = ''
+ patchShebangs utils/ fpix/utils/
+ '';
+
+ makeFlags = [
+ "FORCE_CC=${stdenv.cc.targetPrefix}c++"
+ "FORCE_PYTHON_LIB=${python3}/lib"
+ "FORCE_PYTHON_INC=${python3}/include/${python3.libPrefix}"
+ ];
+
+ # Ver setenv.bash
+ installPhase =
+ let
+ paths = [
+ "3rd_party/py"
+ "utils"
+ "utils/builder"
+ "utils/builder/test_builder"
+ "utils/builder/shared"
+ "utils/regression"
+ ];
+
+ pythonPath = concatStringsSep ":" (map (p: "$out/${p}") paths);
+ in
+ ''
+ mkdir -p $out/ $out/fpix/ $out/riscv/ $out/3rd_party/
+
+ # SimApiHANDCAR.so queda en bin (?), al parecer es así
+ cp -r bin/ py/ $out/
+ cp -r fpix/bin/ $out/fpix/
+
+ for BIN in $out/bin/friscv $out/fpix/bin/fpix_riscv; do
+ wrapProgram $BIN \
+ --prefix PYTHONPATH : ${pythonPath}
+ done
+
+ rm -r utils/handcar/make_area
+
+ cp -r 3rd_party/py/ $out/3rd_party/
+ cp -r config/ utils/ $out/
+ cp -r riscv/arch_data/ $out/riscv/
+ '';
+}
diff --git a/pkgs/force-riscv/imageio-include-string.patch b/pkgs/force-riscv/imageio-include-string.patch
new file mode 100644
index 0000000..90417c1
--- /dev/null
+++ b/pkgs/force-riscv/imageio-include-string.patch
@@ -0,0 +1,12 @@
+diff --git a/base/inc/ImageIO.h b/base/inc/ImageIO.h
+index f93866c..046dacb 100644
+--- a/base/inc/ImageIO.h
++++ b/base/inc/ImageIO.h
+@@ -17,6 +17,7 @@
+ #define Force_ImageIO_H
+
+ #include <map>
++#include <string>
+
+ #include "Defines.h"
+
diff --git a/pkgs/force-riscv/remove-pyeval-initthreads.patch b/pkgs/force-riscv/remove-pyeval-initthreads.patch
new file mode 100644
index 0000000..b31f0e2
--- /dev/null
+++ b/pkgs/force-riscv/remove-pyeval-initthreads.patch
@@ -0,0 +1,12 @@
+diff --git a/3rd_party/inc/pybind11/detail/internals.h b/3rd_party/inc/pybind11/detail/internals.h
+index 86fbe92..31ff371 100644
+--- a/3rd_party/inc/pybind11/detail/internals.h
++++ b/3rd_party/inc/pybind11/detail/internals.h
+@@ -265,7 +265,6 @@ PYBIND11_NOINLINE inline internals &get_internals() {
+ auto *&internals_ptr = *internals_pp;
+ internals_ptr = new internals();
+ #if defined(WITH_THREAD)
+- PyEval_InitThreads();
+ PyThreadState *tstate = PyThreadState_Get();
+ #if PY_VERSION_HEX >= 0x03070000
+ internals_ptr->tstate = PyThread_tss_alloc();
diff --git a/pkgs/force-riscv/testio-include-string.patch b/pkgs/force-riscv/testio-include-string.patch
new file mode 100644
index 0000000..5b36d9f
--- /dev/null
+++ b/pkgs/force-riscv/testio-include-string.patch
@@ -0,0 +1,12 @@
+diff --git a/base/inc/TestIO.h b/base/inc/TestIO.h
+index 7d28c32..08a9167 100644
+--- a/base/inc/TestIO.h
++++ b/base/inc/TestIO.h
+@@ -17,6 +17,7 @@
+ #define Force_TestIO_H
+
+ #include <map>
++#include <string>
+
+ #include "Defines.h"
+
diff --git a/pkgs/force-riscv/urbg-static-constexpr-min-max.patch b/pkgs/force-riscv/urbg-static-constexpr-min-max.patch
new file mode 100644
index 0000000..a047fd0
--- /dev/null
+++ b/pkgs/force-riscv/urbg-static-constexpr-min-max.patch
@@ -0,0 +1,15 @@
+diff --git a/base/inc/Random.h b/base/inc/Random.h
+index 6354dee..21660a9 100644
+--- a/base/inc/Random.h
++++ b/base/inc/Random.h
+@@ -56,8 +56,8 @@ namespace Force {
+ class RandomURBG32 {
+ public:
+ typedef uint32 result_type; //!< Type define required by STL
+- uint32 min() const { return 0; } //!< min function required by STL
+- uint32 max() const { return MAX_UINT32; } //!< max function required by STL
++ static constexpr uint32 min() { return 0; } //!< min function required by STL
++ static constexpr uint32 max() { return MAX_UINT32; } //!< max function required by STL
+ uint32 operator () () const { return mpRandomInstance->Random32(min(), max()); }
+
+ explicit RandomURBG32(const Random* randomInstance) : mpRandomInstance(randomInstance) { } //!< Constructor with pointer to a Random object provieded.
diff --git a/pkgs/force-riscv/wno-error-range-loop-construct.patch b/pkgs/force-riscv/wno-error-range-loop-construct.patch
new file mode 100644
index 0000000..034d522
--- /dev/null
+++ b/pkgs/force-riscv/wno-error-range-loop-construct.patch
@@ -0,0 +1,13 @@
+diff --git a/utils/make/Makefile.common b/utils/make/Makefile.common
+index d0c96d3..422f6eb 100644
+--- a/utils/make/Makefile.common
++++ b/utils/make/Makefile.common
+@@ -60,7 +60,7 @@ else
+ PYTHON_LIB_TYPE=
+ endif
+
+-CFLAGS = -Wall -std=c++11 -gdwarf-3 -m64 -Werror $(OPTIMIZATION) $(PICKY_FLAGS) $(VISIBILITY) -D $(ARCH_ENUM_HEADER)
++CFLAGS = -Wall -std=c++11 -gdwarf-3 -m64 -Werror $(OPTIMIZATION) $(PICKY_FLAGS) $(VISIBILITY) -D $(ARCH_ENUM_HEADER) -Wno-error=range-loop-construct
+ LFLAGS = -lpthread -static-libstdc++ -static-libgcc -L$(PYTHON_LIB) -lpython$(PYTHON_VER)$(PYTHON_LIB_TYPE) -lutil -ldl -rdynamic
+
+ ALL_OBJS := $(ALL_SRCS:%.cc=$(OBJ_DIR)/%.o)