Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sat, 8 Jan 2022 16:45:51 +0900
From: Rui Ueyama <rui314@...il.com>
To: musl@...ts.openwall.com
Subject: [PATCH] Explicitly pass the -fno-common flag

Common symbol is a special type of symbol that allows a linker to merge
multiple common symbols into one and turn it into a defined symbol.
This feature was used in C to allow tentative definitions. That is,
you can write `int foo;` instead of `extern int foo;` in a header file.

Common symbols are discouraged these days because they can easily
hide unintentional duplicate symbol errors. For that reason, GCC
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678)
and Clang (https://github.com/llvm/llvm-project/commit/0a9fc9233e172601e26381810d093e02ef410f65)
now default to `-fno-common`.

That means, musl libc's global variables are compiled to common symbols
or regular defined symbols depending on the compiler. That's not an issue
per se, but it's unnecessary churn.

This patch always passes the `-fno-common` flag to the compiler.
---
 configure | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/configure b/configure
index e1aefed7..73ec966d 100755
--- a/configure
+++ b/configure
@@ -492,6 +492,14 @@ tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables
 tryflag CFLAGS_AUTO -ffunction-sections
 tryflag CFLAGS_AUTO -fdata-sections

+#
+# The use of common symbol is discouraged recently because it can
+# easily hide unintentional duplicate symbol errors. Recent versions
+# of GCC and Clang default to -fno-common. To get a consistent output
+# with older versions of compilers, explicitly pass that flag.
+#
+tryflag CFLAGS_AUTO -fno-common
+
 #
 # On x86, make sure we don't have incompatible instruction set
 # extensions enabled by default. This is bad for making static binaries.
--
2.33.0.610.gcefe983a32

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.