git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC v1 1/1] intialize false_but_the_compiler_does_not_know_it_

From
Junio C Hamano <gitster@pobox.com>
Date
May 7, 2025, 16:27 UTC
Message-ID
<xmqqikmce67y.fsf@gitster.g>
In-Reply-To
<CAOTNsDy4YcOP9H_xmUDKRdGuEu0GABDj8sM0Jt+oPEo7JVSQ9A@mail.gmail.com>
Koji Nakamaru <koji.nakamaru@gree.net> writes:
Show 14 quoted lines
> On Wed, May 7, 2025 at 2:16 AM Junio C Hamano <gitster@pobox.com> wrote:
>> 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.
>
> I tested further with Xcode 14.3.1 (the last version of 14.x) and 15,
> where the former still had the issue and the latter worked without the
> workaround. Xcode 15 introduces a new linker which seems to fix the bug.
>
> cf. https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Build-System
>
> Koji Nakamaru
Wonderful.  Thanks for a quick report.
Here is an updated patch with the above information.
Thanks.
--- >8 ---
From: Torsten Bögershausen <tboegi@web.de>
Date:   Tue May 6 14:06:44 2025 +0200
intialize false_but_the_compiler_does_not_know_it_

Compiling/linking 82e79c63642c on an older MacOs machine (like Xcode 14.3.1, the last version of 14.x series) 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 fails to pick up compiler-tricks/not-constant.o that defines the needed false_but_the_compiler_does_not_know_it_ symbol, which is the only thing defined in that object file, from the libgit.a archive.

Initializing the variable explicitly to 0 works around the linker bug; the symbol type changes from 'C' to 'S' and is picked up by the linker.

Xcode 15 introduces a new linker, which seems to fix the bug, making the workaround here unnecessary, and Apple requires [*] to build with Xcode 16 or later in order to upload to their App Store Connect since April 24, 2025, but not everybody is expected to upgrade their toolchain immediately.

 [*] https://developer.apple.com/news/upcoming-requirements/?id=02212025a
Helped-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
[jc: update version info with Koji's help]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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;
Previous: Koji Nakamaru
Message 7 of 7 in “Problems with 82e79c63642c, NOT_CONSTANT with sigfillset()”
  1. Torsten BögershausenMay 4, 2025
  2. Junio C HamanoMay 5, 2025
  3. Koji NakamaruMay 6, 2025
  4. 1/1 intialize false_but_the_compiler_does_not_know_it_tboegi@web.de, May 6, 2025
  5. Junio C HamanoMay 6, 2025
  6. Koji NakamaruMay 7, 2025
  7. Junio C HamanoMay 7, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.