[PATCH] Fix c++ build with CLANG

Wald Commits scm-commit at wald.intevation.org
Fri Sep 26 18:44:46 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1411749881 -7200
# Node ID a548dd9a5dbe293ad3dc9a0e844070a62c99c2e8
# Parent  b18f08034c24fca38650feb39f2127dfe837388d
Fix c++ build with CLANG

    The c++ include directories were not picked up automatically
    and had to be added manually.

diff -r b18f08034c24 -r a548dd9a5dbe CMakeLists.txt
--- a/CMakeLists.txt	Fri Sep 26 18:01:35 2014 +0200
+++ b/CMakeLists.txt	Fri Sep 26 18:44:41 2014 +0200
@@ -24,6 +24,8 @@
 
 if (USE_CLANG)
    message (STATUS "Using clang options to build trustbridge.")
+   # This is a bit of a hack but necessary on Ubuntu 14.4
+   include_directories(/usr/include/c++/4.8 /usr/include/x86_64-linux-gnu/c++/4.8/)
 endif()
 
 include(CTest)
@@ -138,8 +140,10 @@
 endif()
 
 # No chance to compile nss with -Werror
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+if (NOT USE_CLANG)
+   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+endif()
 
 # Cmake does not correctly identify gcc windres when cross compiling
 # making this line neccessary to set the correct flags for it.
diff -r b18f08034c24 -r a548dd9a5dbe INSTALL
--- a/INSTALL	Fri Sep 26 18:01:35 2014 +0200
+++ b/INSTALL	Fri Sep 26 18:44:41 2014 +0200
@@ -109,14 +109,25 @@
 
 CLANG
 =====
-Alternatively you can build trustbridge with CLANG:
+Alternatively you can build trustbridge with CLANG. This is a bit of a hack
+and does not use all the hardening flags. Building with CLANG is _NOT_ recommended
+but it can be useful for analysis of the code.
+
+As root install the required packages an perform an evil hack that fixes the c++
+build with clang on ubuntu:
+
+    apt-get install clang llvm
+    ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 /usr/lib/x86_64-linux-gnu/libstdc++.so
+
+Now you can build trustbridge as user:
 
     mkdir build-clang
     cd build-clang
     CC=/usr/bin/clang \
     CXX=/usr/bin/clang++ \
     cmake .. -DCMAKE_PREFIX_PATH=$YOURPREFIX \
-    -DUSE_CLANG=TRUE
+    -DUSE_CLANG=TRUE \
+    -DCMAKE_VERBOSE_MAKEFILE=TRUE
 
 I386
 ====


More information about the Trustbridge-commits mailing list