Fix #735 (#736)
authorMarco Leogrande <dark.knight.ita@gmail.com>
Thu, 6 Oct 2016 19:28:40 +0000 (12:28 -0700)
committer4ast <alexei.starovoitov@gmail.com>
Thu, 6 Oct 2016 19:28:40 +0000 (12:28 -0700)
GCC 6 behaves slightly differently when using -isystem, and our use of
that parameter is causing a build failure. Avoid using -isystem on
gcc6+ for now, until that compiler becomes a bit more mainstream and
we can debug further.

Failure had been introuced in d19e0cb.

Signed-off-by: Marco Leogrande <marcol@plumgrid.com>
CMakeLists.txt

index ff3a9cd..6cd05f2 100644 (file)
@@ -66,11 +66,19 @@ if(NOT DEFINED BCC_KERNEL_MODULES_SUFFIX)
 endif()
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
-# iterate over all available directories in LLVM_INCLUDE_DIRS to
-# generate a correctly tokenized list of parameters
-foreach(ONE_LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIRS})
-  set(CXX_ISYSTEM_DIRS "${CXX_ISYSTEM_DIRS} -isystem ${ONE_LLVM_INCLUDE_DIR}")
-endforeach()
+
+# As reported in issue #735, GCC 6 has some behavioral problems when
+# dealing with -isystem. Hence, skip the warning optimization
+# altogether on that compiler.
+execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
+if (GCC_VERSION VERSION_LESS 6.0)
+  # iterate over all available directories in LLVM_INCLUDE_DIRS to
+  # generate a correctly tokenized list of parameters
+  foreach(ONE_LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIRS})
+    set(CXX_ISYSTEM_DIRS "${CXX_ISYSTEM_DIRS} -isystem ${ONE_LLVM_INCLUDE_DIR}")
+  endforeach()
+endif()
+
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall ${CXX_ISYSTEM_DIRS}")
 endif()