alibaba / xoc

XOC is a compiler infrastructure that provides multi-level operations, flexibility, and the capability of representing almost all popular languages. There are two level IR representations used throughout all phases of the compilation.
110 stars 52 forks source link

Fixes to build #9

Open mingodad opened 2 years ago

mingodad commented 2 years ago

I just cloned this project (actually https://github.com/stevenknown/xoc but it has not enabled issues there) and tried to build but got some warnings and an error related to try use of HeapSort::HeapValVector<T> hdata(data); with clang++ (6 and 11) and g++9.

Here is the output of git diff -u of my changes to be able to build it:

diff --git a/com/flty.cpp b/com/flty.cpp
index 0a44cbf..5f02c1b 100644
--- a/com/flty.cpp
+++ b/com/flty.cpp
@@ -129,7 +129,7 @@ void Float::dump() const
 {
     StrBuf buf(16);
     format(buf);
-    fprintf(stdout, buf.buf);
+    fprintf(stdout, "%s", buf.buf);
 }

 } //namespace xcom
diff --git a/com/rational.cpp b/com/rational.cpp
index 4464267..8b8911f 100644
--- a/com/rational.cpp
+++ b/com/rational.cpp
@@ -139,7 +139,7 @@ void Rational::dump() const
 {
     StrBuf buf(16);
     format(buf);
-    fprintf(stdout, buf.buf);
+    fprintf(stdout, "%s", buf.buf);
 }

diff --git a/com/sort.cpp b/com/sort.cpp
index 8c2acc7..b37a75c 100644
--- a/com/sort.cpp
+++ b/com/sort.cpp
@@ -54,7 +54,7 @@ public:
     DumpHeap(Vector<T> & data)
     {
         if (data.get_last_idx() < 0) { return; }
-        HeapSort::HeapValVector<T> hdata(data);
+        HeapSort<int>::HeapValVector<T> hdata(data);
         m_pool = smpoolCreate(64, MEM_COMM);
         UINT node_count = 1;
         for (UINT i = hdata.get_begin_idx(); i <= hdata.get_end_idx(); i++) {
diff --git a/com/sort.h b/com/sort.h
index a2ea8cd..3659dda 100644
--- a/com/sort.h
+++ b/com/sort.h
@@ -120,7 +120,7 @@ void Bucket<T>::dump()
     INT j = 0;
     printf("\nBUCKET");
     for (UINT i = 0; i < Hash<T>::m_bucket_size; i++) {
-        printf("\n\tB%d:", i);
+        printf("\n\tB%ud:", i);
         HC<T> * elemhc = (HC<T>*)HB_member(Hash<T>::m_bucket[i]);
         while (elemhc != nullptr) {
             printf("%f,", HC_val(elemhc));
diff --git a/dex/dex_const_info.h b/dex/dex_const_info.h
index d006707..91351f1 100644
--- a/dex/dex_const_info.h
+++ b/dex/dex_const_info.h
@@ -110,7 +110,13 @@ author: Su Zhenyu
 #define HAS_PREDICATE_REGISTER false

 //Define the max/min integer value range of target machine.
+#ifdef MIN_HOST_INT_VALUE
+#undef MIN_HOST_INT_VALUE
+#endif
 #define MIN_HOST_INT_VALUE 0x80000000
+#ifdef MAX_HOST_INT_VALUE
+#undef MAX_HOST_INT_VALUE
+#endif
 #define MAX_HOST_INT_VALUE 0x7fffFFFF
 #define EPSILON 0.000001
stevenknown commented 2 years ago

It looks good to me. clang may apply more C++ type check than gcc and VisualStudio, I will apply your patch into code.