]> git.ipfire.org Git - thirdparty/git.git/commitdiff
intialize false_but_the_compiler_does_not_know_it_
authorTorsten Bögershausen <tboegi@web.de>
Tue, 6 May 2025 12:06:44 +0000 (14:06 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 May 2025 16:11:47 +0000 (09:11 -0700)
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.

Helped-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compiler-tricks/not-constant.c

index 1da3ffc2f593d21079c9582fe903eb4cb8224f03..9fb4f275b1c4280fbd0bc90532da9d018c3c5c8a 100644 (file)
@@ -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;