From: Szabolcs Nagy <nsz@port70.net>
To: Rui Ueyama <rui314@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] Explicitly pass the -fno-common flag
Date: Sun, 9 Jan 2022 00:25:36 +0100 [thread overview]
Message-ID: <20220108232536.GC1320090@port70.net> (raw)
In-Reply-To: <CACKH++a5HJtKmXzYwoZk36m4ykAq_QSOby+ytK=2HKjqxgX3EQ@mail.gmail.com>
* Rui Ueyama <rui314@gmail.com> [2022-01-08 16:45:51 +0900]:
> 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.
building x86_64 musl with -fcommon i see these symbols in COM section:
obj/src/malloc/replaced.lo:
__aligned_alloc_replaced
__malloc_replaced
obj/src/malloc/mallocng/malloc.lo:
__malloc_lock
obj/src/misc/getopt.lo:
__optpos
optarg
optopt
obj/src/env/__stack_chk_fail.lo:
__stack_chk_guard
obj/src/env/__init_tls.lo:
__thread_list_lock
obj/src/aio/aio.lo:
__aio_fut
obj/src/locale/locale_map.lo:
__locale_lock
obj/src/internal/libc.lo:
__hwcap
__libc
obj/src/internal/defsysinfo.lo:
__sysinfo
obj/src/signal/sigaction.lo:
__eintr_valid_flag
obj/src/exit/abort_lock.lo:
__abort_lock
obj/src/network/h_errno.lo:
h_errno
obj/src/time/getdate.lo:
getdate_err
i'm not sure how this can cause trouble (maybe static linking?), but
if we care then another solution is to change
int x;
to
int x = 0;
instead of forcing -fno-common.
next prev parent reply other threads:[~2022-01-08 23:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-08 7:45 Rui Ueyama
2022-01-08 23:25 ` Szabolcs Nagy [this message]
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220108232536.GC1320090@port70.net \
--to=nsz@port70.net \
--cc=musl@lists.openwall.com \
--cc=rui314@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).