Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-10-15 22:30:29 +0300
committerJunio C Hamano <gitster@pobox.com>2020-10-16 18:41:40 +0300
commit55391836224af8a65f3802f4a4c87ece0f2c19a4 (patch)
treea41a9695a0a402959c0133fdcd0d8f43de705561 /config.mak.dev
parent47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc (diff)
config.mak.dev: build with -fno-common
It's an easy mistake to define a variable in a header with "int x;" when you really meant to only declare the variable as "extern int x;" instead. Clang and gcc will both allow this when building with "-fcommon"; they put these "tentative definitions" in a common block which the linker is able to resolve. This is the default in clang and was the default in gcc until gcc-10, since it helps some legacy code. However, we would prefer not to rely on this because: - using "extern" makes the intent more clear (so it's a style issue, but it's one the compiler can help us catch) - according to the gcc manpage, it may yield a speed and code size penalty So let's build explicitly with -fno-common when the DEVELOPER knob is set, which will let developers using clang and older versions of gcc notice these problems. I didn't bother making this conditional on a particular version of gcc. As far as I know, this option has been available forever in both gcc and clang, so old versions don't need to avoid it. And we already expect gcc and clang options throughout config.mak.dev, so it's unlikely anybody setting the DEVELOPER knob is using anything else. It's a noop on gcc-10, of course, but it's not worth trying to exclude it there. Note that there's nothing to fix in the code; we already don't have any issues here. But if you want to test the patch, you can add a bare "int x;" into cache.h, which will cause the link step to fail. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.mak.dev')
-rw-r--r--config.mak.dev1
1 files changed, 1 insertions, 0 deletions
diff --git a/config.mak.dev b/config.mak.dev
index cd4a82a9eb..20168e5691 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -15,6 +15,7 @@ DEVELOPER_CFLAGS += -Wpointer-arith
DEVELOPER_CFLAGS += -Wstrict-prototypes
DEVELOPER_CFLAGS += -Wunused
DEVELOPER_CFLAGS += -Wvla
+DEVELOPER_CFLAGS += -fno-common
DEVELOPER_CFLAGS += -DENABLE_SHA256