From 3f7af85cf56e46f2b24dc0aaa5af07ca9ea62289 Mon Sep 17 00:00:00 2001
From: Nick Zavaritsky <mejedi@gmail.com>
Date: Tue, 13 Oct 2015 13:59:12 +0300
Subject: [PATCH] Document reasons for using -fno-common compiler flag

---
 cmake/compiler.cmake | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index ff829954d1..32986c65c6 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -107,6 +107,23 @@ unset(CC_DEBUG_OPT)
 # internally, we also need to make sure all code is compiled
 # with unwind info.
 #
+# In C a global variable without a storage specifier (static/extern) and
+# without an initialiser is called a ’tentative definition’. The
+# language permits multiple tentative definitions in the single
+# translation unit; i.e. int foo; int foo; is perfectly ok. GNU
+# toolchain goes even further, allowing multiple tentative definitions
+# in *different* translation units. Internally, variables introduced via
+# tentative definitions are implemented as ‘common’ symbols. Linker
+# permits multiple definitions if they are common symbols, and it picks
+# one arbitrarily for inclusion in the binary being linked.
+#
+# -fno-common forces GNU toolchain to behave in a more
+# standard-conformant way in respect to tentative definitions and it
+# prevents common symbols generation. Since we are a cross-platform
+# project it really makes sense. There are toolchains that don’t
+# implement GNU style handling of the tentative definitions and there
+# are platforms lacking proper support for common symbols (osx).
+#
 
 add_compile_flags("C;CXX"
     "-fno-common"
-- 
GitLab