Repository: kudu
Updated Branches:
  refs/heads/master ba3cdea53 -> 726dedacd

KUDU-2427: only add -fno-sized-deallocation for C++ files

Ubuntu 18.04 has a gcc that's new enough to support -fsized-deallocation.
But, if -fno-sized-deallocation is added to a C file's compilation flags,
the compiler will emit a warning:

  cc1: warning: command line option ‘-fno-sized-deallocation’ is valid for 
C++/ObjC++ but not for C

The problem is that we want to apply this flag only to "exported" targets,
but we have one such target (gutil_exported) that has both C and C++ files
in it. To address this, we can use a cmake generator expression[1] to
conditionally add the flag only to the C++ files in the target. This means
adding the flag with target_compile_options(), as set_target_properties()
does not support generator expressions.


Change-Id: Ib2fbd94f19495eb48119d8f9ecb6fdceee2387c3
Reviewed-by: Todd Lipcon <>
Tested-by: Adar Dembo <>


Branch: refs/heads/master
Commit: 726dedacd1203cbefa20f82c9eba529a28f44013
Parents: ba3cdea
Author: Adar Dembo <>
Authored: Fri May 11 12:41:29 2018 -0700
Committer: Adar Dembo <>
Committed: Thu May 17 18:07:07 2018 +0000

 CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 508aab9..782ecbc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -613,7 +613,9 @@ endif()
   # include sized deallocation (new in C++14). This reverses the setting from
   # non-exported (default) flags.
-    set(EXPORTED_FLAGS "${EXPORTED_FLAGS} -fno-sized-deallocation")
+    # Note: this is retained by the set_target_properties() call below.
+    target_compile_options(${EXPORTED_LIB_NAME}
+      PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-sized-deallocation>)

Reply via email to