# Building git with /bin/sh⇔dash produces suboptimal GIT-CFLAGS file

3 messages from 2024-11-28 to 2024-11-28. Participants: Дилян Палаузов, brian m. carlson.
Thread: https://gitlist.dev/t/62556

## Дилян Палаузов, 2024-11-28 13:53

Subject: Building git with /bin/sh⇔dash produces suboptimal GIT-CFLAGS file
Message-ID: <b4ef94b2a0294c338d115fee68e0c31e44dad3b9.camel@aegee.org>
URL: https://gitlist.dev/e/b4ef94b2a0294c338d115fee68e0c31e44dad3b9.camel%40aegee.org

```
Hello,

when /bin/sh is bash, target GIT-CFLAGS: FORCE in Makefile puts in the file GIT-CFLAGS the content

gcc:  -g -O2  -I. -DHAVE_SYSINFO -DGIT_HOST_CPU="\"x86_64\"" -DUSE_LIBPCRE2 -DHAVE_ALLOCA_H -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -DSUPPORTS_SIMPLE_IPC -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"git-compat-util.h\"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\"" -DSHA256_BLK  -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_SYNC_FILE_RANGE -DHAVE_GETDELIM '-
DPROCFS_EXECUTABLE_PATH="/proc/self/exe"' -DFREAD_READS_DIRECTORIES -DSHELL_PATH='"/bin/sh"':

when /bin/sh is dash (b3e38ad), the same file GIT-CFLAGS contains

gcc:  -g -O2  -I. -DHAVE_SYSINFO -DGIT_HOST_CPU=""x86_64"" -DUSE_LIBPCRE2 -DHAVE_ALLOCA_H -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -DSUPPORTS_SIMPLE_IPC -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C=""git-compat-util.h"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=""git-compat-util.h"" -DSHA256_BLK  -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_SYNC_FILE_RANGE -DHAVE_GETDELIM '-
DPROCFS_EXECUTABLE_PATH="/proc/self/exe"' -DFREAD_READS_DIRECTORIES -DSHELL_PATH='"/bin/sh"':

Note the differences in the -DGIT_HOST_CPU, -DSHA1DC_CUSTOM_INCLUDE_SHA1_C values.  Because of the differences, in Makefile:3150   if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then  always succeeds, prints “* new build flags” and every run of make starts rebuilding daemon.o.  So the empty build is not empty.

Greetings
  Дилян

```

## brian m. carlson, 2024-11-28 17:25

Subject: Re: Building git with /bin/sh⇔dash produces suboptimal GIT-CFLAGS file
Message-ID: <Z0inflH-gQbZwNCX@tapette.crustytoothpaste.net>
URL: https://gitlist.dev/e/Z0inflH-gQbZwNCX%40tapette.crustytoothpaste.net
In-Reply-To: <b4ef94b2a0294c338d115fee68e0c31e44dad3b9.camel@aegee.org>

```
On 2024-11-28 at 13:53:21, Дилян Палаузов wrote:
> Hello,
> 
> when /bin/sh is bash, target GIT-CFLAGS: FORCE in Makefile puts in the file GIT-CFLAGS the content
> 
> gcc:  -g -O2  -I. -DHAVE_SYSINFO -DGIT_HOST_CPU="\"x86_64\"" -DUSE_LIBPCRE2 -DHAVE_ALLOCA_H -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -DSUPPORTS_SIMPLE_IPC -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"git-compat-util.h\"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\"" -DSHA256_BLK  -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_SYNC_FILE_RANGE -DHAVE_GETDELIM '-
> DPROCFS_EXECUTABLE_PATH="/proc/self/exe"' -DFREAD_READS_DIRECTORIES -DSHELL_PATH='"/bin/sh"':
> 
> when /bin/sh is dash (b3e38ad), the same file GIT-CFLAGS contains
> 
> gcc:  -g -O2  -I. -DHAVE_SYSINFO -DGIT_HOST_CPU=""x86_64"" -DUSE_LIBPCRE2 -DHAVE_ALLOCA_H -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -DSUPPORTS_SIMPLE_IPC -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C=""git-compat-util.h"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=""git-compat-util.h"" -DSHA256_BLK  -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_SYNC_FILE_RANGE -DHAVE_GETDELIM '-
> DPROCFS_EXECUTABLE_PATH="/proc/self/exe"' -DFREAD_READS_DIRECTORIES -DSHELL_PATH='"/bin/sh"':
> 
> Note the differences in the -DGIT_HOST_CPU, -DSHA1DC_CUSTOM_INCLUDE_SHA1_C values.  Because of the differences, in Makefile:3150   if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then  always succeeds, prints “* new build flags” and every run of make starts rebuilding daemon.o.  So the empty build is not empty.

I don't see this on Debian unstable's 0.5.12-9, so I'd say that this is
likely a dash bug upstream, probably a regression, and I'd suggest you
report it to them.  I don't see any reason that the Makefile should be
doing anything incorrect here after some inspection.

I've noted, looking at the upstream Git repository, that (unlike zsh)
there's no testsuite, so perhaps this is the kind of thing that could
well end up in a future testsuite.
-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA

```

## Дилян Палаузов, 2024-11-28 18:52

Subject: Re: Building git with /bin/sh⇔dash produces suboptimal GIT-CFLAGS file
Message-ID: <580342884c7b59f74f29ce1b824ffcb096113ee7.camel@aegee.org>
URL: https://gitlist.dev/e/580342884c7b59f74f29ce1b824ffcb096113ee7.camel%40aegee.org
In-Reply-To: <Z0inflH-gQbZwNCX@tapette.crustytoothpaste.net>

```
Hello,

echo U\"\\\"U > out

puts in out 

U"\"U

under bash, and 

U""U

with dash.  Every time I report to dash@vger.kernel.org that something is broken, e.g. because it behaves differently in dash from bash, the answer is that both behaviours are allowed by POSIX, echo is not portable and should not be used.  git’s Makefile does  echo "$$FLAGS" >GIT-CFLAGS so I am not going to report this to dash.

Greetings
  Дилян

-----Original Message-----
From: brian m. carlson <sandals@crustytoothpaste.net>
To: Дилян Палаузов <dilyan.palauzov@aegee.org>
Cc: git@vger.kernel.org
Subject: Re: Building git with /bin/sh⇔dash produces suboptimal GIT-CFLAGS file
Date: 28/11/24 18:25:18

On 2024-11-28 at 13:53:21, Дилян Палаузов wrote:
> Hello,
> 
> when /bin/sh is bash, target GIT-CFLAGS: FORCE in Makefile puts in the file GIT-CFLAGS the content
> 
> gcc:  -g -O2  -I. -DHAVE_SYSINFO -DGIT_HOST_CPU="\"x86_64\"" -DUSE_LIBPCRE2 -DHAVE_ALLOCA_H -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -DSUPPORTS_SIMPLE_IPC -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"git-compat-util.h\"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\"" -DSHA256_BLK  -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_SYNC_FILE_RANGE -DHAVE_GETDELIM '-
> DPROCFS_EXECUTABLE_PATH="/proc/self/exe"' -DFREAD_READS_DIRECTORIES -DSHELL_PATH='"/bin/sh"':
> 
> when /bin/sh is dash (b3e38ad), the same file GIT-CFLAGS contains
> 
> gcc:  -g -O2  -I. -DHAVE_SYSINFO -DGIT_HOST_CPU=""x86_64"" -DUSE_LIBPCRE2 -DHAVE_ALLOCA_H -I/usr/local/include -DUSE_CURL_FOR_IMAP_SEND -DSUPPORTS_SIMPLE_IPC -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C=""git-compat-util.h"" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=""git-compat-util.h"" -DSHA256_BLK  -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_SYNC_FILE_RANGE -DHAVE_GETDELIM '-
> DPROCFS_EXECUTABLE_PATH="/proc/self/exe"' -DFREAD_READS_DIRECTORIES -DSHELL_PATH='"/bin/sh"':
> 
> Note the differences in the -DGIT_HOST_CPU, -DSHA1DC_CUSTOM_INCLUDE_SHA1_C values.  Because of the differences, in Makefile:3150   if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then  always succeeds, prints “* new build flags” and every run of make starts rebuilding daemon.o.  So the empty build is not empty.

I don't see this on Debian unstable's 0.5.12-9, so I'd say that this is
likely a dash bug upstream, probably a regression, and I'd suggest you
report it to them.  I don't see any reason that the Makefile should be
doing anything incorrect here after some inspection.

I've noted, looking at the upstream Git repository, that (unlike zsh)
there's no testsuite, so perhaps this is the kind of thing that could
well end up in a future testsuite.


```
