git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Koji Nakamaru <koji.nakamaru@gree.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Torsten Bögershausen" <tboegi@web.de>, git@vger.kernel.org
Subject: Re: Problems with 82e79c63642c, NOT_CONSTANT with sigfillset()
Date: Tue, 6 May 2025 15:14:30 +0900	[thread overview]
Message-ID: <CAOTNsDw=0+2pLfPTaGdfwpMrnFDJ9nTBiwRO6w=fZ=Am5thXXA@mail.gmail.com> (raw)
In-Reply-To: <xmqqjz6uokdx.fsf@gitster.g>

On Tue, May 6, 2025 at 5:47 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Torsten Bögershausen <tboegi@web.de> writes:
>
> > There is a problem with the somewhat new
> > commit 82e79c63642c introducing NOT_CONSTANT with sigfillset():
> >
> > Compiling on 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)
> >
> > What is the best thing to avoid this ?
> >
> > The introduced "false_but_the_compiler_does_not_know_it" triggers here
> > because there is a proper prototype in signal.h and then a
> > #define sigfillset() ...
> > further down in the file, which can never fail.
> >
> > a) Define a sigfillset_or_die_if_needed macro,
> >   which does what we have today, and is simply defined
> >   as sigfillset() without any error checking for MacOs(some version)
> > b) Revert the commit (and fix the conflicts)
> > c) Anything better ?
> >
> > I have a raw patch for b), not fully cooked, as the commit message
> > is the hardest part. Before sending that out:
> > Are the thoughts about a better solution ?
>
> How about figuring out why it does not work on your system?
>
> Namely, compiling compiler-tricks/not-constant.c should yield
> compiler-tricks/not-constant.o and that should be "ar"ed into
> libgit.a, just like config.o, connect.o, etc., so I cannot see how
> your ld fails to find false_but_the_compiler_does_not_know_it when
> it has no problem with say git_config or other global symbols.
>

I reproduced the issue with Xcode 14.2 on macOS Monterey. It seems to
be caused by the ld command's bug and can be avoided by tweaking
Makefile:

diff --git a/Makefile b/Makefile
index 8a7f1c7654..8a06db8400 100644
--- a/Makefile
+++ b/Makefile
@@ -1387,7 +1387,7 @@ UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o

 # xdiff and reftable libs may in turn depend on what is in libgit.a
-GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
+GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB)
$(LIB_FILE) compiler-tricks/not-constant.o
 EXTLIBS =

 GIT_USER_AGENT = git/$(GIT_VERSION)

or by explicitly initializing false_but_the_compiler_does_not_know_it_
(which changes the symbol type from 'C' to 'S'):

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;

Koji Nakamaru

  reply	other threads:[~2025-05-06  6:14 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 [this message]
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
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='CAOTNsDw=0+2pLfPTaGdfwpMrnFDJ9nTBiwRO6w=fZ=Am5thXXA@mail.gmail.com' \
    --to=koji.nakamaru@gree.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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).