{"thread":{"id":"63394","subject":"Problems with 82e79c63642c, NOT_CONSTANT with sigfillset()","startedAt":"2025-05-04T19:05:10Z","lastAt":"2025-05-07T16:27:48Z","messageCount":7,"participants":["Torsten Bögershausen","Junio C Hamano","Koji Nakamaru","tboegi@web.de"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"517196","messageId":"7efc9c9c-8187-4e10-bf9d-1cbb6aeac124@web.de","threadId":"63394","inReplyTo":null,"subject":"Problems with 82e79c63642c, NOT_CONSTANT with sigfillset()","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2025-05-04T19:04:57Z","receivedAt":"2025-05-04T19:05:10Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"There is a problem with the somewhat new\ncommit 82e79c63642c introducing NOT_CONSTANT with sigfillset():\n\nCompiling on older (?) MacOs machine leads to this:\n     Undefined symbols for architecture x86_64:\n       \"_false_but_the_compiler_does_not_know_it_\", referenced from:\n           _start_command in libgit.a(run-command.o)\n\nWhat is the best thing to avoid this ?\n\nThe introduced \"false_but_the_compiler_does_not_know_it\" triggers here\nbecause there is a proper prototype in signal.h and then a\n#define sigfillset() ...\nfurther down in the file, which can never fail.\n\na) Define a sigfillset_or_die_if_needed macro,\n   which does what we have today, and is simply defined\n   as sigfillset() without any error checking for MacOs(some version)\nb) Revert the commit (and fix the conflicts)\nc) Anything better ?\n\nI have a raw patch for b), not fully cooked, as the commit message\nis the hardest part. Before sending that out:\nAre the thoughts about a better solution ?\n\n\n\n\n"},{"id":"517276","messageId":"xmqqjz6uokdx.fsf@gitster.g","threadId":"63394","inReplyTo":"7efc9c9c-8187-4e10-bf9d-1cbb6aeac124@web.de","subject":"Re: Problems with 82e79c63642c, NOT_CONSTANT with sigfillset()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-05T20:47:06Z","receivedAt":"2025-05-05T20:47:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> There is a problem with the somewhat new\n> commit 82e79c63642c introducing NOT_CONSTANT with sigfillset():\n>\n> Compiling on older (?) MacOs machine leads to this:\n>     Undefined symbols for architecture x86_64:\n>       \"_false_but_the_compiler_does_not_know_it_\", referenced from:\n>           _start_command in libgit.a(run-command.o)\n>\n> What is the best thing to avoid this ?\n>\n> The introduced \"false_but_the_compiler_does_not_know_it\" triggers here\n> because there is a proper prototype in signal.h and then a\n> #define sigfillset() ...\n> further down in the file, which can never fail.\n>\n> a) Define a sigfillset_or_die_if_needed macro,\n>   which does what we have today, and is simply defined\n>   as sigfillset() without any error checking for MacOs(some version)\n> b) Revert the commit (and fix the conflicts)\n> c) Anything better ?\n>\n> I have a raw patch for b), not fully cooked, as the commit message\n> is the hardest part. Before sending that out:\n> Are the thoughts about a better solution ?\n\nHow about figuring out why it does not work on your system?  \n\nNamely, compiling compiler-tricks/not-constant.c should yield\ncompiler-tricks/not-constant.o and that should be \"ar\"ed into\nlibgit.a, just like config.o, connect.o, etc., so I cannot see how\nyour ld fails to find false_but_the_compiler_does_not_know_it when\nit has no problem with say git_config or other global symbols.\n\n\n"},{"id":"517292","messageId":"CAOTNsDw=0+2pLfPTaGdfwpMrnFDJ9nTBiwRO6w=fZ=Am5thXXA@mail.gmail.com","threadId":"63394","inReplyTo":"xmqqjz6uokdx.fsf@gitster.g","subject":"Re: Problems with 82e79c63642c, NOT_CONSTANT with sigfillset()","fromName":"Koji Nakamaru","fromEmail":"koji.nakamaru@gree.net","sentAt":"2025-05-06T06:14:30Z","receivedAt":"2025-05-06T06:14:43Z","isPatch":false,"sender":{"key":"koji.nakamaru@gree.net","avatar":"https://avatars.githubusercontent.com/u/2645978?v=4"},"body":"On Tue, May 6, 2025 at 5:47 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Torsten Bögershausen <tboegi@web.de> writes:\n>\n> > There is a problem with the somewhat new\n> > commit 82e79c63642c introducing NOT_CONSTANT with sigfillset():\n> >\n> > Compiling on older (?) MacOs machine leads to this:\n> >     Undefined symbols for architecture x86_64:\n> >       \"_false_but_the_compiler_does_not_know_it_\", referenced from:\n> >           _start_command in libgit.a(run-command.o)\n> >\n> > What is the best thing to avoid this ?\n> >\n> > The introduced \"false_but_the_compiler_does_not_know_it\" triggers here\n> > because there is a proper prototype in signal.h and then a\n> > #define sigfillset() ...\n> > further down in the file, which can never fail.\n> >\n> > a) Define a sigfillset_or_die_if_needed macro,\n> >   which does what we have today, and is simply defined\n> >   as sigfillset() without any error checking for MacOs(some version)\n> > b) Revert the commit (and fix the conflicts)\n> > c) Anything better ?\n> >\n> > I have a raw patch for b), not fully cooked, as the commit message\n> > is the hardest part. Before sending that out:\n> > Are the thoughts about a better solution ?\n>\n> How about figuring out why it does not work on your system?\n>\n> Namely, compiling compiler-tricks/not-constant.c should yield\n> compiler-tricks/not-constant.o and that should be \"ar\"ed into\n> libgit.a, just like config.o, connect.o, etc., so I cannot see how\n> your ld fails to find false_but_the_compiler_does_not_know_it when\n> it has no problem with say git_config or other global symbols.\n>\n\nI reproduced the issue with Xcode 14.2 on macOS Monterey. It seems to\nbe caused by the ld command's bug and can be avoided by tweaking\nMakefile:\n\ndiff --git a/Makefile b/Makefile\nindex 8a7f1c7654..8a06db8400 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1387,7 +1387,7 @@ UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o\n UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o\n\n # xdiff and reftable libs may in turn depend on what is in libgit.a\n-GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)\n+GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB)\n$(LIB_FILE) compiler-tricks/not-constant.o\n EXTLIBS =\n\n GIT_USER_AGENT = git/$(GIT_VERSION)\n\nor by explicitly initializing false_but_the_compiler_does_not_know_it_\n(which changes the symbol type from 'C' to 'S'):\n\ndiff --git a/compiler-tricks/not-constant.c b/compiler-tricks/not-constant.c\nindex 1da3ffc2f5..9fb4f275b1 100644\n--- a/compiler-tricks/not-constant.c\n+++ b/compiler-tricks/not-constant.c\n@@ -1,2 +1,2 @@\n #include <git-compat-util.h>\n-int false_but_the_compiler_does_not_know_it_;\n+int false_but_the_compiler_does_not_know_it_ = 0;\n\nKoji Nakamaru\n"},{"id":"517330","messageId":"20250506120644.186968-1-tboegi@web.de","threadId":"63394","inReplyTo":"7efc9c9c-8187-4e10-bf9d-1cbb6aeac124@web.de","subject":"[PATCH/RFC v1 1/1] intialize false_but_the_compiler_does_not_know_it_","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2025-05-06T12:06:44Z","receivedAt":"2025-05-06T12:12:02Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nCompiling/linking 82e79c63642c on an older MacOs machine leads to this:\nUndefined symbols for architecture x86_64:\n  \"_false_but_the_compiler_does_not_know_it_\", referenced from:\n      _start_command in libgit.a(run-command.o)\n\nThe linker doesn't seem to pick up the symbol:\n\"false_but_the_compiler_does_not_know_it_\"\n\nInitializing the variable to 0 fixes the problem:\nThe symbol type changes from 'C' to 'S' and is picked up by the linker.\n\nHelped-by: Koji Nakamaru <koji.nakamaru@gree.net>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n compiler-tricks/not-constant.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\nKoji Nakamaru: Thanks for the digging.\nThis patch fixes the problem here -  as a side note,\nthe change in Makefile alone doesn't help.\n\n\ndiff --git a/compiler-tricks/not-constant.c b/compiler-tricks/not-constant.c\nindex 1da3ffc2f5..9fb4f275b1 100644\n--- a/compiler-tricks/not-constant.c\n+++ b/compiler-tricks/not-constant.c\n@@ -1,2 +1,2 @@\n #include <git-compat-util.h>\n-int false_but_the_compiler_does_not_know_it_;\n+int false_but_the_compiler_does_not_know_it_ = 0;\n-- \n2.39.5\n\n"},{"id":"517366","messageId":"xmqq5xidlkvv.fsf@gitster.g","threadId":"63394","inReplyTo":"20250506120644.186968-1-tboegi@web.de","subject":"Re: [PATCH/RFC v1 1/1] intialize false_but_the_compiler_does_not_know_it_","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-06T17:16:52Z","receivedAt":"2025-05-06T17:16:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> From: Torsten Bögershausen <tboegi@web.de>\n>\n> Compiling/linking 82e79c63642c on an older MacOs machine leads to this:\n> Undefined symbols for architecture x86_64:\n>   \"_false_but_the_compiler_does_not_know_it_\", referenced from:\n>       _start_command in libgit.a(run-command.o)\n>\n> The linker doesn't seem to pick up the symbol:\n> \"false_but_the_compiler_does_not_know_it_\"\n>\n> Initializing the variable to 0 fixes the problem:\n> The symbol type changes from 'C' to 'S' and is picked up by the linker.\n>\n> Helped-by: Koji Nakamaru <koji.nakamaru@gree.net>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>  compiler-tricks/not-constant.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n\nThanks, both.\n\nThe alleged ld bug and this fix I can sort of believe.\n\nThe resulting object file from the original code would not have any\ndata, but just declares a BSS symbol in common, which may be\nunusual, and this forces us to have an explicit initialization\ndata.\n\nJust for reference (as the proposed log message refers to an \"older\nmacOS\"), do we know if the toolchain on a more recent release of\nmacOS work without this workaround already?  It may be nice to tell\nusers what version they need to avoid the same issue in their own\nprogram.\n\nWill queue.  Thanks.\n\n\n\n> Koji Nakamaru: Thanks for the digging.\n> This patch fixes the problem here -  as a side note,\n> the change in Makefile alone doesn't help.\n>\n>\n> diff --git a/compiler-tricks/not-constant.c b/compiler-tricks/not-constant.c\n> index 1da3ffc2f5..9fb4f275b1 100644\n> --- a/compiler-tricks/not-constant.c\n> +++ b/compiler-tricks/not-constant.c\n> @@ -1,2 +1,2 @@\n>  #include <git-compat-util.h>\n> -int false_but_the_compiler_does_not_know_it_;\n> +int false_but_the_compiler_does_not_know_it_ = 0;\n"},{"id":"517418","messageId":"CAOTNsDy4YcOP9H_xmUDKRdGuEu0GABDj8sM0Jt+oPEo7JVSQ9A@mail.gmail.com","threadId":"63394","inReplyTo":"xmqq5xidlkvv.fsf@gitster.g","subject":"Re: [PATCH/RFC v1 1/1] intialize false_but_the_compiler_does_not_know_it_","fromName":"Koji Nakamaru","fromEmail":"koji.nakamaru@gree.net","sentAt":"2025-05-07T01:22:51Z","receivedAt":"2025-05-07T01:23:03Z","isPatch":true,"sender":{"key":"koji.nakamaru@gree.net","avatar":"https://avatars.githubusercontent.com/u/2645978?v=4"},"body":"On Wed, May 7, 2025 at 2:16 AM Junio C Hamano <gitster@pobox.com> wrote:\n> Just for reference (as the proposed log message refers to an \"older\n> macOS\"), do we know if the toolchain on a more recent release of\n> macOS work without this workaround already?  It may be nice to tell\n> users what version they need to avoid the same issue in their own\n> program.\n\nI tested further with Xcode 14.3.1 (the last version of 14.x) and 15,\nwhere the former still had the issue and the latter worked without the\nworkaround. Xcode 15 introduces a new linker which seems to fix the bug.\n\ncf. https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Build-System\n\nKoji Nakamaru\n"},{"id":"517501","messageId":"xmqqikmce67y.fsf@gitster.g","threadId":"63394","inReplyTo":"CAOTNsDy4YcOP9H_xmUDKRdGuEu0GABDj8sM0Jt+oPEo7JVSQ9A@mail.gmail.com","subject":"Re: [PATCH/RFC v1 1/1] intialize false_but_the_compiler_does_not_know_it_","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-07T16:27:45Z","receivedAt":"2025-05-07T16:27:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Koji Nakamaru <koji.nakamaru@gree.net> writes:\n\n> On Wed, May 7, 2025 at 2:16 AM Junio C Hamano <gitster@pobox.com> wrote:\n>> Just for reference (as the proposed log message refers to an \"older\n>> macOS\"), do we know if the toolchain on a more recent release of\n>> macOS work without this workaround already?  It may be nice to tell\n>> users what version they need to avoid the same issue in their own\n>> program.\n>\n> I tested further with Xcode 14.3.1 (the last version of 14.x) and 15,\n> where the former still had the issue and the latter worked without the\n> workaround. Xcode 15 introduces a new linker which seems to fix the bug.\n>\n> cf. https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Build-System\n>\n> Koji Nakamaru\n\nWonderful.  Thanks for a quick report.\n\nHere is an updated patch with the above information.\n\nThanks.\n\n--- >8 ---\nFrom: Torsten Bögershausen <tboegi@web.de>\nDate:   Tue May 6 14:06:44 2025 +0200\n\nintialize false_but_the_compiler_does_not_know_it_\n\nCompiling/linking 82e79c63642c on an older MacOs machine (like Xcode\n14.3.1, the last version of 14.x series) leads to this:\n\n    Undefined symbols for architecture x86_64:\n      \"_false_but_the_compiler_does_not_know_it_\", referenced from:\n          _start_command in libgit.a(run-command.o)\n\nThe linker fails to pick up compiler-tricks/not-constant.o that\ndefines the needed false_but_the_compiler_does_not_know_it_ symbol,\nwhich is the only thing defined in that object file, from the\nlibgit.a archive.\n\nInitializing the variable explicitly to 0 works around the linker\nbug; the symbol type changes from 'C' to 'S' and is picked up by the\nlinker.\n\nXcode 15 introduces a new linker, which seems to fix the bug, making\nthe workaround here unnecessary, and Apple requires [*] to build with\nXcode 16 or later in order to upload to their App Store Connect\nsince April 24, 2025, but not everybody is expected to upgrade their\ntoolchain immediately.\n\n [*] https://developer.apple.com/news/upcoming-requirements/?id=02212025a\n\nHelped-by: Koji Nakamaru <koji.nakamaru@gree.net>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n[jc: update version info with Koji's help]\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n\ndiff --git a/compiler-tricks/not-constant.c b/compiler-tricks/not-constant.c\nindex 1da3ffc2f5..9fb4f275b1 100644\n--- a/compiler-tricks/not-constant.c\n+++ b/compiler-tricks/not-constant.c\n@@ -1,2 +1,2 @@\n #include <git-compat-util.h>\n-int false_but_the_compiler_does_not_know_it_;\n+int false_but_the_compiler_does_not_know_it_ = 0;\n"}]}