git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: tboegi@web.de
Cc: git@vger.kernel.org,  koji.nakamaru@gree.net
Subject: Re: [PATCH/RFC v1 1/1] intialize false_but_the_compiler_does_not_know_it_
Date: Tue, 06 May 2025 10:16:52 -0700	[thread overview]
Message-ID: <xmqq5xidlkvv.fsf@gitster.g> (raw)
In-Reply-To: <20250506120644.186968-1-tboegi@web.de> (tboegi@web.de's message of "Tue, 6 May 2025 14:06:44 +0200")

tboegi@web.de writes:

> From: Torsten Bögershausen <tboegi@web.de>
>
> Compiling/linking 82e79c63642c on an older MacOs machine leads to this:
> Undefined symbols for architecture x86_64:
>   "_false_but_the_compiler_does_not_know_it_", referenced from:
>       _start_command in libgit.a(run-command.o)
>
> The linker doesn't seem to pick up the symbol:
> "false_but_the_compiler_does_not_know_it_"
>
> Initializing the variable to 0 fixes the problem:
> The symbol type changes from 'C' to 'S' and is picked up by the linker.
>
> Helped-by: Koji Nakamaru <koji.nakamaru@gree.net>
> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> ---
>  compiler-tricks/not-constant.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, both.

The alleged ld bug and this fix I can sort of believe.

The resulting object file from the original code would not have any
data, but just declares a BSS symbol in common, which may be
unusual, and this forces us to have an explicit initialization
data.

Just for reference (as the proposed log message refers to an "older
macOS"), do we know if the toolchain on a more recent release of
macOS work without this workaround already?  It may be nice to tell
users what version they need to avoid the same issue in their own
program.

Will queue.  Thanks.



> Koji Nakamaru: Thanks for the digging.
> This patch fixes the problem here -  as a side note,
> the change in Makefile alone doesn't help.
>
>
> diff --git a/compiler-tricks/not-constant.c b/compiler-tricks/not-constant.c
> index 1da3ffc2f5..9fb4f275b1 100644
> --- a/compiler-tricks/not-constant.c
> +++ b/compiler-tricks/not-constant.c
> @@ -1,2 +1,2 @@
>  #include <git-compat-util.h>
> -int false_but_the_compiler_does_not_know_it_;
> +int false_but_the_compiler_does_not_know_it_ = 0;

  reply	other threads:[~2025-05-06 17:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-04 19:04 Problems with 82e79c63642c, NOT_CONSTANT with sigfillset() Torsten Bögershausen
2025-05-05 20:47 ` Junio C Hamano
2025-05-06  6:14   ` Koji Nakamaru
2025-05-06 12:06 ` [PATCH/RFC v1 1/1] intialize false_but_the_compiler_does_not_know_it_ tboegi
2025-05-06 17:16   ` Junio C Hamano [this message]
2025-05-07  1:22     ` Koji Nakamaru
2025-05-07 16:27       ` Junio C Hamano

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=xmqq5xidlkvv.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=koji.nakamaru@gree.net \
    --cc=tboegi@web.de \
    /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.
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).