{"thread":{"id":"64154","subject":"[Bug] Unrealiable threading support detection (on HP-UX)","startedAt":"2025-09-16T20:12:38Z","lastAt":"2025-09-16T20:12:38Z","messageCount":1,"participants":["Osipov, Michael (IN IT IN)"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"526477","messageId":"93cee8d0-0c1d-4329-ae93-7f900601995e@innomotics.com","threadId":"64154","inReplyTo":null,"subject":"[Bug] Unrealiable threading support detection (on HP-UX)","fromName":"Osipov, Michael (IN IT IN)","fromEmail":"michael.osipov@innomotics.com","sentAt":"2025-09-16T20:12:33Z","receivedAt":"2025-09-16T20:12:38Z","isPatch":false,"sender":{"key":"michael.osipov@innomotics.com","avatar":null},"body":"Hi folks,\n\nI have stumbled upon an issue on HP-UX where the detection of threading \n(pthreads) is incorrect or unreliable. There are actually two issues: \nincorrect display and incorrect detection.\n\nConsider:\n> root@deblndw001x:/var/tmp/ports/work/git-2.51.0\n> # CPPFLAGS=\"$CPPFLAGS -D_XOPEN_SOURCE=600\" $CONFIGURE --with-editor=vim --with-zlib=$PREFIX   --with-perl=/usr/bin/perl --with-iconv=$PREFIX --with-libpcre2=$PREFIX   --with-gitconfig=$SYSCONFDIR/gitconfig --with-gitattributes=$SYSCONFDIR/gitattributes --without-tcltk --with-lib=lib/hpux32\n> configure: Setting lib to 'lib/hpux32'\n> configure: Will try -pthread then -lpthread to enable POSIX Threads.\n> ...\n> checking for POSIX Threads with ''... yes\n> configure: creating ./config.status\n> config.status: creating config.mak.autogen\n> config.status: executing config.mak.autogen commands\n\nLooking at configure.ac the message \"Will try...\" is not correct because \nmuch more is tried:\n> for opt in -mt -pthread -lpthread; do\n\nSo either the message needs to be extended *or* the values removed from \nthe message to avoid updating both.\n\nThe output tells us that pthread support is in libc since no library is \nrequired. Let's try:\n> # git clone https://github.com/freebsd/freebsd-src.git\n> Cloning into 'freebsd-src'...\n> error: cannot create async thread: Function is not available\n> fatal: fetch-pack: unable to fork off sideband demultiplexer\n\nDoesn't work. HP-UX requires either -lphtread or better -mt.\n\n> # diff configure.ac.orig configure.ac\n> --- configure.ac.orig   2025-09-16 18:05:44 +0200\n> +++ configure.ac        2025-09-16 18:05:55 +0200\n> @@ -1272,7 +1272,7 @@\n>    # trigger a warning about an unused flag). Hence if we checked for\n>    # \"-mt\" before \"\" we would end up picking it. But unfortunately this\n>    # would then trigger compiler warnings on every single file we compile.\n> -  for opt in \"\" -mt -pthread -lpthread; do\n> +  for opt in -mt -pthread -lpthread; do\n>       old_CFLAGS=\"$CFLAGS\"\n>       old_LIBS=\"$LIBS\"\n>       case \"$opt\" in\n\ndoes the trick. But why did it apparently work during configuration?.. \nand here is now the bug:\n> configure:8609: checking for POSIX Threads with ''\n> configure:8639: /opt/aCC/bin/aCC -AC99 -AC99 -o conftest  +We901 -I/opt/ports/include -D_XOPEN_SOURCE=600 -L/opt/ports/lib/hpux32 conftest.c  -lintl >&5\n> \"conftest.c\", line 45: warning #2111-D: statement is unreachable\n>     return 0;\n>     ^\n> \n> configure:8639: $? = 0\n> configure:8641: result: yes\n\n$LIBS is passed and libs contain -lintl. GNU gettext nowaways (since \n0.23) links by default against libpthread, so it is a transitive \ndependency and goes unnoticed. The manpage for pthread says the following:\n>       A multithreaded application must define the appropriate POSIX revision\n>       level (199506) at compile time and link against the pthread library\n>       with -lpthread.  For example:\n> \n>            cc -D_POSIX_C_SOURCE=199506L -o myapp myapp.c -lpthread\n> \n>       All program sources must also include the header file <pthread.h>.\n> \n>       Note: If -lc is explicitly specified in the link line, then it must be\n>       after the -lpthread.  Refer to pthread_stubs(5) for more details.\n\nSo, git and everything in libexec *must* be linked with -mt otherwise it \nwill fail at runtime.\n\nTo sum up, we have two bugs:\n* Incorrect display of the values to tried (./configure --help is \nincorrect as well)\n* Incorrect detection during configuration\n\nAs a workaround I can pass \"--enable-pthreads=-mt\", but I'd rather \neither have no threading or correct threading by default, but not \nsomething broken at runtime.\n\nLet me know what you think!\n\nMichael\n\nPS: FWIW, I have reported a similar issue for MIT Kerberos with GNU \ngettext and Cyrus SASL today: \nhttps://mailman.mit.edu/pipermail/kerberos/2025-September/023286.html\n"}]}