From e3559f0df98183a78cf670168150faa71467bd23 Mon Sep 17 00:00:00 2001
From: tangxifan <tangxifan@gmail.com>
Date: Mon, 14 Sep 2020 16:53:16 -0600
Subject: [PATCH 1/7] [Regression Test] Add compiler coverage test to CI

---
 .travis.yml       | 61 ++++++++++++++++++++++++++++++++++++++++++++---
 .travis/common.sh |  4 ++--
 2 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index bf9c42724c..55bcf62547 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,7 +15,7 @@ cache:
 
 # Supported Operating systems
 dist: bionic
-compiler: g++-8
+#compiler: g++-8
 addons:
   apt:
     sources:
@@ -33,8 +33,6 @@ addons:
     - doxygen
     - flex
     - fontconfig
-    - g++-8
-    - gcc-8
     - gdb
     - git
     - gperf
@@ -56,6 +54,17 @@ addons:
     - zip
     - qt5-default
     - clang-format-7
+# Add all the supported compilers
+    - g++-6
+    - gcc-6
+    - g++-7
+    - gcc-7
+    - g++-8
+    - gcc-8
+    - g++-9
+    - gcc-9
+    - clang-6.0
+    - clang-8
 #- os: osx
 #  osx_image: xcode10.2 # we target latest MacOS Mojave
 #  sudo: true
@@ -76,6 +85,10 @@ addons:
 #      - libxml++
 #      - qt5
 
+# Use gcc-8 as default compiler
+env:
+  - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
+
 before_script:
   - source .travis/common.sh
   - source .travis/install.sh
@@ -116,6 +129,48 @@ jobs:
         - source .travis/build.sh
         - source .travis/fpga_spice_reg_test.sh
 
+    - stage: Test
+      name: "Build Compatibility: GCC-6 (Ubuntu Bionic 18.04)"
+      env:
+        - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
+      script:
+        - source .travis/build.sh
+
+    - stage: Test
+      name: "Build Compatibility: GCC-7 (Ubuntu Bionic 18.04)"
+      env:
+        - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
+      script:
+        - source .travis/build.sh
+
+    - stage: Test
+      name: "Build Compatibility: GCC-8 (Ubuntu Bionic 18.04)"
+      env:
+        - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
+      script:
+        - source .travis/build.sh
+
+    - stage: Test
+      name: "Build Compatibility: GCC-9 (Ubuntu Bionic 18.04)"
+      env:
+        - MATRIX_EVAL="CC=gcc-9 && CXX=g++-9"
+      script:
+        - source .travis/build.sh
+
+    - stage: Test
+      name: "Build Compatibility: Clang-6 (Ubuntu Bionic 18.04)"
+      env:
+        - MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
+      script:
+        - source .travis/build.sh
+
+    - stage: Test
+      name: "Build Compatibility: Clang-8 (Ubuntu Bionic 18.04)"
+      env:
+        - MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
+      script:
+        - source .travis/build.sh
+
 #after_failure:
 #  - .travis/after_failure.sh
 
diff --git a/.travis/common.sh b/.travis/common.sh
index a293cb00fc..880d64ae8a 100644
--- a/.travis/common.sh
+++ b/.travis/common.sh
@@ -39,8 +39,8 @@ if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
   sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / -allowUntrusted
 else
   # For linux, we use g++-8 and gcc-8 as default compilers
-  export CC=gcc-8
-  export CXX=g++-8
+  #export CC=gcc-8
+  #export CXX=g++-8
 fi
 
 

From c08d4f5cd9c00110f9702948b7cd364fed3c5378 Mon Sep 17 00:00:00 2001
From: tangxifan <tangxifan@gmail.com>
Date: Mon, 14 Sep 2020 16:59:08 -0600
Subject: [PATCH 2/7] [Regression Test] Patch travis script

---
 .travis/common.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis/common.sh b/.travis/common.sh
index 880d64ae8a..bee008a88e 100644
--- a/.travis/common.sh
+++ b/.travis/common.sh
@@ -37,7 +37,7 @@ if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
   # export PATH="/usr/local/opt/qt/bin:$PATH"
   # Install header files in Mojave, if not gcc-4.9 cannot spot stdio.h
   sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / -allowUntrusted
-else
+#else
   # For linux, we use g++-8 and gcc-8 as default compilers
   #export CC=gcc-8
   #export CXX=g++-8

From d4bac95cd4d354839f8381f8ff166a411b47cb69 Mon Sep 17 00:00:00 2001
From: tangxifan <tangxifan@gmail.com>
Date: Mon, 14 Sep 2020 17:07:14 -0600
Subject: [PATCH 3/7] [Regression Tests] Enable matrix eval parameter in
 setting up compilers

---
 .travis/common.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.travis/common.sh b/.travis/common.sh
index bee008a88e..a5a7274de3 100644
--- a/.travis/common.sh
+++ b/.travis/common.sh
@@ -37,10 +37,11 @@ if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
   # export PATH="/usr/local/opt/qt/bin:$PATH"
   # Install header files in Mojave, if not gcc-4.9 cannot spot stdio.h
   sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / -allowUntrusted
-#else
+else
   # For linux, we use g++-8 and gcc-8 as default compilers
-  #export CC=gcc-8
-  #export CXX=g++-8
+  eval "${MATRIX_EVAL}"
+  export "CC=$CC"
+  export "CXX=$CXX"
 fi
 
 

From fc6bfdc7a22cf2be757911d976b01da408257991 Mon Sep 17 00:00:00 2001
From: tangxifan <tangxifan@gmail.com>
Date: Mon, 14 Sep 2020 18:55:21 -0600
Subject: [PATCH 4/7] [OpenFPGA Code] Patch syntax compatibility for older gcc

---
 libopenfpga/libopenfpgautil/src/openfpga_decode.h  | 1 +
 libopenfpga/libopenfpgautil/src/openfpga_scale.cpp | 6 +++---
 openfpga/src/base/io_location_map.h                | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libopenfpga/libopenfpgautil/src/openfpga_decode.h b/libopenfpga/libopenfpgautil/src/openfpga_decode.h
index ab6778c869..85809fee2e 100644
--- a/libopenfpga/libopenfpgautil/src/openfpga_decode.h
+++ b/libopenfpga/libopenfpgautil/src/openfpga_decode.h
@@ -4,6 +4,7 @@
 /********************************************************************
  * Include header files that are required by function declaration
  *******************************************************************/
+#include <stddef.h>
 #include <vector>
 
 /********************************************************************
diff --git a/libopenfpga/libopenfpgautil/src/openfpga_scale.cpp b/libopenfpga/libopenfpgautil/src/openfpga_scale.cpp
index 9baa753d1d..66364501dd 100644
--- a/libopenfpga/libopenfpgautil/src/openfpga_scale.cpp
+++ b/libopenfpga/libopenfpgautil/src/openfpga_scale.cpp
@@ -140,7 +140,7 @@ float string_to_unit(const std::string& scale) {
   /* Invalid unit report error */
   VTR_LOGF_ERROR(__FILE__, __LINE__,
                  "Invalid unit %s!\nAcceptable units are [a|f|p|n|u|k|M|B|T] or empty\n",
-                 scale); 
+                 scale.c_str()); 
   exit(1);
 }
 
@@ -153,13 +153,13 @@ float string_to_time_unit(const std::string& scale) {
     && (2 != scale.length()) ) {
     VTR_LOGF_ERROR(__FILE__, __LINE__,
                    "Time unit (='%s') must contain only one or two characters!\n",
-                   scale);
+                   scale.c_str());
   } 
   /* The last character must be 's' */
   if ('s' != scale.back()) {
     VTR_LOGF_ERROR(__FILE__, __LINE__,
                    "Time unit (='%s') must end with 's'!\n",
-                   scale);
+                   scale.c_str());
   }
 
   float unit = 1.;
diff --git a/openfpga/src/base/io_location_map.h b/openfpga/src/base/io_location_map.h
index de6422d230..ef326a66a7 100644
--- a/openfpga/src/base/io_location_map.h
+++ b/openfpga/src/base/io_location_map.h
@@ -4,6 +4,7 @@
 /********************************************************************
  * Include header files required by the data structure definition
  *******************************************************************/
+#include <stddef.h>
 #include <vector>
 
 /* Begin namespace openfpga */

From c23742c7517e70cc39f5f5d0ec35ac39e9e38fb0 Mon Sep 17 00:00:00 2001
From: tangxifan <tangxifan@gmail.com>
Date: Mon, 14 Sep 2020 20:13:27 -0600
Subject: [PATCH 5/7] [OpenFPGA code] fix bug for clang compatibility

---
 libopenfpga/libopenfpgashell/src/command_parser.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libopenfpga/libopenfpgashell/src/command_parser.cpp b/libopenfpga/libopenfpgashell/src/command_parser.cpp
index 5e0397421f..b2daf12f72 100644
--- a/libopenfpga/libopenfpgashell/src/command_parser.cpp
+++ b/libopenfpga/libopenfpgashell/src/command_parser.cpp
@@ -67,7 +67,7 @@ bool parse_command(const std::vector<std::string>& argv,
   /* Validate that the command name matches argv[0] */
   if (argv[0] != cmd.name()) { 
     VTR_LOG("Unexpected command name '%s'!\n",
-            argv[0]);
+            argv[0].c_str());
     return false;
   }
 

From b43cd2741df94a9a164a0d68dbf3eb4d2dfc01c0 Mon Sep 17 00:00:00 2001
From: tangxifan <tangxifan@gmail.com>
Date: Mon, 14 Sep 2020 20:14:16 -0600
Subject: [PATCH 6/7] [Regression Tests] Add gcc-5 compatibility test to Travis
 CI

---
 .travis.yml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 55bcf62547..c4349f39cb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -55,6 +55,8 @@ addons:
     - qt5-default
     - clang-format-7
 # Add all the supported compilers
+    - g++-5
+    - gcc-5
     - g++-6
     - gcc-6
     - g++-7
@@ -129,6 +131,13 @@ jobs:
         - source .travis/build.sh
         - source .travis/fpga_spice_reg_test.sh
 
+    - stage: Test
+      name: "Build Compatibility: GCC-5 (Ubuntu Bionic 18.04)"
+      env:
+        - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
+      script:
+        - source .travis/build.sh
+
     - stage: Test
       name: "Build Compatibility: GCC-6 (Ubuntu Bionic 18.04)"
       env:

From 8b6c8f73e9a1a7a54f7019e2ef1c8d0da0dba792 Mon Sep 17 00:00:00 2001
From: tangxifan <tangxifan@gmail.com>
Date: Mon, 14 Sep 2020 21:26:53 -0600
Subject: [PATCH 7/7] [OpenFPGA code] fix bug for clang compatibility

---
 libopenfpga/libarchopenfpga/src/read_xml_circuit_library.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libopenfpga/libarchopenfpga/src/read_xml_circuit_library.cpp b/libopenfpga/libarchopenfpga/src/read_xml_circuit_library.cpp
index 9fb61a6544..0954a0086f 100644
--- a/libopenfpga/libarchopenfpga/src/read_xml_circuit_library.cpp
+++ b/libopenfpga/libarchopenfpga/src/read_xml_circuit_library.cpp
@@ -459,7 +459,7 @@ void read_xml_output_mask(pugi::xml_node& xml_port,
     if (circuit_lib.port_size(port) != mask_vector.size()) {
       archfpga_throw(loc_data.filename_c_str(), loc_data.line(xml_port),
                      "Invalid lut_output_mask attribute '%s'! It must match the port size (=%lu)\n",
-                     output_mask_attr, circuit_lib.port_size(port));
+                     output_mask_attr.c_str(), circuit_lib.port_size(port));
     } 
   } else {
     /* By default, we give a mask vector covering each pin of the port */