Blame otp-0011-Add-fno-common-gcc-option.patch

5ded90
From: Sverker Eriksson <sverker@erlang.org>
5ded90
Date: Fri, 17 Jan 2020 17:21:32 +0100
5ded90
Subject: [PATCH] Add -fno-common gcc option
5ded90
5ded90
5ded90
diff --git a/erts/aclocal.m4 b/erts/aclocal.m4
5ded90
index 5fefd72d5d..5d274e69c3 100644
5ded90
--- a/erts/aclocal.m4
5ded90
+++ b/erts/aclocal.m4
5ded90
@@ -2935,6 +2935,12 @@ fi
5ded90
 # DED_EMU_THR_DEFS=$EMU_THR_DEFS
5ded90
 DED_CFLAGS="$CFLAGS $CPPFLAGS $DED_CFLAGS"
5ded90
 if test "x$GCC" = xyes; then
5ded90
+    # Use -fno-common for gcc, that is link error if multiple definitions of
5ded90
+    # global variables are encountered. This is ISO C compliant.
5ded90
+    # Until version 10, gcc has had -fcommon as default, which allows and merges
5ded90
+    # such dubious duplicates.
5ded90
+    LM_TRY_ENABLE_CFLAG([-fno-common], [DED_CFLAGS])
5ded90
+
5ded90
     DED_STATIC_CFLAGS="$DED_CFLAGS"
5ded90
     DED_CFLAGS="$DED_CFLAGS -fPIC"
5ded90
 fi
5ded90
diff --git a/erts/configure.in b/erts/configure.in
5ded90
index a887f86621..0a466ad5cc 100644
5ded90
--- a/erts/configure.in
5ded90
+++ b/erts/configure.in
5ded90
@@ -566,6 +566,12 @@ if test "x$GCC" = xyes; then
5ded90
     WFLAGS="$WFLAGS -Wdeclaration-after-statement"
5ded90
   fi
5ded90
   CFLAGS=$saved_CFLAGS
5ded90
+
5ded90
+  # Use -fno-common for gcc, that is link error if multiple definitions of
5ded90
+  # global variables are encountered. This is ISO C compliant.
5ded90
+  # Until version 10, gcc has had -fcommon as default, which allows and merges
5ded90
+  # such dubious duplicates.
5ded90
+  LM_TRY_ENABLE_CFLAG([-fno-common], [CFLAGS])
5ded90
 else
5ded90
   WFLAGS=""
5ded90
   WERRORFLAGS=""
5ded90
diff --git a/lib/erl_interface/configure.in b/lib/erl_interface/configure.in
5ded90
index f0e9b2eb3f..230dba25d6 100644
5ded90
--- a/lib/erl_interface/configure.in
5ded90
+++ b/lib/erl_interface/configure.in
5ded90
@@ -315,6 +315,12 @@ if test "x$GCC" = xyes; then
5ded90
         WFLAGS="$WFLAGS -fno-strict-aliasing";;
5ded90
   esac
5ded90
   CFLAGS="$WERRORFLAGS $CFLAGS"
5ded90
+
5ded90
+  # Use -fno-common for gcc, that is link error if multiple definitions of
5ded90
+  # global variables are encountered. This is ISO C compliant.
5ded90
+  # Until version 10, gcc has had -fcommon as default, which allows and merges
5ded90
+  # such dubious duplicates.
5ded90
+  LM_TRY_ENABLE_CFLAG([-fno-common], [CFLAGS])
5ded90
 else
5ded90
   WFLAGS=""
5ded90
   WERRORFLAGS=""