mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rui Ueyama <>
Subject: [musl] [PATCH] Explicitly pass the -fno-common flag
Date: Sat, 8 Jan 2022 16:45:51 +0900	[thread overview]
Message-ID: <> (raw)

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
and Clang (
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.

             reply	other threads:[~2022-01-08 13:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08  7:45 Rui Ueyama [this message]
2022-01-08 23:25 ` Szabolcs Nagy
2022-01-09  1:49   ` Rich Felker
2022-01-10 16:50     ` Markus Wichmann
2022-01-10 18:45       ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \
    --subject='Re: [musl] [PATCH] Explicitly pass the -fno-common flag' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).