Skip to contentSkip to conversation

Fit the building tools to Plan 9 environment

PATCH Superseded KADOTA, Kyohei via GitGitGadget 5 participants 29 messages Aug 6, 2020 – Sep 10, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Fit the building tools to Plan 9 environment

I've posted some commits for porting git to Plan 9.

This pull request is thing that cut off building scripts from #305 and is re-constructed that.

I expect this don't change any artifacts.

lufia (4):
Use $(SHELL_PATH) instead of sh in Makefile. Define TAR_CF and TAR_XF variables in Makefile Fit to Plan 9's ANSI/POSIX compatibility layer Use $(LD) instead of $(CC) for linking the object files

 .github/workflows/main.yml |  1 +
 GIT-VERSION-GEN            |  2 +-
 Makefile                   | 33 ++++++++++---------
 ci/lib.sh                  |  8 ++++-
 config.mak.in              |  1 +
 config.mak.uname           | 18 +++++++----
 generate-cmdlist.sh        | 19 +++++++----
 git-gui/Makefile           |  6 ++--
 t/chainlint.sed            | 66 +++++++++++++++++++-------------------
 templates/Makefile         |  6 ++--
 10 files changed, 93 insertions(+), 67 deletions(-)

base-commit: dc04167d378fb29d30e1647ff6ff51dd182bc9a3
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-694%2Flufia%2Fcompat-p9-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-694/lufia/compat-p9-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/694

Signature · 1 line
gitgitgadget
#7 lore raw

PATCH 2/4 Define TAR_CF and TAR_XF variables in Makefile

From: lufia <[email protected]>

Plan 9's tar(1) don't support o option.
So I changed Makefiles to replace tar commands if needed.

---
 Makefile           | 14 ++++++++------
 templates/Makefile |  6 ++++--
 2 files changed, 12 insertions(+), 8 deletions(-)
Makefile +8 -6
index 372139f1f2..e222241509 100644
@@ -547,6 +547,8 @@ AR = ar
 RM = rm -f
 DIFF = diff
 TAR = tar
+TAR_CF = $(TAR) cf
+TAR_XF = $(TAR) xof
 FIND = find
 INSTALL = install
 TCL_PATH = tclsh
@@ -2926,13 +2928,13 @@ endif
 	$(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
 ifndef NO_GETTEXT
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(localedir_SQ)'
-	(cd po/build/locale && $(TAR) cf - .) | \
-	(cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR) xof -)
+	(cd po/build/locale && $(TAR_CF) - .) | \
+	(cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR_XF) -)
 endif
 ifndef NO_PERL
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perllibdir_SQ)'
-	(cd perl/build/lib && $(TAR) cf - .) | \
-	(cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xof -)
+	(cd perl/build/lib && $(TAR_CF) - .) | \
+	(cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR_XF) -)
 	$(MAKE) -C gitweb install
 endif
 ifndef NO_TCLTK
@@ -2999,8 +3001,8 @@ install-man: install-man-perl
 
 install-man-perl: man-perl
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mandir_SQ)/man3'
-	(cd perl/build/man/man3 && $(TAR) cf - .) | \
-	(cd '$(DESTDIR_SQ)$(mandir_SQ)/man3' && umask 022 && $(TAR) xof -)
+	(cd perl/build/man/man3 && $(TAR_CF) - .) | \
+	(cd '$(DESTDIR_SQ)$(mandir_SQ)/man3' && umask 022 && $(TAR_XF) -)
 
 install-html:
 	$(MAKE) -C Documentation install-html
templates/Makefile +4 -2
index d22a71a399..eddc07effb 100644
@@ -6,6 +6,8 @@ endif
 
 INSTALL ?= install
 TAR ?= tar
+TAR_CF ?= tar cf
+TAR_XF ?= tar xof
 RM ?= rm -f
 prefix ?= $(HOME)
 template_instdir ?= $(prefix)/share/git-core/templates
@@ -62,5 +64,5 @@ clean:
 
 install: all
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
-	(cd blt && $(TAR) cf - .) | \
-	(cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -)
+	(cd blt && $(TAR_CF) - .) | \
+	(cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR_XF) -)
Signature · 1 line
gitgitgadget
#1 lore raw

PATCH 1/4 Use $(SHELL_PATH) instead of sh in Makefile.

In reply to KADOTA, Kyohei via GitGitGadget

From: lufia <[email protected]>

In the not POSIX environment, like Plan 9, sh might not be looked up in the directories named by the $PATH.

---
 config.mak.uname | 12 ++++++------
 git-gui/Makefile |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)
config.mak.uname +6 -6
index c7eba69e54..f3eb2b91a2 100644
@@ -4,12 +4,12 @@
 # Microsoft's Safe Exception Handling in libraries (such as zlib).
 # Typically required for VS2013+/32-bit compilation on Vista+ versions.
 
-uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
-uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
-uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
-uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
-uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
-uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
+uname_S := $(shell $(SHELL_PATH) -c 'uname -s 2>/dev/null || echo not')
+uname_M := $(shell $(SHELL_PATH) -c 'uname -m 2>/dev/null || echo not')
+uname_O := $(shell $(SHELL_PATH) -c 'uname -o 2>/dev/null || echo not')
+uname_R := $(shell $(SHELL_PATH) -c 'uname -r 2>/dev/null || echo not')
+uname_P := $(shell $(SHELL_PATH) -c 'uname -p 2>/dev/null || echo not')
+uname_V := $(shell $(SHELL_PATH) -c 'uname -v 2>/dev/null || echo not')
 
 ifdef MSVC
 	# avoid the MingW and Cygwin configuration sections
git-gui/Makefile +3 -3
index f10caedaa7..c47603c397 100644
@@ -11,9 +11,9 @@ GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
 -include GIT-VERSION-FILE
 
-uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
-uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
-uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
+uname_S := $(shell $(SHELL_PATH) -c 'uname -s 2>/dev/null || echo not')
+uname_O := $(shell $(SHELL_PATH) -c 'uname -o 2>/dev/null || echo not')
+uname_R := $(shell $(SHELL_PATH) -c 'uname -r 2>/dev/null || echo not')
 
 SCRIPT_SH = git-gui.sh
 GITGUI_MAIN := git-gui
Signature · 1 line
gitgitgadget
#16 lore raw

PATCH 4/4 Use $(LD) instead of $(CC) for linking the object files

In reply to KADOTA, Kyohei via GitGitGadget

From: lufia <[email protected]>

Plan 9's loader(aka. linker) is separated from the compiler. The compilers are called 8c, 6c... for each machine architectures; corresponded loaders are called 8l, 6l...

---
 .github/workflows/main.yml |  1 +
 Makefile                   | 19 ++++++++++---------
 ci/lib.sh                  |  8 +++++++-
 config.mak.in              |  1 +
 config.mak.uname           |  6 ++++++
 5 files changed, 25 insertions(+), 10 deletions(-)
.github/workflows/main.yml +1 -0
index 84a5dcff7a..37b006f371 100644
@@ -243,6 +243,7 @@ jobs:
             pool: ubuntu-latest
     env:
       CC: ${{matrix.vector.cc}}
+      LD: ${{matrix.vector.cc}}
       jobname: ${{matrix.vector.jobname}}
     runs-on: ${{matrix.vector.pool}}
     steps:
Makefile +10 -9
index e222241509..a52a05604a 100644
@@ -543,6 +543,7 @@ export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
 
 # Set our default programs
 CC = cc
+LD = cc
 AR = ar
 RM = rm -f
 DIFF = diff
@@ -2128,7 +2129,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = \
 	'-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
 
 git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) \
 		$(filter %.o,$^) $(LIBS)
 
 help.sp help.s help.o: command-list.h
@@ -2459,25 +2460,25 @@ compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null
 endif
 
 git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
 git-bugreport$X: bugreport.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(LIBS)
 
 git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(IMAP_SEND_LDFLAGS) $(LIBS)
 
 git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(LIBS)
 git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
 git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
 	$(VCSSVN_LIB)
 
 $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
@@ -2487,7 +2488,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
 	cp $< $@
 
 $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
 $(LIB_FILE): $(LIB_OBJS)
@@ -2782,7 +2783,7 @@ t/helper/test-svn-fe$X: $(VCSSVN_LIB)
 t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
 
 t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
 
 check-sha1:: t/helper/test-tool$X
 	t/helper/test-sha1.sh
ci/lib.sh +7 -1
index 3eefec500d..19c5beb277 100755
@@ -125,6 +125,7 @@ then
 	test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx
 	CI_REPO_SLUG="$(expr "$BUILD_REPOSITORY_URI" : '.*/\([^/]*/[^/]*\)$')"
 	CC="${CC:-gcc}"
+	LD="$CC"
 
 	# use a subdirectory of the cache dir (because the file share is shared
 	# among *all* phases)
@@ -149,6 +150,7 @@ then
 	CI_REPO_SLUG="$GITHUB_REPOSITORY"
 	CI_JOB_ID="$GITHUB_RUN_ID"
 	CC="${CC:-gcc}"
+	LD="$CC"
 
 	cache_dir="$HOME/none"
 
@@ -184,6 +186,7 @@ linux-clang|linux-gcc)
 	if [ "$jobname" = linux-gcc ]
 	then
 		export CC=gcc-8
+		export LD="$CC"
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3"
 	else
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python2"
@@ -207,6 +210,7 @@ osx-clang|osx-gcc)
 	if [ "$jobname" = osx-gcc ]
 	then
 		export CC=gcc-9
+		export LD="$CC"
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=$(which python3)"
 	else
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=$(which python2)"
@@ -222,12 +226,14 @@ GETTEXT_POISON)
 	;;
 Linux32)
 	CC=gcc
+	LD="$CC"
 	;;
 linux-musl)
 	CC=gcc
+	LD="$CC"
 	MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3 USE_LIBPCRE2=Yes"
 	MAKEFLAGS="$MAKEFLAGS NO_REGEX=Yes ICONV_OMITS_BOM=Yes"
 	;;
 esac
 
-MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
+MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc} LD=${LD:-cc}"
config.mak.in +1 -0
index e6a6d0f941..76ea7e781e 100644
@@ -2,6 +2,7 @@
 # @configure_input@
 
 CC = @CC@
+LD = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
config.mak.uname +6 -0
index f3eb2b91a2..3c4c11eec1 100644
@@ -69,6 +69,7 @@ ifeq ($(uname_S),GNU/kFreeBSD)
 endif
 ifeq ($(uname_S),UnixWare)
 	CC = cc
+	LD = $(CC)
 	NEEDS_SOCKET = YesPlease
 	NEEDS_NSL = YesPlease
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
@@ -90,6 +91,7 @@ ifeq ($(uname_S),SCO_SV)
 	endif
 	ifeq ($(uname_R),5)
 		CC = cc
+		LD = $(CC)
 		BASIC_CFLAGS += -Kthread
 	endif
 	NEEDS_SOCKET = YesPlease
@@ -435,6 +437,7 @@ ifeq ($(uname_S),Windows)
 	DEFAULT_HELP_FORMAT = html
 
 	CC = compat/vcbuild/scripts/clink.pl
+	LD = $(CC)
 	AR = compat/vcbuild/scripts/lib.pl
 	CFLAGS =
 	BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
@@ -525,6 +528,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
 	ifeq ($(uname_R).$(uname_V),L17.02)
 		CC += -WRVU=L16.05
 	endif
+	LD = $(CC)
 	# Disable all optimization, seems to result in bad code, with -O or -O2
 	# or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
 	# abends on "git push". Needs more investigation.
@@ -665,8 +669,10 @@ else
 			BASIC_LDFLAGS += -Wl,--large-address-aware
 		endif
 		CC = gcc
+		LD = $(CC)
 		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
 			-fstack-protector-strong
+		BASIC_LDFLAGS += -fstack-protector-strong
 		EXTLIBS += -lntdll
 		INSTALL = /bin/install
 		NO_R_TO_GCC_LINKER = YesPlease
Signature · 1 line
gitgitgadget
#9 lore raw

PATCH 3/4 Fit to Plan 9's ANSI/POSIX compatibility layer

In reply to KADOTA, Kyohei via GitGitGadget

From: lufia <[email protected]>

That haven't any commands: cut, expr and printf.

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

---
 GIT-VERSION-GEN     |  2 +-
 generate-cmdlist.sh | 19 ++++++++-----
 t/chainlint.sed     | 66 ++++++++++++++++++++++-----------------------
 3 files changed, 47 insertions(+), 40 deletions(-)
GIT-VERSION-GEN +1 -1
index 9db2f4feab..a7cc01caf9 100755
@@ -26,7 +26,7 @@ else
 	VN="$DEF_VER"
 fi
 
-VN=$(expr "$VN" : v*'\(.*\)')
+VN=${VN#v}
 
 if test -r $GVF
 then
generate-cmdlist.sh +13 -6
index 45fecf8bdf..8344ca6264 100755
@@ -6,11 +6,11 @@ die () {
 }
 
 command_list () {
-	eval "grep -ve '^#' $exclude_programs" <"$1"
+	eval "grep -v -e '^#' $exclude_programs" <"$1"
 }
 
 get_categories () {
-	tr ' ' '\n'|
+	tr ' ' '\012'|
 	grep -v '^$' |
 	sort |
 	uniq
@@ -18,13 +18,13 @@ get_categories () {
 
 category_list () {
 	command_list "$1" |
-	cut -c 40- |
+	awk '{ print substr($0, 40) }' |
 	get_categories
 }
 
 get_synopsis () {
 	sed -n '
-		/^NAME/,/'"$1"'/H
+		/^NAME/,/'"$1"'/h
 		${
 			x
 			s/.*'"$1"' - \(.*\)/N_("\1")/
@@ -60,16 +60,23 @@ define_category_names () {
 	echo "};"
 }
 
+if test -z "$(echo -n)"
+then
+	alias print='echo -n'
+else
+	alias print='printf %s'
+fi
+
 print_command_list () {
 	echo "static struct cmdname_help command_list[] = {"
 
 	command_list "$1" |
 	while read cmd rest
 	do
-		printf "	{ \"$cmd\", $(get_synopsis $cmd), 0"
+		print "	{ \"$cmd\", $(get_synopsis $cmd), 0"
 		for cat in $(echo "$rest" | get_categories)
 		do
-			printf " | CAT_$cat"
+			print " | CAT_$cat"
 		done
 		echo " },"
 	done
t/chainlint.sed +33 -33

174 lines not on this page · raw message

Signature · 1 line
gitgitgadget
#10 lore raw

Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer

Quoted 3 lines · lufia via GitGitGadget

From: lufia <[email protected]>

That haven't any commands: cut, expr and printf.

Is this ANSI/POSIX environment the one mentioned at [0]? That page describes it as supporting POSIX 1003.1-1990, which is a bit dated. I think we generally assume one has the 2001 edition or later, so you'll have your work cut out for you.

Quoted 11 lines

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

I will note that usually the project prefers to have a human's personal name here and in the commit metadata instead of a username. Junio may chime in here with an opinion.

generate-cmdlist.sh die () { · line 9

Quoted 3 lines

command_list () {

generate-cmdlist.sh +1 -1
-	eval "grep -ve '^#' $exclude_programs" <"$1"
+	eval "grep -v -e '^#' $exclude_programs" <"$1"

Is it really the case that Plan 9's grep cannot deal with bundled short options? That seems to be a significant departure from POSIX and Unix behavior. Regardless, this should be explained in the commit message.

generate-cmdlist.sh die () { · line 13

Quoted 3 lines

get_categories () {

generate-cmdlist.sh +1 -1
-	tr ' ' '\n'|
+	tr ' ' '\012'|

Okay, I guess. Is this something we need to handle elsewhere as well? The commit message should tell us why this is necessary, and what Plan 9 does and doesn't support.

generate-cmdlist.sh get_categories () { · line 21

Quoted 9 lines
generate-cmdlist.sh +1 -1
 	grep -v '^$' |
 	sort |
 	uniq
@@ -18,13 +18,13 @@ get_categories () {
 
 category_list () {
 	command_list "$1" |
-	cut -c 40- |
+	awk '{ print substr($0, 40) }' |

I can tell that you haven't gotten the test suite working because I've added a large number of cut invocations there. I suspect you're going to need to provide a portability wrapper there that implements it using awk, sed, or perl.

generate-cmdlist.sh define_category_names () { · line 68

Quoted 6 lines
generate-cmdlist.sh +6 -0
+if test -z "$(echo -n)"
+then
+	alias print='echo -n'
+else
+	alias print='printf %s'
+fi

Let's avoid an alias here (especially with a common builtin name) and instead use a shell function. Maybe like this (not tab-indented):

  print_nonl () {
    if command -v printf >/dev/null 2>&1
    then
      printf "%s" "$@"
    else
      echo -n "$@"
    fi
  }

Notice also that we prefer the standard form and fall back to the nonstandard form if the system is less capable. I don't know if Plan 9 supports "command -v"; "type" may be preferable, but isn't supported by some other shells (e.g., posh). For portability reasons, we may need to try to run printf and see if it fails.

This is also going to need some patching in the testsuite, since we use printf extensively (more than 1300 times). I do hope you have perl available.

[0] http://doc.cat-v.org/plan_9/4th_edition/papers/ape

Signature · 1 line
brian m. carlson: Houston, Texas, US
#2 lore raw

Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.

In reply to lufia via GitGitGadget
Quoted 4 lines · lufia via GitGitGadget

From: lufia <[email protected]>

In the not POSIX environment, like Plan 9, sh might not be looked up in the directories named by the $PATH.

I think Git's editor handling assumes that sh is somewhere in the PATH, so it might be fine for us to just ask the user to adjust PATH appropriately before running make. I don't have a strong preference; if this works on a standard Unix machine, which it looks like it should (although I haven't tested), I'm fine with it.

Signature · 1 line
brian m. carlson: Houston, Texas, US
#17 lore raw
In reply to KADOTA, Kyohei via GitGitGadget
Quoted 6 lines · Kyohei via GitGitGadget

I've posted some commits for porting git to Plan 9.

This pull request is thing that cut off building scripts from #305 and is re-constructed that.

I expect this don't change any artifacts.

I took a look at this and left some comments. I expect you're going to have your work cut out for you in the test suite due to the lack of good, modern POSIX support.

I regret to report that I looked at the source code of the ANSI/POSIX environment from the Berkeley release and found that it's mostly shell scripts (well, rc scripts) and has all of the functionality one would expect from that. I suspect that this will not make the port any easier.

Signature · 1 line
brian m. carlson: Houston, Texas, US
#3 lore raw

Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.

In reply to brian m. carlson
Quoted 9 lines · brian m. carlson
Quoted 2 lines · lufia via GitGitGadget

In the not POSIX environment, like Plan 9, sh might not be looked up in the directories named by the $PATH.

I think Git's editor handling assumes that sh is somewhere in the PATH, so it might be fine for us to just ask the user to adjust PATH appropriately before running make. I don't have a strong preference; if this works on a standard Unix machine, which it looks like it should (although I haven't tested), I'm fine with it.

This does, however, have a bit of a chicken-and-egg feel to it. The results of the "uname_FOO" assignments in config.mak.uname are consulted later in the file to _assign_ a value to SHELL_PATH on a number of platforms. So, making the "uname_FOO" assignments themselves depend upon SHELL_PATH is rather circular and confusing.

#11 lore raw

Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer

In reply to brian m. carlson
Quoted 9 lines · lufia via GitGitGadget
Quoted 3 lines

From: lufia <[email protected]>

That haven't any commands: cut, expr and printf.

Is this ANSI/POSIX environment the one mentioned at [0]? That page describes it as supporting POSIX 1003.1-1990, which is a bit dated. I think we generally assume one has the 2001 edition or later, so you'll have your work cut out for you.

Yes, the layer I told is APE.
I guess originally APE might be introduced for porting Ghostscript to Plan 9.

Quoted 10 lines
Quoted 10 lines

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

Quoted 5 lines
Quoted 1 line

I will note that usually the project prefers to have a human's personal name here and in the commit metadata instead of a username. Junio may chime in here with an opinion.

I see. I will rename them.

Quoted 7 lines

generate-cmdlist.sh die () { · line 9

Quoted 3 lines

command_list () {

generate-cmdlist.sh +1 -1
-     eval "grep -ve '^#' $exclude_programs" <"$1"
+     eval "grep -v -e '^#' $exclude_programs" <"$1"

Is it really the case that Plan 9's grep cannot deal with bundled short options? That seems to be a significant departure from POSIX and Unix behavior. Regardless, this should be explained in the commit message.

This is awful.
But now, APE's grep (/bin/ape/grep) is a simple wrapper for native grep (/bin/grep),
its option parser is a very rough implementation.
https://github.com/0intro/plan9-contrib/blob/master/rc/bin/ape/grep

Quoted 7 lines

generate-cmdlist.sh die () { · line 13

Quoted 3 lines

get_categories () {

generate-cmdlist.sh +1 -1
-     tr ' ' '\n'|
+     tr ' ' '\012'|

Okay, I guess. Is this something we need to handle elsewhere as well? The commit message should tell us why this is necessary, and what Plan 9 does and doesn't support.

Yeah. I will edit the message.
Plan 9's tr(1) handles only \(16 bit octal) and \x(16 bit hexadecimal) escape sequences.
If another character after leading backslash, tr(1) will replace \c to c.

Quoted 5 lines
Quoted 5 lines
      grep -v '^$' |
      sort |
      uniq
(quoted diff) +0 -0
@@ -18,13 +18,13 @@ get_categories () {
 
Quoted 9 lines

generate-cmdlist.sh get_categories () { · line 21

Quoted 4 lines
generate-cmdlist.sh +1 -1
 category_list () {
      command_list "$1" |
-     cut -c 40- |
+     awk '{ print substr($0, 40) }' |

I can tell that you haven't gotten the test suite working because I've added a large number of cut invocations there. I suspect you're going to need to provide a portability wrapper there that implements it using awk, sed, or perl.

I see. If I'd like to put those wrappers to the repository, is there the best place for them?

Quoted 25 lines

generate-cmdlist.sh define_category_names () { · line 68

Quoted 6 lines
generate-cmdlist.sh +6 -0
+if test -z "$(echo -n)"
+then
+     alias print='echo -n'
+else
+     alias print='printf %s'
+fi

Let's avoid an alias here (especially with a common builtin name) and instead use a shell function. Maybe like this (not tab-indented):

  print_nonl () {
    if command -v printf >/dev/null 2>&1
    then
      printf "%s" "$@"
    else
      echo -n "$@"
    fi
  }

Notice also that we prefer the standard form and fall back to the nonstandard form if the system is less capable. I don't know if Plan 9 supports "command -v"; "type" may be preferable, but isn't supported by some other shells (e.g., posh). For portability reasons, we may need to try to run printf and see if it fails.

Quoted 3 lines

This is also going to need some patching in the testsuite, since we use printf extensively (more than 1300 times). I do hope you have perl available.

In fact, Plan 9's ape/sh is pdksh, so it supports "command -v". However I think, like the above comment, it might be better to create the printf(1) wrapper.

---
kadota

Quoted 3 lines

[0] http://doc.cat-v.org/plan_9/4th_edition/papers/ape
--
brian m. carlson: Houston, Texas, US

#4 lore raw

Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.

In reply to Eric Sunshine
Quoted 12 lines
Quoted 9 lines · brian m. carlson
Quoted 2 lines · lufia via GitGitGadget

In the not POSIX environment, like Plan 9, sh might not be looked up in the directories named by the $PATH.

I think Git's editor handling assumes that sh is somewhere in the PATH, so it might be fine for us to just ask the user to adjust PATH appropriately before running make. I don't have a strong preference; if this works on a standard Unix machine, which it looks like it should (although I haven't tested), I'm fine with it.

Quoted 5 lines

This does, however, have a bit of a chicken-and-egg feel to it. The results of the "uname_FOO" assignments in config.mak.uname are consulted later in the file to _assign_ a value to SHELL_PATH on a number of platforms. So, making the "uname_FOO" assignments themselves depend upon SHELL_PATH is rather circular and confusing.

The problem is, Plan 9 APE's sh is placed on /bin/ape/sh by default. By running /bin/ape/psh
APE commands existed under /bin/ape such as sh, uname, etc, will be mounted on /bin.
In running of ape/psh, APE commands will prioritize than native commands. So I've wanted to run /bin/ape/psh before executing some shell commands by gmake.

----
kadota

#5 lore raw

Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.

In reply to Eric Sunshine
Quoted 12 lines · Eric Sunshine
Quoted 9 lines · brian m. carlson
Quoted 2 lines · lufia via GitGitGadget

In the not POSIX environment, like Plan 9, sh might not be looked up in the directories named by the $PATH.

I think Git's editor handling assumes that sh is somewhere in the PATH, so it might be fine for us to just ask the user to adjust PATH appropriately before running make. I don't have a strong preference; if this works on a standard Unix machine, which it looks like it should (although I haven't tested), I'm fine with it.

Quoted 5 lines

This does, however, have a bit of a chicken-and-egg feel to it. The results of the "uname_FOO" assignments in config.mak.uname are consulted later in the file to _assign_ a value to SHELL_PATH on a number of platforms. So, making the "uname_FOO" assignments themselves depend upon SHELL_PATH is rather circular and confusing.

Is that just being circular and confusing, or does it produce an incorrect result depending on the circumstances? We would end up special casing SHELL_PATH (e.g. exclude it from the variables that are set based on uname), which I would want to avoid, as I would suspect that there will be even more variables that need similar treatment.

This does have a bad smell. Even on a not-so-posix Windows, we do not use such a hack.

#8 lore raw

Re: [PATCH 2/4] Define TAR_CF and TAR_XF variables in Makefile

In reply to lufia via GitGitGadget
Quoted 1 line · lufia via GitGitGadget

From: lufia <[email protected]>

See Documentation/SubmittingPatches[[real-name]].

Quoted 2 lines

Plan 9's tar(1) don't support o option.
So I changed Makefiles to replace tar commands if needed.

There is a big gap/leap between these two sentences. The first sentence might justify TAR_XF but it does not explain why TAR_CF is needed at all. Also there is "$(TAR) czf" that is left without getting turned into $(TAR_CF)z.

Are there still remaining uses of $(TAR) after applying this patch? If with a different justification, a patch that abstracts our use of "tar" as an archiving tool into different use cases and give one Makefile macro to each of them with more meaningful names might be more palatable. E.g. instead of TAR_CF that abstracts only the "tar cf" part, make "take everything in the current directory and send an archive of it to the standard output", i.e. "tar cf - .", into a Makefile macro, with matching "take an archive from the standard input and extract it to the current directory", i.e. "tar xf -", as a matching Makefile macro, perhaps---that way people without a working "tar" might be able to use zip, cpio or pax (or a script written around them) as an alternative "archiving tool", for example.

Side note. The above would probably be a huge undertaking and I am not suggesting it as a serious counterproposal.

A more plausible alternative is to just touch "$(TAR) xof -" and replace it with $(TAR_XOF) or even $(EXTRACT_TARBALL_AS_MYSELF) while leaving $(TAR_CF) alone. That _might_ be palatable.

I dunno.

#14 lore raw

Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer

In reply to brian m. carlson
Quoted 3 lines · brian m. carlson

I will note that usually the project prefers to have a human's personal name here and in the commit metadata instead of a username. Junio may chime in here with an opinion.

Thanks, I just did.

Quoted 7 lines

Review

Quoted 3 lines

command_list () {

(quoted diff) +1 -1
-	eval "grep -ve '^#' $exclude_programs" <"$1"
+	eval "grep -v -e '^#' $exclude_programs" <"$1"

Is it really the case that Plan 9's grep cannot deal with bundled short options? That seems to be a significant departure from POSIX and Unix behavior. Regardless, this should be explained in the commit message.

I am not interested in this ball of wax, but there are some pieces that are worth salvaging. This is one of those good bits.

GIT-VERSION-GEN +1 -1
index 9db2f4feab..a7cc01caf9 100755
@@ -26,7 +26,7 @@ else
 	VN="$DEF_VER"
 fi
 
-VN=$(expr "$VN" : v*'\(.*\)')
+VN=${VN#v}
 
 if test -r $GVF
 then

BUT.

Dealing with "grep" that cannot take "-ve" and forces developers to spell it as "-v -e" is not one of them. So is forbidding use of "cut".

Quoted 7 lines

Review

Quoted 3 lines

get_categories () {

(quoted diff) +1 -1
-	tr ' ' '\n'|
+	tr ' ' '\012'|

Okay, I guess. Is this something we need to handle elsewhere as well? The commit message should tell us why this is necessary, and what Plan 9 does and doesn't support.

Yeah, POSIX does want you to understand '\n' and others, but this is within reason for portability that I think we could swallow.

Quoted 10 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+if test -z "$(echo -n)"
+then
+	alias print='echo -n'
+else
+	alias print='printf %s'
+fi

Let's avoid an alias here (especially with a common builtin name) and instead use a shell function. Maybe like this (not tab-indented):

Quoted 8 lines
  print_nonl () {
    if command -v printf >/dev/null 2>&1
    then
      printf "%s" "$@"
    else
      echo -n "$@"
    fi
  }

I'd rather not to see this done; "echo -n" and "echo '...\c'" are not portable and we do want people to use 'printf'. This directly goes against it.

Quoted 3 lines

This is also going to need some patching in the testsuite, since we use printf extensively (more than 1300 times). I do hope you have perl available.

Eh, so what would Plan9 people do with Perl? Write a single-liner 'printf' script and put it in a directory on their $PATH?

I am not sure if it is worth crippling the toolset our developers are allowed to choose from and use in our scripts and tests like this patch tries to do.

If this were Windows, it might have been a different story, but what we are talking about is Plan 9, which had the last "fourth edition" in 2002, right? During the 18 years since then, none of its users and developers work on porting many OSS packages, whose primary user base are on POSIXy systems, to it and we need to apply patches like these to each and every OSS packages of interest? I would have expected that any exotic-minority-but-thriving-platform would be able to tell its users "here are ports of POSIXy programs---install them and it can become usable by those who only know Linux"?

So, I dunno.

#12 lore raw

Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer

In reply to Kyohei Kadota
Quoted 2 lines · Kyohei Kadota

I see. If I'd like to put those wrappers to the repository, is there the best place for them?

If you can stuff them in a shell function, then I'd just put those in a file like t/test-lib-wrappers.sh and conditionally source them from t/test-lib.sh. Otherwise, I'd create a subdirectory of t and then add that to the PATH if necessary.

If you're going to use it outside of the testsuite, then maybe compat/scripts might be a good idea.

Quoted 3 lines

In fact, Plan 9's ape/sh is pdksh, so it supports "command -v". However I think, like the above comment, it might be better to create the printf(1) wrapper.

Awesome. I haven't used pdksh in a long time, but if it supports that, all the better. I'm surprised it doesn't have printf as a builtin, though.

Signature · 1 line
brian m. carlson: Houston, Texas, US
#13 lore raw

Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer

Quoted 7 lines · brian m. carlson
Quoted 2 lines · Kyohei Kadota

I see. If I'd like to put those wrappers to the repository, is there the best place for them?

If you can stuff them in a shell function, then I'd just put those in a file like t/test-lib-wrappers.sh and conditionally source them from t/test-lib.sh.

There are already platform-specific shell functions in test-lib.sh[1] and some larger compatibility functions in test-lib-functions.sh[2], so those might be better locations for Plan9 compatibility wrappers than creating a new file (or not?).

[1]: see the section commented:
"Fix some commands on Windows, and other OS-specific things"
[2]: see, for instance, the mingw_test_cmp() function

#6 lore raw

Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.

In reply to Junio C Hamano

After a moment's thought I decided to run ape/psh before building git. If so then, sh will be found from the directories named in PATH because it is mounted onto /bin.

2020年8月7日(金) 2:30 Junio C Hamano <[email protected]>:

Quoted 31 lines
Quoted 12 lines · Eric Sunshine
Quoted 9 lines · brian m. carlson
Quoted 2 lines · lufia via GitGitGadget

In the not POSIX environment, like Plan 9, sh might not be looked up in the directories named by the $PATH.

I think Git's editor handling assumes that sh is somewhere in the PATH, so it might be fine for us to just ask the user to adjust PATH appropriately before running make. I don't have a strong preference; if this works on a standard Unix machine, which it looks like it should (although I haven't tested), I'm fine with it.

Quoted 5 lines

This does, however, have a bit of a chicken-and-egg feel to it. The results of the "uname_FOO" assignments in config.mak.uname are consulted later in the file to _assign_ a value to SHELL_PATH on a number of platforms. So, making the "uname_FOO" assignments themselves depend upon SHELL_PATH is rather circular and confusing.

Is that just being circular and confusing, or does it produce an incorrect result depending on the circumstances? We would end up special casing SHELL_PATH (e.g. exclude it from the variables that are set based on uname), which I would want to avoid, as I would suspect that there will be even more variables that need similar treatment.

This does have a bad smell. Even on a not-so-posix Windows, we do not use such a hack.

#15 lore raw

Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer

In reply to Junio C Hamano
Quoted 34 lines
Quoted 3 lines · brian m. carlson

I will note that usually the project prefers to have a human's personal name here and in the commit metadata instead of a username. Junio may chime in here with an opinion.

Thanks, I just did.

Quoted 7 lines

Review

Quoted 3 lines

command_list () {

(quoted diff) +1 -1
-    eval "grep -ve '^#' $exclude_programs" <"$1"
+    eval "grep -v -e '^#' $exclude_programs" <"$1"

Is it really the case that Plan 9's grep cannot deal with bundled short options? That seems to be a significant departure from POSIX and Unix behavior. Regardless, this should be explained in the commit message.

I am not interested in this ball of wax, but there are some pieces that are worth salvaging. This is one of those good bits.

GIT-VERSION-GEN +1 -1
index 9db2f4feab..a7cc01caf9 100755
@@ -26,7 +26,7 @@ else
        VN="$DEF_VER"
 fi
 
-VN=$(expr "$VN" : v*'\(.*\)')
+VN=${VN#v}
 
 if test -r $GVF
 then
Quoted 5 lines

BUT.

Dealing with "grep" that cannot take "-ve" and forces developers to spell it as "-v -e" is not one of them. So is forbidding use of "cut".

I see. I will rewrite Plan 9's ape/grep to handle bundled options well.

Quoted 10 lines
Quoted 7 lines

Review

Quoted 3 lines

get_categories () {

(quoted diff) +1 -1
-    tr ' ' '\n'|
+    tr ' ' '\012'|

Okay, I guess. Is this something we need to handle elsewhere as well? The commit message should tell us why this is necessary, and what Plan 9 does and doesn't support.

Yeah, POSIX does want you to understand '\n' and others, but this is within reason for portability that I think we could swallow.

I'm happy, thanks.

Quoted 27 lines
Quoted 10 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+if test -z "$(echo -n)"
+then
+    alias print='echo -n'
+else
+    alias print='printf %s'
+fi

Let's avoid an alias here (especially with a common builtin name) and instead use a shell function. Maybe like this (not tab-indented):

Quoted 8 lines
  print_nonl () {
    if command -v printf >/dev/null 2>&1
    then
      printf "%s" "$@"
    else
      echo -n "$@"
    fi
  }

I'd rather not to see this done; "echo -n" and "echo '...\c'" are not portable and we do want people to use 'printf'. This directly goes against it.

Quoted 3 lines

This is also going to need some patching in the testsuite, since we use printf extensively (more than 1300 times). I do hope you have perl available.

Quoted 6 lines

Eh, so what would Plan9 people do with Perl? Write a single-liner 'printf' script and put it in a directory on their $PATH?

I am not sure if it is worth crippling the toolset our developers are allowed to choose from and use in our scripts and tests like this patch tries to do.

Like other topics, I decide to implement printf(1). These new POSIX tools will be installed to Plan 9 systems from other repo or patches before building git.

Quoted 11 lines

If this were Windows, it might have been a different story, but what we are talking about is Plan 9, which had the last "fourth edition" in 2002, right? During the 18 years since then, none of its users and developers work on porting many OSS packages, whose primary user base are on POSIXy systems, to it and we need to apply patches like these to each and every OSS packages of interest? I would have expected that any exotic-minority-but-thriving-platform would be able to tell its users "here are ports of POSIXy programs---install them and it can become usable by those who only know Linux"?

So, I dunno.

Final official distribution from Bell labs was released in Jan 2015. Now, There are some distributions that forked from official Plan 9 and are maintained by that community,
such as 9legacy, 9front or others.

I will try to implement POSIX toolsets if it is needed because POSIX is a large spec.
Thanks for your advice.

#18 lore raw

v2 cover Fit the building tools to Plan 9 environment

In reply to KADOTA, Kyohei via GitGitGadget

I've posted some commits for porting git to Plan 9.

This pull request is thing that cut off building scripts from #305 and is re-constructed that.

I expect this don't change any artifacts.

differ from v1
==============

* drop some adapters, printf, cut, expr or tar
* drop using SHELL_PATH instead of sh
* use real name at Signed-off-by signature

Kyohei Kadota (2):
Fit to Plan 9's ANSI/POSIX compatibility layer Use $(LD) instead of $(CC) for linking the object files

 .github/workflows/main.yml |  1 +
 Makefile                   | 15 +++++----
 ci/lib.sh                  |  8 ++++-
 config.mak.in              |  1 +
 config.mak.uname           |  6 ++++
 generate-cmdlist.sh        |  4 +--
 t/chainlint.sed            | 66 +++++++++++++++++++-------------------
 7 files changed, 58 insertions(+), 43 deletions(-)

base-commit: 3a238e539bcdfe3f9eb5010fd218640c1b499f7a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-694%2Flufia%2Fcompat-p9-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-694/lufia/compat-p9-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/694

Range-diff vs v1:

 1:  1f63b4fc7c < -:  ---------- Use $(SHELL_PATH) instead of sh in Makefile.
 2:  22f8f3e37a < -:  ---------- Define TAR_CF and TAR_XF variables in Makefile
 3:  d15ed626de ! 1:  c850888c25 Fit to Plan 9's ANSI/POSIX compatibility layer
     @@
       ## Metadata ##
     -Author: lufia <[email protected]>
     +Author: Kyohei Kadota <[email protected]>
      
       ## Commit message ##
          Fit to Plan 9's ANSI/POSIX compatibility layer
      
     -    That haven't any commands: cut, expr and printf.
     +    tr(1) of ANSI/POSIX environment, aka APE, don't support \n literal.
     +    It's handles only octal(\ooo) or hexadecimal(\xhhhh) numbers.
      
          And its sed(1)'s label is limited to maximum seven characters.
          Therefore I replaced some labels to drop a character.
     @@ Commit message
          * shell -> sh
          * string -> str
      
     -    Signed-off-by: lufia <[email protected]>
     -
     - ## GIT-VERSION-GEN ##
     -@@ GIT-VERSION-GEN: else
     - 	VN="$DEF_VER"
     - fi
     - 
     --VN=$(expr "$VN" : v*'\(.*\)')
     -+VN=${VN#v}
     - 
     - if test -r $GVF
     - then
     +    Signed-off-by: Kyohei Kadota <[email protected]>
      
       ## generate-cmdlist.sh ##
     -@@ generate-cmdlist.sh: die () {
     - }
     - 
     - command_list () {
     --	eval "grep -ve '^#' $exclude_programs" <"$1"
     -+	eval "grep -v -e '^#' $exclude_programs" <"$1"
     +@@ generate-cmdlist.sh: command_list () {
       }
       
       get_categories () {
     @@ generate-cmdlist.sh: die () {
       	grep -v '^$' |
       	sort |
       	uniq
     -@@ generate-cmdlist.sh: get_categories () {
     - 
     - category_list () {
     - 	command_list "$1" |
     --	cut -c 40- |
     -+	awk '{ print substr($0, 40) }' |
     - 	get_categories
     - }
     +@@ generate-cmdlist.sh: category_list () {
       
       get_synopsis () {
       	sed -n '
     @@ generate-cmdlist.sh: get_categories () {
       		${
       			x
       			s/.*'"$1"' - \(.*\)/N_("\1")/
     -@@ generate-cmdlist.sh: define_category_names () {
     - 	echo "};"
     - }
     - 
     -+if test -z "$(echo -n)"
     -+then
     -+	alias print='echo -n'
     -+else
     -+	alias print='printf %s'
     -+fi
     -+
     - print_command_list () {
     - 	echo "static struct cmdname_help command_list[] = {"
     - 
     - 	command_list "$1" |
     - 	while read cmd rest
     - 	do
     --		printf "	{ \"$cmd\", $(get_synopsis $cmd), 0"
     -+		print "	{ \"$cmd\", $(get_synopsis $cmd), 0"
     - 		for cat in $(echo "$rest" | get_categories)
     - 		do
     --			printf " | CAT_$cat"
     -+			print " | CAT_$cat"
     - 		done
     - 		echo " },"
     - 	done
      
       ## t/chainlint.sed ##
      @@
 4:  4ebd56a3c5 ! 2:  6f35562965 Use $(LD) instead of $(CC) for linking the object files
     @@
       ## Metadata ##
     -Author: lufia <[email protected]>
     +Author: Kyohei Kadota <[email protected]>
      
       ## Commit message ##
          Use $(LD) instead of $(CC) for linking the object files
     @@ Commit message
          The compilers are called 8c, 6c... for each machine architectures;
          corresponded loaders are called 8l, 6l...
      
     -    Signed-off-by: lufia <[email protected]>
     +    Signed-off-by: Kyohei Kadota <[email protected]>
      
       ## .github/workflows/main.yml ##
      @@ .github/workflows/main.yml: jobs:
     @@ Makefile: compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null
      -	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
      +	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
       
     - git-bugreport$X: bugreport.o GIT-LDFLAGS $(GITLIBS)
     --	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
     -+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
     - 		$(LIBS)
     - 
       git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)
      -	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
      +	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
     @@ Makefile: compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null
      +	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
       		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
       
     - git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
     --	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
     -+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
     - 	$(VCSSVN_LIB)
     - 
       $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
      @@ Makefile: $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
       	cp $< $@
     @@ Makefile: $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
       		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
       
       $(LIB_FILE): $(LIB_OBJS)
     -@@ Makefile: t/helper/test-svn-fe$X: $(VCSSVN_LIB)
     +@@ Makefile: perf: all
       t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
       
       t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
Signature · 1 line
gitgitgadget
#19 lore raw

PATCH v2 1/2 Fit to Plan 9's ANSI/POSIX compatibility layer

From: Kyohei Kadota <[email protected]>

tr(1) of ANSI/POSIX environment, aka APE, don't support \n literal. It's handles only octal(\ooo) or hexadecimal(\xhhhh) numbers.

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

---
 generate-cmdlist.sh |  4 +--
 t/chainlint.sed     | 66 ++++++++++++++++++++++-----------------------
 2 files changed, 35 insertions(+), 35 deletions(-)
generate-cmdlist.sh +2 -2
index 45fecf8bdf..4031623b0e 100755
@@ -10,7 +10,7 @@ command_list () {
 }
 
 get_categories () {
-	tr ' ' '\n'|
+	tr ' ' '\012'|
 	grep -v '^$' |
 	sort |
 	uniq
@@ -24,7 +24,7 @@ category_list () {
 
 get_synopsis () {
 	sed -n '
-		/^NAME/,/'"$1"'/H
+		/^NAME/,/'"$1"'/h
 		${
 			x
 			s/.*'"$1"' - \(.*\)/N_("\1")/
t/chainlint.sed +33 -33

174 lines not on this page · raw message

Signature · 1 line
gitgitgadget
#23 lore raw

PATCH v2 2/2 Use $(LD) instead of $(CC) for linking the object files

In reply to KADOTA, Kyohei via GitGitGadget

From: Kyohei Kadota <[email protected]>

Plan 9's loader(aka. linker) is separated from the compiler. The compilers are called 8c, 6c... for each machine architectures; corresponded loaders are called 8l, 6l...

---
 .github/workflows/main.yml |  1 +
 Makefile                   | 15 ++++++++-------
 ci/lib.sh                  |  8 +++++++-
 config.mak.in              |  1 +
 config.mak.uname           |  6 ++++++
 5 files changed, 23 insertions(+), 8 deletions(-)
.github/workflows/main.yml +1 -0
index 30425404eb..5ece32d4fa 100644
@@ -252,6 +252,7 @@ jobs:
             pool: ubuntu-latest
     env:
       CC: ${{matrix.vector.cc}}
+      LD: ${{matrix.vector.cc}}
       jobname: ${{matrix.vector.jobname}}
     runs-on: ${{matrix.vector.pool}}
     steps:
Makefile +8 -7
index 86e5411f39..c0c0c280f0 100644
@@ -543,6 +543,7 @@ export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
 
 # Set our default programs
 CC = cc
+LD = cc
 AR = ar
 RM = rm -f
 DIFF = diff
@@ -2121,7 +2122,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = \
 	'-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
 
 git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) \
 		$(filter %.o,$^) $(LIBS)
 
 help.sp help.s help.o: command-list.h
@@ -2445,17 +2446,17 @@ compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null
 endif
 
 git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
 git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(IMAP_SEND_LDFLAGS) $(LIBS)
 
 git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(LIBS)
 git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
 $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
@@ -2465,7 +2466,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
 	cp $< $@
 
 $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
 $(LIB_FILE): $(LIB_OBJS)
@@ -2753,7 +2754,7 @@ perf: all
 t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
 
 t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
 
 check-sha1:: t/helper/test-tool$X
 	t/helper/test-sha1.sh
ci/lib.sh +7 -1
index 3eefec500d..19c5beb277 100755
@@ -125,6 +125,7 @@ then
 	test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx
 	CI_REPO_SLUG="$(expr "$BUILD_REPOSITORY_URI" : '.*/\([^/]*/[^/]*\)$')"
 	CC="${CC:-gcc}"
+	LD="$CC"
 
 	# use a subdirectory of the cache dir (because the file share is shared
 	# among *all* phases)
@@ -149,6 +150,7 @@ then
 	CI_REPO_SLUG="$GITHUB_REPOSITORY"
 	CI_JOB_ID="$GITHUB_RUN_ID"
 	CC="${CC:-gcc}"
+	LD="$CC"
 
 	cache_dir="$HOME/none"
 
@@ -184,6 +186,7 @@ linux-clang|linux-gcc)
 	if [ "$jobname" = linux-gcc ]
 	then
 		export CC=gcc-8
+		export LD="$CC"
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3"
 	else
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python2"
@@ -207,6 +210,7 @@ osx-clang|osx-gcc)
 	if [ "$jobname" = osx-gcc ]
 	then
 		export CC=gcc-9
+		export LD="$CC"
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=$(which python3)"
 	else
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=$(which python2)"
@@ -222,12 +226,14 @@ GETTEXT_POISON)
 	;;
 Linux32)
 	CC=gcc
+	LD="$CC"
 	;;
 linux-musl)
 	CC=gcc
+	LD="$CC"
 	MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3 USE_LIBPCRE2=Yes"
 	MAKEFLAGS="$MAKEFLAGS NO_REGEX=Yes ICONV_OMITS_BOM=Yes"
 	;;
 esac
 
-MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
+MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc} LD=${LD:-cc}"
config.mak.in +1 -0
index e6a6d0f941..76ea7e781e 100644
@@ -2,6 +2,7 @@
 # @configure_input@
 
 CC = @CC@
+LD = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
config.mak.uname +6 -0
index c7eba69e54..886ce068f8 100644
@@ -69,6 +69,7 @@ ifeq ($(uname_S),GNU/kFreeBSD)
 endif
 ifeq ($(uname_S),UnixWare)
 	CC = cc
+	LD = $(CC)
 	NEEDS_SOCKET = YesPlease
 	NEEDS_NSL = YesPlease
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
@@ -90,6 +91,7 @@ ifeq ($(uname_S),SCO_SV)
 	endif
 	ifeq ($(uname_R),5)
 		CC = cc
+		LD = $(CC)
 		BASIC_CFLAGS += -Kthread
 	endif
 	NEEDS_SOCKET = YesPlease
@@ -435,6 +437,7 @@ ifeq ($(uname_S),Windows)
 	DEFAULT_HELP_FORMAT = html
 
 	CC = compat/vcbuild/scripts/clink.pl
+	LD = $(CC)
 	AR = compat/vcbuild/scripts/lib.pl
 	CFLAGS =
 	BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
@@ -525,6 +528,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
 	ifeq ($(uname_R).$(uname_V),L17.02)
 		CC += -WRVU=L16.05
 	endif
+	LD = $(CC)
 	# Disable all optimization, seems to result in bad code, with -O or -O2
 	# or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
 	# abends on "git push". Needs more investigation.
@@ -665,8 +669,10 @@ else
 			BASIC_LDFLAGS += -Wl,--large-address-aware
 		endif
 		CC = gcc
+		LD = $(CC)
 		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
 			-fstack-protector-strong
+		BASIC_LDFLAGS += -fstack-protector-strong
 		EXTLIBS += -lntdll
 		INSTALL = /bin/install
 		NO_R_TO_GCC_LINKER = YesPlease
Signature · 1 line
gitgitgadget
#20 lore raw

Re: [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer

In reply to Kyohei Kadota via GitGitGadget
Quoted 9 lines · Kyohei Kadota via GitGitGadget

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

These are reasonable. "cl" feels a little odd, but I can't think of anything better.

generate-cmdlist.sh category_list () { · line 26

Quoted 6 lines
generate-cmdlist.sh +1 -1
@@ -24,7 +24,7 @@ category_list () {
 get_synopsis () {
        sed -n '
-               /^NAME/,/'"$1"'/H
+               /^NAME/,/'"$1"'/h

This change is not mentioned in the commit message. "H" and "h" are very different commands, so it's difficult, at a glance, to tell if this change is even valid. Some explanation in the commit message would help (if it is indeed valid).

#21 lore raw

Re: [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer

Quoted 15 lines · Eric Sunshine
Quoted 9 lines · Kyohei Kadota via GitGitGadget

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

These are reasonable. "cl" feels a little odd, but I can't think of anything better.

Quoted 11 lines

generate-cmdlist.sh category_list () { · line 26

Quoted 6 lines
generate-cmdlist.sh +1 -1
@@ -24,7 +24,7 @@ category_list () {
 get_synopsis () {
        sed -n '
-               /^NAME/,/'"$1"'/H
+               /^NAME/,/'"$1"'/h

This change is not mentioned in the commit message. "H" and "h" are very different commands, so it's difficult, at a glance, to tell if this change is even valid. Some explanation in the commit message would help (if it is indeed valid).

I am glad somebody else caught the same thing as I did. copying and appending will give very different results.

Thanks.

#24 lore raw

v3 cover Fit the building tools to Plan 9 environment

In reply to KADOTA, Kyohei via GitGitGadget

I've posted some commits for porting git to Plan 9.

This pull request is thing that cut off building scripts from #305 and is re-constructed that.

I expect this don't change any artifacts.

differ from v1
==============

* drop some adapters, printf, cut, expr or tar
* drop using SHELL_PATH instead of sh
* use real name at Signed-off-by signature

Kyohei Kadota (2):
Fit to Plan 9's ANSI/POSIX compatibility layer Use $(LD) instead of $(CC) for linking the object files

 .github/workflows/main.yml |  1 +
 Makefile                   | 15 +++++----
 ci/lib.sh                  |  8 ++++-
 config.mak.in              |  1 +
 config.mak.uname           |  6 ++++
 generate-cmdlist.sh        |  2 +-
 t/chainlint.sed            | 66 +++++++++++++++++++-------------------
 7 files changed, 57 insertions(+), 42 deletions(-)

base-commit: 3a238e539bcdfe3f9eb5010fd218640c1b499f7a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-694%2Flufia%2Fcompat-p9-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-694/lufia/compat-p9-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/694

Range-diff vs v2:

1: c850888c25 ! 1: 534378c4e5 Fit to Plan 9's ANSI/POSIX compatibility layer

     @@ generate-cmdlist.sh: command_list () {
       	grep -v '^$' |
       	sort |
       	uniq
     -@@ generate-cmdlist.sh: category_list () {
     - 
     - get_synopsis () {
     - 	sed -n '
     --		/^NAME/,/'"$1"'/H
     -+		/^NAME/,/'"$1"'/h
     - 		${
     - 			x
     - 			s/.*'"$1"' - \(.*\)/N_("\1")/
      
       ## t/chainlint.sed ##
      @@

2: 6f35562965 = 2: 7d33e11867 Use $(LD) instead of $(CC) for linking the object files

Signature · 1 line
gitgitgadget
#25 lore raw

PATCH v3 1/2 Fit to Plan 9's ANSI/POSIX compatibility layer

From: Kyohei Kadota <[email protected]>

tr(1) of ANSI/POSIX environment, aka APE, don't support \n literal. It's handles only octal(\ooo) or hexadecimal(\xhhhh) numbers.

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

---
 generate-cmdlist.sh |  2 +-
 t/chainlint.sed     | 66 ++++++++++++++++++++++-----------------------
 2 files changed, 34 insertions(+), 34 deletions(-)
generate-cmdlist.sh +1 -1
index 45fecf8bdf..9dbbb08e70 100755
@@ -10,7 +10,7 @@ command_list () {
 }
 
 get_categories () {
-	tr ' ' '\n'|
+	tr ' ' '\012'|
 	grep -v '^$' |
 	sort |
 	uniq
t/chainlint.sed +33 -33

174 lines not on this page · raw message

Signature · 1 line
gitgitgadget
#27 lore raw

PATCH v3 2/2 Use $(LD) instead of $(CC) for linking the object files

In reply to KADOTA, Kyohei via GitGitGadget

From: Kyohei Kadota <[email protected]>

Plan 9's loader(aka. linker) is separated from the compiler. The compilers are called 8c, 6c... for each machine architectures; corresponded loaders are called 8l, 6l...

---
 .github/workflows/main.yml |  1 +
 Makefile                   | 15 ++++++++-------
 ci/lib.sh                  |  8 +++++++-
 config.mak.in              |  1 +
 config.mak.uname           |  6 ++++++
 5 files changed, 23 insertions(+), 8 deletions(-)
.github/workflows/main.yml +1 -0
index 30425404eb..5ece32d4fa 100644
@@ -252,6 +252,7 @@ jobs:
             pool: ubuntu-latest
     env:
       CC: ${{matrix.vector.cc}}
+      LD: ${{matrix.vector.cc}}
       jobname: ${{matrix.vector.jobname}}
     runs-on: ${{matrix.vector.pool}}
     steps:
Makefile +8 -7
index 86e5411f39..c0c0c280f0 100644
@@ -543,6 +543,7 @@ export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
 
 # Set our default programs
 CC = cc
+LD = cc
 AR = ar
 RM = rm -f
 DIFF = diff
@@ -2121,7 +2122,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = \
 	'-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
 
 git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) \
 		$(filter %.o,$^) $(LIBS)
 
 help.sp help.s help.o: command-list.h
@@ -2445,17 +2446,17 @@ compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null
 endif
 
 git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
 git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(IMAP_SEND_LDFLAGS) $(LIBS)
 
 git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(LIBS)
 git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
 $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
@@ -2465,7 +2466,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
 	cp $< $@
 
 $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
 $(LIB_FILE): $(LIB_OBJS)
@@ -2753,7 +2754,7 @@ perf: all
 t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
 
 t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
 
 check-sha1:: t/helper/test-tool$X
 	t/helper/test-sha1.sh
ci/lib.sh +7 -1
index 3eefec500d..19c5beb277 100755
@@ -125,6 +125,7 @@ then
 	test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx
 	CI_REPO_SLUG="$(expr "$BUILD_REPOSITORY_URI" : '.*/\([^/]*/[^/]*\)$')"
 	CC="${CC:-gcc}"
+	LD="$CC"
 
 	# use a subdirectory of the cache dir (because the file share is shared
 	# among *all* phases)
@@ -149,6 +150,7 @@ then
 	CI_REPO_SLUG="$GITHUB_REPOSITORY"
 	CI_JOB_ID="$GITHUB_RUN_ID"
 	CC="${CC:-gcc}"
+	LD="$CC"
 
 	cache_dir="$HOME/none"
 
@@ -184,6 +186,7 @@ linux-clang|linux-gcc)
 	if [ "$jobname" = linux-gcc ]
 	then
 		export CC=gcc-8
+		export LD="$CC"
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3"
 	else
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python2"
@@ -207,6 +210,7 @@ osx-clang|osx-gcc)
 	if [ "$jobname" = osx-gcc ]
 	then
 		export CC=gcc-9
+		export LD="$CC"
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=$(which python3)"
 	else
 		MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=$(which python2)"
@@ -222,12 +226,14 @@ GETTEXT_POISON)
 	;;
 Linux32)
 	CC=gcc
+	LD="$CC"
 	;;
 linux-musl)
 	CC=gcc
+	LD="$CC"
 	MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3 USE_LIBPCRE2=Yes"
 	MAKEFLAGS="$MAKEFLAGS NO_REGEX=Yes ICONV_OMITS_BOM=Yes"
 	;;
 esac
 
-MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
+MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc} LD=${LD:-cc}"
config.mak.in +1 -0
index e6a6d0f941..76ea7e781e 100644
@@ -2,6 +2,7 @@
 # @configure_input@
 
 CC = @CC@
+LD = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
config.mak.uname +6 -0
index c7eba69e54..886ce068f8 100644
@@ -69,6 +69,7 @@ ifeq ($(uname_S),GNU/kFreeBSD)
 endif
 ifeq ($(uname_S),UnixWare)
 	CC = cc
+	LD = $(CC)
 	NEEDS_SOCKET = YesPlease
 	NEEDS_NSL = YesPlease
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
@@ -90,6 +91,7 @@ ifeq ($(uname_S),SCO_SV)
 	endif
 	ifeq ($(uname_R),5)
 		CC = cc
+		LD = $(CC)
 		BASIC_CFLAGS += -Kthread
 	endif
 	NEEDS_SOCKET = YesPlease
@@ -435,6 +437,7 @@ ifeq ($(uname_S),Windows)
 	DEFAULT_HELP_FORMAT = html
 
 	CC = compat/vcbuild/scripts/clink.pl
+	LD = $(CC)
 	AR = compat/vcbuild/scripts/lib.pl
 	CFLAGS =
 	BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
@@ -525,6 +528,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
 	ifeq ($(uname_R).$(uname_V),L17.02)
 		CC += -WRVU=L16.05
 	endif
+	LD = $(CC)
 	# Disable all optimization, seems to result in bad code, with -O or -O2
 	# or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
 	# abends on "git push". Needs more investigation.
@@ -665,8 +669,10 @@ else
 			BASIC_LDFLAGS += -Wl,--large-address-aware
 		endif
 		CC = gcc
+		LD = $(CC)
 		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
 			-fstack-protector-strong
+		BASIC_LDFLAGS += -fstack-protector-strong
 		EXTLIBS += -lntdll
 		INSTALL = /bin/install
 		NO_R_TO_GCC_LINKER = YesPlease
Signature · 1 line
gitgitgadget
#22 lore raw

Re: [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer

In reply to Eric Sunshine

Thank you for your review!

2020年9月10日(木) 4:56 Eric Sunshine <[email protected]>:

Quoted 16 lines
Quoted 9 lines · Kyohei Kadota via GitGitGadget

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

These are reasonable. "cl" feels a little odd, but I can't think of anything better.

Quoted 11 lines

generate-cmdlist.sh category_list () { · line 26

Quoted 6 lines
generate-cmdlist.sh +1 -1
@@ -24,7 +24,7 @@ category_list () {
 get_synopsis () {
        sed -n '
-               /^NAME/,/'"$1"'/H
+               /^NAME/,/'"$1"'/h

This change is not mentioned in the commit message. "H" and "h" are very different commands, so it's difficult, at a glance, to tell if this change is even valid. Some explanation in the commit message would help (if it is indeed valid).

I missed, this change was not needed. It is remnants of trial and error.

#26 lore raw

Re: [PATCH v3 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer

In reply to Kyohei Kadota via GitGitGadget
Quoted 15 lines · Kyohei Kadota via GitGitGadget

From: Kyohei Kadota <[email protected]>

tr(1) of ANSI/POSIX environment, aka APE, don't support \n literal. It's handles only octal(\ooo) or hexadecimal(\xhhhh) numbers.

And its sed(1)'s label is limited to maximum seven characters. Therefore I replaced some labels to drop a character.

* close -> cl
* continue -> cont (cnt is used for count)
* line -> ln
* hered -> hdoc
* shell -> sh
* string -> str

Quoted 2 lines

---

This round, without the confusion between 'h' and 'H' commands, I see nothing funny in it.

Will queue. Thanks.

#28 lore raw

Re: [PATCH v3 2/2] Use $(LD) instead of $(CC) for linking the object files

In reply to Kyohei Kadota via GitGitGadget

Makefile export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir · line 546

Quoted 9 lines · Kyohei Kadota via GitGitGadget
Makefile +1 -0
index 86e5411f39..c0c0c280f0 100644
@@ -543,6 +543,7 @@ export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
 
 # Set our default programs
 CC = cc
+LD = cc

This is good that any system that use 'cc' to link now will reach the same 'cc' via $(LD) instead of $(CC).

But those who customize $(CC) to their taste now needs to override not just CC but also LD. Can we avoid regressing for them? Perhaps default the value of LD to $(CC) instead of hardcoded 'cc'?

Makefile git.sp git.s git.o: EXTRA_CPPFLAGS = \ · line 2126

Quoted 7 lines
Makefile +1 -1
@@ -2121,7 +2122,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = \
 	'-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
 
 git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) \
 		$(filter %.o,$^) $(LIBS)

Are there those who depended on ALL_CFLAGS on the command line when the final linking happens?

For example, people have '-g -O2' on CFLAGS, and that will be included in ALL_CFLAGS and passed to the final linking phase. GNU ld has "-O" option to optimize; when existing systems link with "cc -g -O2 -o $@ ...", it is likely that "-O2" given to "cc" will cause the "-O" option to be passed to underlying "ld".

But with the updated procedure (where LD is 'cc' for them), the linkage will be done without ALL_CFLAGS passed on the command line, and results in "cc -o $@ ...", without "-g -O2".

That sounds like a regression.

Quoted 31 lines
Makefile +5 -5
@@ -2445,17 +2446,17 @@ compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null
 endif
 
 git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
 git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(IMAP_SEND_LDFLAGS) $(LIBS)
 
 git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(LIBS)
 git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
 $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
@@ -2465,7 +2466,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
 	cp $< $@
 
 $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 

Makefile perf: all · line 2757

Quoted 5 lines
Makefile +1 -1
@@ -2753,7 +2754,7 @@ perf: all
 t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
 
 t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
-	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
+	$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)

Likewise for all of the above.

ci/lib.sh then

Quoted 5 lines
ci/lib.sh +0 -0
index 3eefec500d..19c5beb277 100755
@@ -125,6 +125,7 @@ then

All changes to this file to pass LD=cc everywhere CC=cc is passed look good to me.

config.mak.in line 8

Quoted 12 lines
config.mak.in +1 -0
index e6a6d0f941..76ea7e781e 100644
@@ -2,6 +2,7 @@
 # @configure_input@
 
 CC = @CC@
+LD = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@

OK.

Quoted 29 lines
config.mak.uname +3 -0
index c7eba69e54..886ce068f8 100644
@@ -69,6 +69,7 @@ ifeq ($(uname_S),GNU/kFreeBSD)
 endif
 ifeq ($(uname_S),UnixWare)
 	CC = cc
+	LD = $(CC)
 	NEEDS_SOCKET = YesPlease
 	NEEDS_NSL = YesPlease
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
@@ -90,6 +91,7 @@ ifeq ($(uname_S),SCO_SV)
 	endif
 	ifeq ($(uname_R),5)
 		CC = cc
+		LD = $(CC)
 		BASIC_CFLAGS += -Kthread
 	endif
 	NEEDS_SOCKET = YesPlease
@@ -435,6 +437,7 @@ ifeq ($(uname_S),Windows)
 	DEFAULT_HELP_FORMAT = html
 
 	CC = compat/vcbuild/scripts/clink.pl
+	LD = $(CC)
 	AR = compat/vcbuild/scripts/lib.pl
 	CFLAGS =
 	BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE

config.mak.uname ifeq ($(uname_S),NONSTOP_KERNEL) · line 534

Quoted 7 lines
config.mak.uname +1 -0
@@ -525,6 +528,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
 	ifeq ($(uname_R).$(uname_V),L17.02)
 		CC += -WRVU=L16.05
 	endif
+	LD = $(CC)
 	# Disable all optimization, seems to result in bad code, with -O or -O2
 	# or even -O1 (default), /usr/local/libexec/git-core/git-pack-objects
 	# abends on "git push". Needs more investigation.

Ditto.

config.mak.uname else · line 678

Quoted 11 lines
config.mak.uname +2 -0
@@ -665,8 +669,10 @@ else
 			BASIC_LDFLAGS += -Wl,--large-address-aware
 		endif
 		CC = gcc
+		LD = $(CC)
 		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
 			-fstack-protector-strong
+		BASIC_LDFLAGS += -fstack-protector-strong
 		EXTLIBS += -lntdll
 		INSTALL = /bin/install
 		NO_R_TO_GCC_LINKER = YesPlease

This is an example of the problem we discussed earlier for not passing ALL_CFLAGS to the linking phase. I am not sure what the best solution is, though.

Thanks.