Skip to content
Senran (Stephen) Zhang edited this page Jul 25, 2023 · 7 revisions

How to build on debian bullseye:

Failed when building tiger/*. Not sure if I need them.

It seems I don't need to build gcc-4.8.5 and can comment out building dragonegg if I don't use gcc as the frontend, right?

Build GCC

  1. install gcc-multilib;
  2. download gcc-4.8.5 source from gnu site;
  3. add #include <signal.h> to libsanitizer/asan/asan_linux.cc;
  4. add #include "bits/types/res_state.h" to libsanitizer/tsan/tsan_platform_linux.cc;
  5. run find -name linux-unwind.h -exec sed 's/struct ucontext /ucontext_t /' {} \;;
  6. run find libjava/ -name '*-signal.h' -exec sed -i 's/struct ucontext /ucontext_t /' {} \;
  7. run mkdir build && cd build && ../configure && make -j && make DESTDIR=/path/to/gcc/install install;

Build LegUp

  1. clone a llvm/ repo;
  2. checkout to f60022375490;
  3. copy all *.inc and *.def from llvm/repo to legup-4.0/llvm; and also copy llvm/utils/llvm-build/llvmbuild/main.py, and also a missing LLVMBuild.txt.
  4. checkout llvm to 9f4f5d94cd9a;
  5. copy all *.inc and *.def from llvm/repo to legup-4.0/llvm-2.9_mips;
  6. install libmariadb-dev-compat libtool-bin libmariadb-dev liblpsolve55-dev libisl-dev libgmp-dev autoconf tcl8.6-dev;
  7. apply the patch.diff below;
  8. cd legup-4.0/llvm && ./autoconf/AutoRegen.sh;
  9. cd legup-4.0/llvm-2.9_mips && ./autoconf/AutoRegen.sh;
  10. Append --enable-targets=mips to llvm-2.9_mips configure line in legup-4.0/Makefile;
  11. dowload dragonegg source code wget http://llvm.org/releases/3.3/dragonegg-3.3.src.tar.gz;
  12. copy dragonegg-3.3.src/src/x86/ABIHack.inc and include/dragonegg/gt-cache-4.6.inc;
  13. remove TARGET_CPU_DEFAULT_max in ABIHack.inc:1666; it seems the ABIHack.inc doesn't match the source used in legup, but it doesn't matter IMO;
  14. set DRAGONEGG_GCC_VERSION = /path/gcc-4.8.5/bin/gcc in Makefile;
  15. download clang-3.5 from https://releases.llvm.org/3.5.0/clang+llvm-3.5.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz;
  16. uncompress the tarball above; cd bin/ && ln -s clang clang-3.5; prepend path to clang to PATH;
  17. cd legup-4.0 && PYTHON=/usr/bin/python2.7 make

patch.diff

diff --git a/legup-4.0/llvm-2.9_mips/autoconf/AutoRegen.sh b/legup-4.0/llvm-2.9_mips/autoconf/AutoRegen.sh
index e6c46fdd..12e8e36f 100755
--- a/legup-4.0/llvm-2.9_mips/autoconf/AutoRegen.sh
+++ b/legup-4.0/llvm-2.9_mips/autoconf/AutoRegen.sh
@@ -14,10 +14,10 @@ clean() {
 ### Periods should be escaped with backslash for use by grep.
 ###
 ### If you update these, please also update docs/GettingStarted.html
-want_autoconf_version='2\.63'
+want_autoconf_version='2\.69'
 want_autoheader_version=$want_autoconf_version
-want_aclocal_version='1\.10\.1'
-want_libtool_version='2\.2\.6'
+want_aclocal_version='1\.16'
+want_libtool_version='2\.4\.6'
 ### END NOTE #########################################################
 
 outfile=configure
diff --git a/legup-4.0/llvm-2.9_mips/autoconf/configure.ac b/legup-4.0/llvm-2.9_mips/autoconf/configure.ac
index 3f05642e..ac1943ac 100644
--- a/legup-4.0/llvm-2.9_mips/autoconf/configure.ac
+++ b/legup-4.0/llvm-2.9_mips/autoconf/configure.ac
@@ -1344,7 +1344,7 @@ AC_DEFINE_UNQUOTED([USE_OPROFILE],$USE_OPROFILE,
 ##########
 # Figure out what C libraries are required to compile Tcl programs.
 #
-AC_SEARCH_LIBS(Tcl_Init, tcl8.5 tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,)
+AC_SEARCH_LIBS(Tcl_Init, tcl8.6 tcl8.5 tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,)
 
 ##########
 # Figure out where to get the TCL header files.
@@ -1352,7 +1352,7 @@ AC_SEARCH_LIBS(Tcl_Init, tcl8.5 tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,)
 found=no
 AC_CHECK_HEADER(tcl.h, [found=yes])
 if test "$found" = "no"; then
-  for dir in /usr/include/tcl8.5 /usr/include/tcl8.4 /usr/include/tcl8.3 \
+  for dir in /usr/include/tcl8.6 /usr/include/tcl8.5 /usr/include/tcl8.4 /usr/include/tcl8.3 \
       /usr/local/include /usr/X11/include /usr/X11R6/include /usr/pkg/include \
       /usr/contrib/include /usr/include; do
     AC_CHECK_HEADER($dir/tcl.h, found=yes)
@@ -1452,7 +1452,7 @@ LDFLAGS=$new_ldflags
 found=no
 AC_CHECK_HEADER(mysql.h, [found=yes])
 if test "$found" = "no"; then
-for dir in /usr/include/mysql/ /usr/local/include /usr/contrib/include /usr/include; do
+for dir in /usr/include/mariadb/ /usr/include/mysql/ /usr/local/include /usr/contrib/include /usr/include; do
   AC_CHECK_HEADER($dir/mysql.h, found=yes)
   if test "$found" = "yes"; then
     LIBS="$LIBS -I$dir -lmysqlclient -lz"
diff --git a/legup-4.0/llvm/autoconf/AutoRegen.sh b/legup-4.0/llvm/autoconf/AutoRegen.sh
index e9b752ac..63024acf 100755
--- a/legup-4.0/llvm/autoconf/AutoRegen.sh
+++ b/legup-4.0/llvm/autoconf/AutoRegen.sh
@@ -16,7 +16,7 @@ clean() {
 ### If you update these, please also update docs/GettingStarted.rst
 want_autoconf_version='2\.69'
 want_autoheader_version=$want_autoconf_version
-want_aclocal_version='1\.14\.1'
+want_aclocal_version='1\.16'
 ### END NOTE #########################################################
 
 outfile=configure
diff --git a/legup-4.0/llvm/autoconf/configure.ac b/legup-4.0/llvm/autoconf/configure.ac
index b2c6b977..d7540c81 100644
--- a/legup-4.0/llvm/autoconf/configure.ac
+++ b/legup-4.0/llvm/autoconf/configure.ac
@@ -1592,7 +1592,7 @@ AC_SUBST(LIBXML2_INC)
 ##########
 # Figure out what C libraries are required to compile Tcl programs.
 #
-AC_SEARCH_LIBS(Tcl_Init, tcl8.5 tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,)
+AC_SEARCH_LIBS(Tcl_Init, tcl8.6 tcl8.5 tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,)
 
 ##########
 # Figure out where to get the TCL header files.
@@ -1600,7 +1600,7 @@ AC_SEARCH_LIBS(Tcl_Init, tcl8.5 tcl8.4 tcl8.3 tcl84 tcl83 tcl,,,)
 found=no
 AC_CHECK_HEADER(tcl.h, [found=yes])
 if test "$found" = "no"; then
-  for dir in /usr/include/tcl8.5 /usr/include/tcl8.4 /usr/include/tcl8.3 \
+  for dir in /usr/include/tcl8.6 /usr/include/tcl8.5 /usr/include/tcl8.4 /usr/include/tcl8.3 \
       /usr/local/include /usr/X11/include /usr/X11R6/include /usr/pkg/include \
       /usr/contrib/include /usr/include; do
     AC_CHECK_HEADER($dir/tcl.h, found=yes)
@@ -1749,7 +1749,7 @@ AC_SUBST(TARGET_LPSOLVE_INC)
 found=no
 AC_CHECK_HEADER(mysql.h, [found=yes])
 if test "$found" = "no"; then
-for dir in /usr/include/mysql/ /usr/local/include /usr/contrib/include /usr/include; do
+for dir in /usr/include/mariadb/ /usr/include/mysql/ /usr/local/include /usr/contrib/include /usr/include; do
   AC_CHECK_HEADER($dir/mysql.h, found=yes)
   if test "$found" = "yes"; then
     LIBS="$LIBS -I$dir -lmysqlclient -lz"
diff --git a/legup-4.0/llvm-2.9_mips/include/llvm/ADT/IntervalMap.h b/legup-4.0/llvm-2.9_mips/include/llvm/ADT/IntervalMap.h
index f28ebf3b..82d9997e 100644
--- a/legup-4.0/llvm-2.9_mips/include/llvm/ADT/IntervalMap.h
+++ b/legup-4.0/llvm-2.9_mips/include/llvm/ADT/IntervalMap.h
@@ -1974,7 +1974,7 @@ iterator::overflow(unsigned Level) {
     CurSize[Nodes] = CurSize[NewNode];
     Node[Nodes] = Node[NewNode];
     CurSize[NewNode] = 0;
-    Node[NewNode] = this->map->newNode<NodeT>();
+    Node[NewNode] = this->map->template newNode<NodeT>();
     ++Nodes;
   }
 
diff --git a/legup-4.0/llvm-2.9_mips/include/llvm/ADT/PointerUnion.h b/legup-4.0/llvm-2.9_mips/include/llvm/ADT/PointerUnion.h
index 487096a1..bf079432 100644
--- a/legup-4.0/llvm-2.9_mips/include/llvm/ADT/PointerUnion.h
+++ b/legup-4.0/llvm-2.9_mips/include/llvm/ADT/PointerUnion.h
@@ -263,7 +263,7 @@ namespace llvm {
         ::llvm::PointerUnionTypeSelector<PT1, T, IsInnerUnion,
           ::llvm::PointerUnionTypeSelector<PT2, T, IsInnerUnion, IsPT3 >
                                                                    >::Return Ty;
-      return Ty(Val).is<T>();
+      return Ty(Val).template is<T>();
     }
     
     /// get<T>() - Return the value of the specified pointer type. If the
@@ -276,7 +276,7 @@ namespace llvm {
         ::llvm::PointerUnionTypeSelector<PT1, T, IsInnerUnion,
           ::llvm::PointerUnionTypeSelector<PT2, T, IsInnerUnion, IsPT3 >
                                                                    >::Return Ty;
-      return Ty(Val).get<T>();
+      return Ty(Val).template get<T>();
     }
     
     /// dyn_cast<T>() - If the current value is of the specified pointer type,
diff --git a/legup-4.0/llvm/lib/Target/Verilog/LegupTcl.h b/legup-4.0/llvm/lib/Target/Verilog/LegupTcl.h
index d2d29baa..25074b2b 100644
--- a/legup-4.0/llvm/lib/Target/Verilog/LegupTcl.h
+++ b/legup-4.0/llvm/lib/Target/Verilog/LegupTcl.h
@@ -11,6 +11,8 @@
 #ifndef LEGUP_TCL_H
 #define LEGUP_TCL_H
 
+#define USE_INTERP_RESULT
+#define USE_INTERP_ERRORLINE
 #include <tcl.h>
 
 namespace legup {
diff --git a/legup-4.0/llvm/lib/Target/Verilog/uint128_t.h b/legup-4.0/llvm/lib/Target/Verilog/uint128_t.h
index 69e0f910..dea1cc01 100644
--- a/legup-4.0/llvm/lib/Target/Verilog/uint128_t.h
+++ b/legup-4.0/llvm/lib/Target/Verilog/uint128_t.h
@@ -528,9 +528,11 @@ template <typename T> bool operator<=(T lhs, uint128_t rhs){
 }
 
 // Arithmetic Operators
+#if 0
 template <typename T> T operator+(T lhs, uint128_t rhs){
     return (T) (rhs + lhs);
 }
+#endif
 
 template <typename T> T & operator+=(T & lhs, uint128_t rhs){
     lhs = (T) (rhs + lhs);
diff --git a/legup-4.0/llvm/lib/Target/Verilog/utils.cpp b/legup-4.0/llvm/lib/Target/Verilog/utils.cpp
index bf481d7b..d8dc4d22 100644
--- a/legup-4.0/llvm/lib/Target/Verilog/utils.cpp
+++ b/legup-4.0/llvm/lib/Target/Verilog/utils.cpp
@@ -203,7 +203,8 @@ bool strIsInt(std::string str) {
 
     int out;
     std::stringstream convert(str);
-    return convert >> out;
+    convert >> out;
+    return !convert.fail();
     
 }
 
@@ -212,7 +213,8 @@ int strToInt(std::string str) {
 
   int out;
   std::stringstream convert(str);
-  assert(convert >> out);
+  convert >> out;
+  assert(!convert.fail());
   return out;
   
 }
Clone this wiki locally