git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
* [PATCH 0/4] Fit the building tools to Plan 9 environment
@ 2020-08-06  1:05 KADOTA, Kyohei via GitGitGadget
  2020-08-06  1:05 ` [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile lufia via GitGitGadget
                   ` (5 more replies)
  0 siblings, 6 replies; 29+ messages in thread
From: KADOTA, Kyohei via GitGitGadget @ 2020-08-06  1:05 UTC (permalink / raw)
  To: git; +Cc: KADOTA, Kyohei

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
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.
  2020-08-06  1:05 [PATCH 0/4] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
@ 2020-08-06  1:05 ` lufia via GitGitGadget
  2020-08-06  2:13   ` brian m. carlson
  2020-08-06  1:05 ` [PATCH 2/4] Define TAR_CF and TAR_XF variables " lufia via GitGitGadget
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: lufia via GitGitGadget @ 2020-08-06  1:05 UTC (permalink / raw)
  To: git; +Cc: KADOTA, Kyohei, lufia

From: lufia <lufia@lufia.org>

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

Signed-off-by: lufia <lufia@lufia.org>
---
 config.mak.uname | 12 ++++++------
 git-gui/Makefile |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index c7eba69e54..f3eb2b91a2 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -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
diff --git a/git-gui/Makefile b/git-gui/Makefile
index f10caedaa7..c47603c397 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -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
-- 
gitgitgadget


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 2/4] Define TAR_CF and TAR_XF variables in Makefile
  2020-08-06  1:05 [PATCH 0/4] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
  2020-08-06  1:05 ` [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile lufia via GitGitGadget
@ 2020-08-06  1:05 ` lufia via GitGitGadget
  2020-08-06 17:50   ` Junio C Hamano
  2020-08-06  1:05 ` [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer lufia via GitGitGadget
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: lufia via GitGitGadget @ 2020-08-06  1:05 UTC (permalink / raw)
  To: git; +Cc: KADOTA, Kyohei, lufia

From: lufia <lufia@lufia.org>

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

Signed-off-by: lufia <lufia@lufia.org>
---
 Makefile           | 14 ++++++++------
 templates/Makefile |  6 ++++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 372139f1f2..e222241509 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/templates/Makefile b/templates/Makefile
index d22a71a399..eddc07effb 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -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) -)
-- 
gitgitgadget


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-08-06  1:05 [PATCH 0/4] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
  2020-08-06  1:05 ` [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile lufia via GitGitGadget
  2020-08-06  1:05 ` [PATCH 2/4] Define TAR_CF and TAR_XF variables " lufia via GitGitGadget
@ 2020-08-06  1:05 ` lufia via GitGitGadget
  2020-08-06  2:04   ` brian m. carlson
  2020-08-06  1:05 ` [PATCH 4/4] Use $(LD) instead of $(CC) for linking the object files lufia via GitGitGadget
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 29+ messages in thread
From: lufia via GitGitGadget @ 2020-08-06  1:05 UTC (permalink / raw)
  To: git; +Cc: KADOTA, Kyohei, lufia

From: lufia <lufia@lufia.org>

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

Signed-off-by: lufia <lufia@lufia.org>
---
 GIT-VERSION-GEN     |  2 +-
 generate-cmdlist.sh | 19 ++++++++-----
 t/chainlint.sed     | 66 ++++++++++++++++++++++-----------------------
 3 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 9db2f4feab..a7cc01caf9 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -26,7 +26,7 @@ else
 	VN="$DEF_VER"
 fi
 
-VN=$(expr "$VN" : v*'\(.*\)')
+VN=${VN#v}
 
 if test -r $GVF
 then
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 45fecf8bdf..8344ca6264 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -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
diff --git a/t/chainlint.sed b/t/chainlint.sed
index 70df40e34b..8a25c5b855 100644
--- a/t/chainlint.sed
+++ b/t/chainlint.sed
@@ -117,7 +117,7 @@
 /^[ 	]*!*[ 	]*(..*)[ 	]*[0-9]*[<>|&]/boneline
 
 # multi-line "(...\n...)"
-/^[ 	]*(/bsubshell
+/^[ 	]*(/bsubsh
 
 # innocuous line -- print it and advance to next line
 b
@@ -130,11 +130,11 @@ b
 }
 b
 
-:subshell
+:subsh
 # bare "(" line? -- stash for later printing
 /^[ 	]*([	]*$/ {
 	h
-	bnextline
+	bnextln
 }
 # "(..." line -- split off and stash "(", then process "..." as its own line
 x
@@ -143,7 +143,7 @@ x
 s/(//
 bslurp
 
-:nextline
+:nextln
 N
 s/.*\n//
 
@@ -151,10 +151,10 @@ s/.*\n//
 # incomplete line "...\"
 /\\$/bicmplte
 # multi-line quoted string "...\n..."?
-/"/bdqstring
+/"/bdqstr
 # multi-line quoted string '...\n...'? (but not contraction in string "it's")
 /'/{
-	/"[^'"]*'[^'"]*"/!bsqstring
+	/"[^'"]*'[^'"]*"/!bsqstr
 }
 :folded
 # here-doc -- swallow it
@@ -163,8 +163,8 @@ s/.*\n//
 # before closing ")", "done", "elsif", "else", or "fi" will need to be
 # re-visited to drop "suspect" marking since final line of those constructs
 # legitimately lacks "&&", so "suspect" mark must be removed
-/^[ 	]*#/bnextline
-/^[ 	]*$/bnextline
+/^[ 	]*#/bnextln
+/^[ 	]*$/bnextln
 # in-line comment -- strip it (but not "#" in a string, Bash ${#...} array
 # length, or Perforce "//depot/path#42" revision in filespec)
 /[ 	]#/{
@@ -175,22 +175,22 @@ s/.*\n//
 # multi-line "case ... esac"
 /^[ 	]*case[ 	]..*[ 	]in/bcase
 # multi-line "for ... done" or "while ... done"
-/^[ 	]*for[ 	]..*[ 	]in/bcontinue
-/^[ 	]*while[ 	]/bcontinue
-/^[ 	]*do[ 	]/bcontinue
-/^[ 	]*do[ 	]*$/bcontinue
-/;[ 	]*do/bcontinue
+/^[ 	]*for[ 	]..*[ 	]in/bcont
+/^[ 	]*while[ 	]/bcont
+/^[ 	]*do[ 	]/bcont
+/^[ 	]*do[ 	]*$/bcont
+/;[ 	]*do/bcont
 /^[ 	]*done[ 	]*&&[ 	]*$/bdone
 /^[ 	]*done[ 	]*$/bdone
 /^[ 	]*done[ 	]*[<>|]/bdone
 /^[ 	]*done[ 	]*)/bdone
-/||[ 	]*exit[ 	]/bcontinue
-/||[ 	]*exit[ 	]*$/bcontinue
+/||[ 	]*exit[ 	]/bcont
+/||[ 	]*exit[ 	]*$/bcont
 # multi-line "if...elsif...else...fi"
-/^[ 	]*if[ 	]/bcontinue
-/^[ 	]*then[ 	]/bcontinue
-/^[ 	]*then[ 	]*$/bcontinue
-/;[ 	]*then/bcontinue
+/^[ 	]*if[ 	]/bcont
+/^[ 	]*then[ 	]/bcont
+/^[ 	]*then[ 	]*$/bcont
+/;[ 	]*then/bcont
 /^[ 	]*elif[ 	]/belse
 /^[ 	]*elif[ 	]*$/belse
 /^[ 	]*else[ 	]/belse
@@ -234,10 +234,10 @@ s/.*\n//
 	}
 }
 # line ends with pipe "...|" -- valid; not missing "&&"
-/|[ 	]*$/bcontinue
+/|[ 	]*$/bcont
 # missing end-of-line "&&" -- mark suspect
 /&&[ 	]*$/!s/^/?!AMP?!/
-:continue
+:cont
 # retrieve and print previous line
 x
 n
@@ -250,7 +250,7 @@ s/\\\n//
 bslurp
 
 # check for multi-line double-quoted string "...\n..." -- fold to one line
-:dqstring
+:dqstr
 # remove all quote pairs
 s/"\([^"]*\)"/@!\1@!/g
 # done if no dangling quote
@@ -258,13 +258,13 @@ s/"\([^"]*\)"/@!\1@!/g
 # otherwise, slurp next line and try again
 N
 s/\n//
-bdqstring
+bdqstr
 :dqdone
 s/@!/"/g
 bfolded
 
 # check for multi-line single-quoted string '...\n...' -- fold to one line
-:sqstring
+:sqstr
 # remove all quote pairs
 s/'\([^']*\)'/@!\1@!/g
 # done if no dangling quote
@@ -272,7 +272,7 @@ s/'\([^']*\)'/@!\1@!/g
 # otherwise, slurp next line and try again
 N
 s/\n//
-bsqstring
+bsqstr
 :sqdone
 s/@!/'/g
 bfolded
@@ -282,11 +282,11 @@ bfolded
 :heredoc
 s/^\(.*\)<<[ 	]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
 s/[ 	]*<<//
-:heredsub
+:hdocsub
 N
 /^<\([^>]*\)>.*\n[ 	]*\1[ 	]*$/!{
 	s/\n.*$//
-	bheredsub
+	bhdocsub
 }
 s/^<[^>]*>//
 s/\n.*$//
@@ -305,7 +305,7 @@ bcase
 x
 s/?!AMP?!//
 x
-bcontinue
+bcont
 
 # found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
 # "suspect" from final contained line since that line legitimately lacks "&&"
@@ -321,10 +321,10 @@ bchkchn
 # found nested multi-line "(...\n...)" -- pass through untouched
 :nest
 x
-:nstslurp
+:nstslrp
 n
 # closing ")" on own line -- stop nested slurp
-/^[ 	]*)/bnstclose
+/^[ 	]*)/bnstcl
 # comment -- not closing ")" if in comment
 /^[ 	]*#/bnstcnt
 # "$((...))" -- arithmetic expansion; not closing ")"
@@ -332,11 +332,11 @@ n
 # "$(...)" -- command substitution; not closing ")"
 /\$([^)][^)]*)[^)]*$/bnstcnt
 # closing "...)" -- stop nested slurp
-/)/bnstclose
+/)/bnstcl
 :nstcnt
 x
-bnstslurp
-:nstclose
+bnstslrp
+:nstcl
 s/^/>>/
 # is it "))" which closes nested and parent subshells?
 /)[ 	]*)/bslurp
-- 
gitgitgadget


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 4/4] Use $(LD) instead of $(CC) for linking the object files
  2020-08-06  1:05 [PATCH 0/4] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
                   ` (2 preceding siblings ...)
  2020-08-06  1:05 ` [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer lufia via GitGitGadget
@ 2020-08-06  1:05 ` lufia via GitGitGadget
  2020-08-06  2:23 ` [PATCH 0/4] Fit the building tools to Plan 9 environment brian m. carlson
  2020-09-09 19:47 ` [PATCH v2 0/2] " KADOTA, Kyohei via GitGitGadget
  5 siblings, 0 replies; 29+ messages in thread
From: lufia via GitGitGadget @ 2020-08-06  1:05 UTC (permalink / raw)
  To: git; +Cc: KADOTA, Kyohei, lufia

From: lufia <lufia@lufia.org>

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...

Signed-off-by: lufia <lufia@lufia.org>
---
 .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(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 84a5dcff7a..37b006f371 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -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:
diff --git a/Makefile b/Makefile
index e222241509..a52a05604a 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/ci/lib.sh b/ci/lib.sh
index 3eefec500d..19c5beb277 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -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}"
diff --git a/config.mak.in b/config.mak.in
index e6a6d0f941..76ea7e781e 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -2,6 +2,7 @@
 # @configure_input@
 
 CC = @CC@
+LD = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
diff --git a/config.mak.uname b/config.mak.uname
index f3eb2b91a2..3c4c11eec1 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -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
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-08-06  1:05 ` [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer lufia via GitGitGadget
@ 2020-08-06  2:04   ` brian m. carlson
  2020-08-06 13:49     ` Kyohei Kadota
  2020-08-06 18:10     ` Junio C Hamano
  0 siblings, 2 replies; 29+ messages in thread
From: brian m. carlson @ 2020-08-06  2:04 UTC (permalink / raw)
  To: lufia via GitGitGadget; +Cc: git, KADOTA, Kyohei

[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]

On 2020-08-06 at 01:05:03, lufia via GitGitGadget wrote:
> From: lufia <lufia@lufia.org>
> 
> 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.

> 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
> 
> Signed-off-by: lufia <lufia@lufia.org>

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.

>  command_list () {
> -	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.

>  get_categories () {
> -	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.

>  	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.

> +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
-- 
brian m. carlson: Houston, Texas, US

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.
  2020-08-06  1:05 ` [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile lufia via GitGitGadget
@ 2020-08-06  2:13   ` brian m. carlson
  2020-08-06  4:10     ` Eric Sunshine
  0 siblings, 1 reply; 29+ messages in thread
From: brian m. carlson @ 2020-08-06  2:13 UTC (permalink / raw)
  To: lufia via GitGitGadget; +Cc: git, KADOTA, Kyohei

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

On 2020-08-06 at 01:05:01, lufia via GitGitGadget wrote:
> From: lufia <lufia@lufia.org>
> 
> 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.
-- 
brian m. carlson: Houston, Texas, US

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 0/4] Fit the building tools to Plan 9 environment
  2020-08-06  1:05 [PATCH 0/4] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
                   ` (3 preceding siblings ...)
  2020-08-06  1:05 ` [PATCH 4/4] Use $(LD) instead of $(CC) for linking the object files lufia via GitGitGadget
@ 2020-08-06  2:23 ` brian m. carlson
  2020-09-09 19:47 ` [PATCH v2 0/2] " KADOTA, Kyohei via GitGitGadget
  5 siblings, 0 replies; 29+ messages in thread
From: brian m. carlson @ 2020-08-06  2:23 UTC (permalink / raw)
  To: KADOTA, Kyohei via GitGitGadget; +Cc: git, KADOTA, Kyohei

[-- Attachment #1: Type: text/plain, Size: 784 bytes --]

On 2020-08-06 at 01:05:00, KADOTA, Kyohei via GitGitGadget wrote:
> 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.
-- 
brian m. carlson: Houston, Texas, US

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.
  2020-08-06  2:13   ` brian m. carlson
@ 2020-08-06  4:10     ` Eric Sunshine
  2020-08-06 14:39       ` Kyohei Kadota
  2020-08-06 17:30       ` Junio C Hamano
  0 siblings, 2 replies; 29+ messages in thread
From: Eric Sunshine @ 2020-08-06  4:10 UTC (permalink / raw)
  To: brian m. carlson, lufia via GitGitGadget, Git List, KADOTA, Kyohei

On Wed, Aug 5, 2020 at 10:14 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
> On 2020-08-06 at 01:05:01, lufia via GitGitGadget wrote:
> > 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.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-08-06  2:04   ` brian m. carlson
@ 2020-08-06 13:49     ` Kyohei Kadota
  2020-08-06 23:51       ` brian m. carlson
  2020-08-06 18:10     ` Junio C Hamano
  1 sibling, 1 reply; 29+ messages in thread
From: Kyohei Kadota @ 2020-08-06 13:49 UTC (permalink / raw)
  To: brian m. carlson, lufia via GitGitGadget, git, KADOTA, Kyohei

> On 2020-08-06 at 01:05:03, lufia via GitGitGadget wrote:
> > From: lufia <lufia@lufia.org>
> >
> > 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.

> > 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
> >
> > Signed-off-by: lufia <lufia@lufia.org>
>
> 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.

> >  command_list () {
> > -     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

> >  get_categories () {
> > -     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.

> >       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.

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

> > +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.

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

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.
  2020-08-06  4:10     ` Eric Sunshine
@ 2020-08-06 14:39       ` Kyohei Kadota
  2020-08-06 17:30       ` Junio C Hamano
  1 sibling, 0 replies; 29+ messages in thread
From: Kyohei Kadota @ 2020-08-06 14:39 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: brian m. carlson, lufia via GitGitGadget, Git List

> On Wed, Aug 5, 2020 at 10:14 PM brian m. carlson
> <sandals@crustytoothpaste.net> wrote:
> > On 2020-08-06 at 01:05:01, lufia via GitGitGadget wrote:
> > > 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.

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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.
  2020-08-06  4:10     ` Eric Sunshine
  2020-08-06 14:39       ` Kyohei Kadota
@ 2020-08-06 17:30       ` Junio C Hamano
  2020-08-10  9:04         ` Kyohei Kadota
  1 sibling, 1 reply; 29+ messages in thread
From: Junio C Hamano @ 2020-08-06 17:30 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: brian m. carlson, lufia via GitGitGadget, Git List, KADOTA, Kyohei

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Wed, Aug 5, 2020 at 10:14 PM brian m. carlson
> <sandals@crustytoothpaste.net> wrote:
>> On 2020-08-06 at 01:05:01, lufia via GitGitGadget wrote:
>> > 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.

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.


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 2/4] Define TAR_CF and TAR_XF variables in Makefile
  2020-08-06  1:05 ` [PATCH 2/4] Define TAR_CF and TAR_XF variables " lufia via GitGitGadget
@ 2020-08-06 17:50   ` Junio C Hamano
  0 siblings, 0 replies; 29+ messages in thread
From: Junio C Hamano @ 2020-08-06 17:50 UTC (permalink / raw)
  To: lufia via GitGitGadget; +Cc: git, KADOTA, Kyohei

"lufia via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: lufia <lufia@lufia.org>

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

> 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.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-08-06  2:04   ` brian m. carlson
  2020-08-06 13:49     ` Kyohei Kadota
@ 2020-08-06 18:10     ` Junio C Hamano
  2020-08-10 10:53       ` Kyohei Kadota
  1 sibling, 1 reply; 29+ messages in thread
From: Junio C Hamano @ 2020-08-06 18:10 UTC (permalink / raw)
  To: brian m. carlson; +Cc: lufia via GitGitGadget, git, KADOTA, Kyohei

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> 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.

>>  command_list () {
>> -	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.

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 9db2f4feab..a7cc01caf9 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -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".

>>  get_categories () {
>> -	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.

>> +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
>   }

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.

> 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.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-08-06 13:49     ` Kyohei Kadota
@ 2020-08-06 23:51       ` brian m. carlson
  2020-08-06 23:57         ` Eric Sunshine
  0 siblings, 1 reply; 29+ messages in thread
From: brian m. carlson @ 2020-08-06 23:51 UTC (permalink / raw)
  To: Kyohei Kadota; +Cc: lufia via GitGitGadget, git

[-- Attachment #1: Type: text/plain, Size: 864 bytes --]

On 2020-08-06 at 13:49:43, Kyohei Kadota wrote:
> 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.

> 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.
-- 
brian m. carlson: Houston, Texas, US

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-08-06 23:51       ` brian m. carlson
@ 2020-08-06 23:57         ` Eric Sunshine
  0 siblings, 0 replies; 29+ messages in thread
From: Eric Sunshine @ 2020-08-06 23:57 UTC (permalink / raw)
  To: brian m. carlson, Kyohei Kadota, lufia via GitGitGadget, Git List

On Thu, Aug 6, 2020 at 7:52 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
> On 2020-08-06 at 13:49:43, Kyohei Kadota wrote:
> > 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

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile.
  2020-08-06 17:30       ` Junio C Hamano
@ 2020-08-10  9:04         ` Kyohei Kadota
  0 siblings, 0 replies; 29+ messages in thread
From: Kyohei Kadota @ 2020-08-10  9:04 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Eric Sunshine, brian m. carlson, lufia via GitGitGadget, Git List

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 <gitster@pobox.com>:
>
> Eric Sunshine <sunshine@sunshineco.com> writes:
>
> > On Wed, Aug 5, 2020 at 10:14 PM brian m. carlson
> > <sandals@crustytoothpaste.net> wrote:
> >> On 2020-08-06 at 01:05:01, lufia via GitGitGadget wrote:
> >> > 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.
>
> 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.
>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-08-06 18:10     ` Junio C Hamano
@ 2020-08-10 10:53       ` Kyohei Kadota
  0 siblings, 0 replies; 29+ messages in thread
From: Kyohei Kadota @ 2020-08-10 10:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: brian m. carlson, lufia via GitGitGadget, Git List

>
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
>
> > 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.
>
> >>  command_list () {
> >> -    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.
>
> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
> index 9db2f4feab..a7cc01caf9 100755
> --- a/GIT-VERSION-GEN
> +++ b/GIT-VERSION-GEN
> @@ -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".

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

> >>  get_categories () {
> >> -    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.

> >> +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
> >   }
>
> 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.
>
> > 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.

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.

> 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.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 0/2] Fit the building tools to Plan 9 environment
  2020-08-06  1:05 [PATCH 0/4] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
                   ` (4 preceding siblings ...)
  2020-08-06  2:23 ` [PATCH 0/4] Fit the building tools to Plan 9 environment brian m. carlson
@ 2020-09-09 19:47 ` KADOTA, Kyohei via GitGitGadget
  2020-09-09 19:47   ` [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
                     ` (2 more replies)
  5 siblings, 3 replies; 29+ messages in thread
From: KADOTA, Kyohei via GitGitGadget @ 2020-09-09 19:47 UTC (permalink / raw)
  To: git; +Cc: KADOTA, Kyohei

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 <lufia@lufia.org>
     +Author: Kyohei Kadota <lufia@lufia.org>
      
       ## 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 <lufia@lufia.org>
     -
     - ## 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 <lufia@lufia.org>
      
       ## 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 <lufia@lufia.org>
     +Author: Kyohei Kadota <lufia@lufia.org>
      
       ## 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 <lufia@lufia.org>
     +    Signed-off-by: Kyohei Kadota <lufia@lufia.org>
      
       ## .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)

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-09-09 19:47 ` [PATCH v2 0/2] " KADOTA, Kyohei via GitGitGadget
@ 2020-09-09 19:47   ` Kyohei Kadota via GitGitGadget
  2020-09-09 19:56     ` Eric Sunshine
  2020-09-09 19:47   ` [PATCH v2 2/2] Use $(LD) instead of $(CC) for linking the object files Kyohei Kadota via GitGitGadget
  2020-09-10  2:17   ` [PATCH v3 0/2] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
  2 siblings, 1 reply; 29+ messages in thread
From: Kyohei Kadota via GitGitGadget @ 2020-09-09 19:47 UTC (permalink / raw)
  To: git; +Cc: KADOTA, Kyohei, Kyohei Kadota

From: Kyohei Kadota <lufia@lufia.org>

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

Signed-off-by: Kyohei Kadota <lufia@lufia.org>
---
 generate-cmdlist.sh |  4 +--
 t/chainlint.sed     | 66 ++++++++++++++++++++++-----------------------
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 45fecf8bdf..4031623b0e 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -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")/
diff --git a/t/chainlint.sed b/t/chainlint.sed
index 70df40e34b..8a25c5b855 100644
--- a/t/chainlint.sed
+++ b/t/chainlint.sed
@@ -117,7 +117,7 @@
 /^[ 	]*!*[ 	]*(..*)[ 	]*[0-9]*[<>|&]/boneline
 
 # multi-line "(...\n...)"
-/^[ 	]*(/bsubshell
+/^[ 	]*(/bsubsh
 
 # innocuous line -- print it and advance to next line
 b
@@ -130,11 +130,11 @@ b
 }
 b
 
-:subshell
+:subsh
 # bare "(" line? -- stash for later printing
 /^[ 	]*([	]*$/ {
 	h
-	bnextline
+	bnextln
 }
 # "(..." line -- split off and stash "(", then process "..." as its own line
 x
@@ -143,7 +143,7 @@ x
 s/(//
 bslurp
 
-:nextline
+:nextln
 N
 s/.*\n//
 
@@ -151,10 +151,10 @@ s/.*\n//
 # incomplete line "...\"
 /\\$/bicmplte
 # multi-line quoted string "...\n..."?
-/"/bdqstring
+/"/bdqstr
 # multi-line quoted string '...\n...'? (but not contraction in string "it's")
 /'/{
-	/"[^'"]*'[^'"]*"/!bsqstring
+	/"[^'"]*'[^'"]*"/!bsqstr
 }
 :folded
 # here-doc -- swallow it
@@ -163,8 +163,8 @@ s/.*\n//
 # before closing ")", "done", "elsif", "else", or "fi" will need to be
 # re-visited to drop "suspect" marking since final line of those constructs
 # legitimately lacks "&&", so "suspect" mark must be removed
-/^[ 	]*#/bnextline
-/^[ 	]*$/bnextline
+/^[ 	]*#/bnextln
+/^[ 	]*$/bnextln
 # in-line comment -- strip it (but not "#" in a string, Bash ${#...} array
 # length, or Perforce "//depot/path#42" revision in filespec)
 /[ 	]#/{
@@ -175,22 +175,22 @@ s/.*\n//
 # multi-line "case ... esac"
 /^[ 	]*case[ 	]..*[ 	]in/bcase
 # multi-line "for ... done" or "while ... done"
-/^[ 	]*for[ 	]..*[ 	]in/bcontinue
-/^[ 	]*while[ 	]/bcontinue
-/^[ 	]*do[ 	]/bcontinue
-/^[ 	]*do[ 	]*$/bcontinue
-/;[ 	]*do/bcontinue
+/^[ 	]*for[ 	]..*[ 	]in/bcont
+/^[ 	]*while[ 	]/bcont
+/^[ 	]*do[ 	]/bcont
+/^[ 	]*do[ 	]*$/bcont
+/;[ 	]*do/bcont
 /^[ 	]*done[ 	]*&&[ 	]*$/bdone
 /^[ 	]*done[ 	]*$/bdone
 /^[ 	]*done[ 	]*[<>|]/bdone
 /^[ 	]*done[ 	]*)/bdone
-/||[ 	]*exit[ 	]/bcontinue
-/||[ 	]*exit[ 	]*$/bcontinue
+/||[ 	]*exit[ 	]/bcont
+/||[ 	]*exit[ 	]*$/bcont
 # multi-line "if...elsif...else...fi"
-/^[ 	]*if[ 	]/bcontinue
-/^[ 	]*then[ 	]/bcontinue
-/^[ 	]*then[ 	]*$/bcontinue
-/;[ 	]*then/bcontinue
+/^[ 	]*if[ 	]/bcont
+/^[ 	]*then[ 	]/bcont
+/^[ 	]*then[ 	]*$/bcont
+/;[ 	]*then/bcont
 /^[ 	]*elif[ 	]/belse
 /^[ 	]*elif[ 	]*$/belse
 /^[ 	]*else[ 	]/belse
@@ -234,10 +234,10 @@ s/.*\n//
 	}
 }
 # line ends with pipe "...|" -- valid; not missing "&&"
-/|[ 	]*$/bcontinue
+/|[ 	]*$/bcont
 # missing end-of-line "&&" -- mark suspect
 /&&[ 	]*$/!s/^/?!AMP?!/
-:continue
+:cont
 # retrieve and print previous line
 x
 n
@@ -250,7 +250,7 @@ s/\\\n//
 bslurp
 
 # check for multi-line double-quoted string "...\n..." -- fold to one line
-:dqstring
+:dqstr
 # remove all quote pairs
 s/"\([^"]*\)"/@!\1@!/g
 # done if no dangling quote
@@ -258,13 +258,13 @@ s/"\([^"]*\)"/@!\1@!/g
 # otherwise, slurp next line and try again
 N
 s/\n//
-bdqstring
+bdqstr
 :dqdone
 s/@!/"/g
 bfolded
 
 # check for multi-line single-quoted string '...\n...' -- fold to one line
-:sqstring
+:sqstr
 # remove all quote pairs
 s/'\([^']*\)'/@!\1@!/g
 # done if no dangling quote
@@ -272,7 +272,7 @@ s/'\([^']*\)'/@!\1@!/g
 # otherwise, slurp next line and try again
 N
 s/\n//
-bsqstring
+bsqstr
 :sqdone
 s/@!/'/g
 bfolded
@@ -282,11 +282,11 @@ bfolded
 :heredoc
 s/^\(.*\)<<[ 	]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
 s/[ 	]*<<//
-:heredsub
+:hdocsub
 N
 /^<\([^>]*\)>.*\n[ 	]*\1[ 	]*$/!{
 	s/\n.*$//
-	bheredsub
+	bhdocsub
 }
 s/^<[^>]*>//
 s/\n.*$//
@@ -305,7 +305,7 @@ bcase
 x
 s/?!AMP?!//
 x
-bcontinue
+bcont
 
 # found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
 # "suspect" from final contained line since that line legitimately lacks "&&"
@@ -321,10 +321,10 @@ bchkchn
 # found nested multi-line "(...\n...)" -- pass through untouched
 :nest
 x
-:nstslurp
+:nstslrp
 n
 # closing ")" on own line -- stop nested slurp
-/^[ 	]*)/bnstclose
+/^[ 	]*)/bnstcl
 # comment -- not closing ")" if in comment
 /^[ 	]*#/bnstcnt
 # "$((...))" -- arithmetic expansion; not closing ")"
@@ -332,11 +332,11 @@ n
 # "$(...)" -- command substitution; not closing ")"
 /\$([^)][^)]*)[^)]*$/bnstcnt
 # closing "...)" -- stop nested slurp
-/)/bnstclose
+/)/bnstcl
 :nstcnt
 x
-bnstslurp
-:nstclose
+bnstslrp
+:nstcl
 s/^/>>/
 # is it "))" which closes nested and parent subshells?
 /)[ 	]*)/bslurp
-- 
gitgitgadget


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 2/2] Use $(LD) instead of $(CC) for linking the object files
  2020-09-09 19:47 ` [PATCH v2 0/2] " KADOTA, Kyohei via GitGitGadget
  2020-09-09 19:47   ` [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
@ 2020-09-09 19:47   ` Kyohei Kadota via GitGitGadget
  2020-09-10  2:17   ` [PATCH v3 0/2] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
  2 siblings, 0 replies; 29+ messages in thread
From: Kyohei Kadota via GitGitGadget @ 2020-09-09 19:47 UTC (permalink / raw)
  To: git; +Cc: KADOTA, Kyohei, Kyohei Kadota

From: Kyohei Kadota <lufia@lufia.org>

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...

Signed-off-by: Kyohei Kadota <lufia@lufia.org>
---
 .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(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 30425404eb..5ece32d4fa 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -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:
diff --git a/Makefile b/Makefile
index 86e5411f39..c0c0c280f0 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/ci/lib.sh b/ci/lib.sh
index 3eefec500d..19c5beb277 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -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}"
diff --git a/config.mak.in b/config.mak.in
index e6a6d0f941..76ea7e781e 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -2,6 +2,7 @@
 # @configure_input@
 
 CC = @CC@
+LD = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
diff --git a/config.mak.uname b/config.mak.uname
index c7eba69e54..886ce068f8 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -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
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-09-09 19:47   ` [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
@ 2020-09-09 19:56     ` Eric Sunshine
  2020-09-09 20:34       ` Junio C Hamano
  2020-09-10  0:35       ` Kyohei Kadota
  0 siblings, 2 replies; 29+ messages in thread
From: Eric Sunshine @ 2020-09-09 19:56 UTC (permalink / raw)
  To: Kyohei Kadota via GitGitGadget; +Cc: Git List, KADOTA, Kyohei

On Wed, Sep 9, 2020 at 3:48 PM Kyohei Kadota via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> 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.

> diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
> @@ -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).

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-09-09 19:56     ` Eric Sunshine
@ 2020-09-09 20:34       ` Junio C Hamano
  2020-09-10  0:35       ` Kyohei Kadota
  1 sibling, 0 replies; 29+ messages in thread
From: Junio C Hamano @ 2020-09-09 20:34 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Kyohei Kadota via GitGitGadget, Git List, KADOTA, Kyohei

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Wed, Sep 9, 2020 at 3:48 PM Kyohei Kadota via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
>> 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.
>
>> diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
>> @@ -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.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-09-09 19:56     ` Eric Sunshine
  2020-09-09 20:34       ` Junio C Hamano
@ 2020-09-10  0:35       ` Kyohei Kadota
  1 sibling, 0 replies; 29+ messages in thread
From: Kyohei Kadota @ 2020-09-10  0:35 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List

Thank you for your review!

2020年9月10日(木) 4:56 Eric Sunshine <sunshine@sunshineco.com>:
>
> On Wed, Sep 9, 2020 at 3:48 PM Kyohei Kadota via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > 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.
>
> > diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
> > @@ -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.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 0/2] Fit the building tools to Plan 9 environment
  2020-09-09 19:47 ` [PATCH v2 0/2] " KADOTA, Kyohei via GitGitGadget
  2020-09-09 19:47   ` [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
  2020-09-09 19:47   ` [PATCH v2 2/2] Use $(LD) instead of $(CC) for linking the object files Kyohei Kadota via GitGitGadget
@ 2020-09-10  2:17   ` KADOTA, Kyohei via GitGitGadget
  2020-09-10  2:17     ` [PATCH v3 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
  2020-09-10  2:17     ` [PATCH v3 2/2] Use $(LD) instead of $(CC) for linking the object files Kyohei Kadota via GitGitGadget
  2 siblings, 2 replies; 29+ messages in thread
From: KADOTA, Kyohei via GitGitGadget @ 2020-09-10  2:17 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, KADOTA, Kyohei

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

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-09-10  2:17   ` [PATCH v3 0/2] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
@ 2020-09-10  2:17     ` Kyohei Kadota via GitGitGadget
  2020-09-10  5:13       ` Junio C Hamano
  2020-09-10  2:17     ` [PATCH v3 2/2] Use $(LD) instead of $(CC) for linking the object files Kyohei Kadota via GitGitGadget
  1 sibling, 1 reply; 29+ messages in thread
From: Kyohei Kadota via GitGitGadget @ 2020-09-10  2:17 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, KADOTA, Kyohei, Kyohei Kadota

From: Kyohei Kadota <lufia@lufia.org>

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

Signed-off-by: Kyohei Kadota <lufia@lufia.org>
---
 generate-cmdlist.sh |  2 +-
 t/chainlint.sed     | 66 ++++++++++++++++++++++-----------------------
 2 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 45fecf8bdf..9dbbb08e70 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -10,7 +10,7 @@ command_list () {
 }
 
 get_categories () {
-	tr ' ' '\n'|
+	tr ' ' '\012'|
 	grep -v '^$' |
 	sort |
 	uniq
diff --git a/t/chainlint.sed b/t/chainlint.sed
index 70df40e34b..8a25c5b855 100644
--- a/t/chainlint.sed
+++ b/t/chainlint.sed
@@ -117,7 +117,7 @@
 /^[ 	]*!*[ 	]*(..*)[ 	]*[0-9]*[<>|&]/boneline
 
 # multi-line "(...\n...)"
-/^[ 	]*(/bsubshell
+/^[ 	]*(/bsubsh
 
 # innocuous line -- print it and advance to next line
 b
@@ -130,11 +130,11 @@ b
 }
 b
 
-:subshell
+:subsh
 # bare "(" line? -- stash for later printing
 /^[ 	]*([	]*$/ {
 	h
-	bnextline
+	bnextln
 }
 # "(..." line -- split off and stash "(", then process "..." as its own line
 x
@@ -143,7 +143,7 @@ x
 s/(//
 bslurp
 
-:nextline
+:nextln
 N
 s/.*\n//
 
@@ -151,10 +151,10 @@ s/.*\n//
 # incomplete line "...\"
 /\\$/bicmplte
 # multi-line quoted string "...\n..."?
-/"/bdqstring
+/"/bdqstr
 # multi-line quoted string '...\n...'? (but not contraction in string "it's")
 /'/{
-	/"[^'"]*'[^'"]*"/!bsqstring
+	/"[^'"]*'[^'"]*"/!bsqstr
 }
 :folded
 # here-doc -- swallow it
@@ -163,8 +163,8 @@ s/.*\n//
 # before closing ")", "done", "elsif", "else", or "fi" will need to be
 # re-visited to drop "suspect" marking since final line of those constructs
 # legitimately lacks "&&", so "suspect" mark must be removed
-/^[ 	]*#/bnextline
-/^[ 	]*$/bnextline
+/^[ 	]*#/bnextln
+/^[ 	]*$/bnextln
 # in-line comment -- strip it (but not "#" in a string, Bash ${#...} array
 # length, or Perforce "//depot/path#42" revision in filespec)
 /[ 	]#/{
@@ -175,22 +175,22 @@ s/.*\n//
 # multi-line "case ... esac"
 /^[ 	]*case[ 	]..*[ 	]in/bcase
 # multi-line "for ... done" or "while ... done"
-/^[ 	]*for[ 	]..*[ 	]in/bcontinue
-/^[ 	]*while[ 	]/bcontinue
-/^[ 	]*do[ 	]/bcontinue
-/^[ 	]*do[ 	]*$/bcontinue
-/;[ 	]*do/bcontinue
+/^[ 	]*for[ 	]..*[ 	]in/bcont
+/^[ 	]*while[ 	]/bcont
+/^[ 	]*do[ 	]/bcont
+/^[ 	]*do[ 	]*$/bcont
+/;[ 	]*do/bcont
 /^[ 	]*done[ 	]*&&[ 	]*$/bdone
 /^[ 	]*done[ 	]*$/bdone
 /^[ 	]*done[ 	]*[<>|]/bdone
 /^[ 	]*done[ 	]*)/bdone
-/||[ 	]*exit[ 	]/bcontinue
-/||[ 	]*exit[ 	]*$/bcontinue
+/||[ 	]*exit[ 	]/bcont
+/||[ 	]*exit[ 	]*$/bcont
 # multi-line "if...elsif...else...fi"
-/^[ 	]*if[ 	]/bcontinue
-/^[ 	]*then[ 	]/bcontinue
-/^[ 	]*then[ 	]*$/bcontinue
-/;[ 	]*then/bcontinue
+/^[ 	]*if[ 	]/bcont
+/^[ 	]*then[ 	]/bcont
+/^[ 	]*then[ 	]*$/bcont
+/;[ 	]*then/bcont
 /^[ 	]*elif[ 	]/belse
 /^[ 	]*elif[ 	]*$/belse
 /^[ 	]*else[ 	]/belse
@@ -234,10 +234,10 @@ s/.*\n//
 	}
 }
 # line ends with pipe "...|" -- valid; not missing "&&"
-/|[ 	]*$/bcontinue
+/|[ 	]*$/bcont
 # missing end-of-line "&&" -- mark suspect
 /&&[ 	]*$/!s/^/?!AMP?!/
-:continue
+:cont
 # retrieve and print previous line
 x
 n
@@ -250,7 +250,7 @@ s/\\\n//
 bslurp
 
 # check for multi-line double-quoted string "...\n..." -- fold to one line
-:dqstring
+:dqstr
 # remove all quote pairs
 s/"\([^"]*\)"/@!\1@!/g
 # done if no dangling quote
@@ -258,13 +258,13 @@ s/"\([^"]*\)"/@!\1@!/g
 # otherwise, slurp next line and try again
 N
 s/\n//
-bdqstring
+bdqstr
 :dqdone
 s/@!/"/g
 bfolded
 
 # check for multi-line single-quoted string '...\n...' -- fold to one line
-:sqstring
+:sqstr
 # remove all quote pairs
 s/'\([^']*\)'/@!\1@!/g
 # done if no dangling quote
@@ -272,7 +272,7 @@ s/'\([^']*\)'/@!\1@!/g
 # otherwise, slurp next line and try again
 N
 s/\n//
-bsqstring
+bsqstr
 :sqdone
 s/@!/'/g
 bfolded
@@ -282,11 +282,11 @@ bfolded
 :heredoc
 s/^\(.*\)<<[ 	]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
 s/[ 	]*<<//
-:heredsub
+:hdocsub
 N
 /^<\([^>]*\)>.*\n[ 	]*\1[ 	]*$/!{
 	s/\n.*$//
-	bheredsub
+	bhdocsub
 }
 s/^<[^>]*>//
 s/\n.*$//
@@ -305,7 +305,7 @@ bcase
 x
 s/?!AMP?!//
 x
-bcontinue
+bcont
 
 # found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
 # "suspect" from final contained line since that line legitimately lacks "&&"
@@ -321,10 +321,10 @@ bchkchn
 # found nested multi-line "(...\n...)" -- pass through untouched
 :nest
 x
-:nstslurp
+:nstslrp
 n
 # closing ")" on own line -- stop nested slurp
-/^[ 	]*)/bnstclose
+/^[ 	]*)/bnstcl
 # comment -- not closing ")" if in comment
 /^[ 	]*#/bnstcnt
 # "$((...))" -- arithmetic expansion; not closing ")"
@@ -332,11 +332,11 @@ n
 # "$(...)" -- command substitution; not closing ")"
 /\$([^)][^)]*)[^)]*$/bnstcnt
 # closing "...)" -- stop nested slurp
-/)/bnstclose
+/)/bnstcl
 :nstcnt
 x
-bnstslurp
-:nstclose
+bnstslrp
+:nstcl
 s/^/>>/
 # is it "))" which closes nested and parent subshells?
 /)[ 	]*)/bslurp
-- 
gitgitgadget


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v3 2/2] Use $(LD) instead of $(CC) for linking the object files
  2020-09-10  2:17   ` [PATCH v3 0/2] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
  2020-09-10  2:17     ` [PATCH v3 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
@ 2020-09-10  2:17     ` Kyohei Kadota via GitGitGadget
  2020-09-10  5:31       ` Junio C Hamano
  1 sibling, 1 reply; 29+ messages in thread
From: Kyohei Kadota via GitGitGadget @ 2020-09-10  2:17 UTC (permalink / raw)
  To: git; +Cc: Eric Sunshine, KADOTA, Kyohei, Kyohei Kadota

From: Kyohei Kadota <lufia@lufia.org>

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...

Signed-off-by: Kyohei Kadota <lufia@lufia.org>
---
 .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(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 30425404eb..5ece32d4fa 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -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:
diff --git a/Makefile b/Makefile
index 86e5411f39..c0c0c280f0 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/ci/lib.sh b/ci/lib.sh
index 3eefec500d..19c5beb277 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -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}"
diff --git a/config.mak.in b/config.mak.in
index e6a6d0f941..76ea7e781e 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -2,6 +2,7 @@
 # @configure_input@
 
 CC = @CC@
+LD = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
diff --git a/config.mak.uname b/config.mak.uname
index c7eba69e54..886ce068f8 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -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
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v3 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer
  2020-09-10  2:17     ` [PATCH v3 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
@ 2020-09-10  5:13       ` Junio C Hamano
  0 siblings, 0 replies; 29+ messages in thread
From: Junio C Hamano @ 2020-09-10  5:13 UTC (permalink / raw)
  To: Kyohei Kadota via GitGitGadget; +Cc: git, Eric Sunshine, KADOTA, Kyohei

"Kyohei Kadota via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Kyohei Kadota <lufia@lufia.org>
>
> 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
>
> Signed-off-by: Kyohei Kadota <lufia@lufia.org>
> ---

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

Will queue.  Thanks.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v3 2/2] Use $(LD) instead of $(CC) for linking the object files
  2020-09-10  2:17     ` [PATCH v3 2/2] Use $(LD) instead of $(CC) for linking the object files Kyohei Kadota via GitGitGadget
@ 2020-09-10  5:31       ` Junio C Hamano
  0 siblings, 0 replies; 29+ messages in thread
From: Junio C Hamano @ 2020-09-10  5:31 UTC (permalink / raw)
  To: Kyohei Kadota via GitGitGadget; +Cc: git, Eric Sunshine, KADOTA, Kyohei

"Kyohei Kadota via GitGitGadget" <gitgitgadget@gmail.com> writes:

> diff --git a/Makefile b/Makefile
> index 86e5411f39..c0c0c280f0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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'?

> @@ -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.

> @@ -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)
>
> @@ -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.

> diff --git a/ci/lib.sh b/ci/lib.sh
> index 3eefec500d..19c5beb277 100755
> --- a/ci/lib.sh
> +++ b/ci/lib.sh
> @@ -125,6 +125,7 @@ then

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

> diff --git a/config.mak.in b/config.mak.in
> index e6a6d0f941..76ea7e781e 100644
> --- a/config.mak.in
> +++ b/config.mak.in
> @@ -2,6 +2,7 @@
>  # @configure_input@
>  
>  CC = @CC@
> +LD = @CC@
>  CFLAGS = @CFLAGS@
>  CPPFLAGS = @CPPFLAGS@
>  LDFLAGS = @LDFLAGS@

OK.

> diff --git a/config.mak.uname b/config.mak.uname
> index c7eba69e54..886ce068f8 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -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.

Ditto.

> @@ -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.

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2020-09-10  5:31 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06  1:05 [PATCH 0/4] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
2020-08-06  1:05 ` [PATCH 1/4] Use $(SHELL_PATH) instead of sh in Makefile lufia via GitGitGadget
2020-08-06  2:13   ` brian m. carlson
2020-08-06  4:10     ` Eric Sunshine
2020-08-06 14:39       ` Kyohei Kadota
2020-08-06 17:30       ` Junio C Hamano
2020-08-10  9:04         ` Kyohei Kadota
2020-08-06  1:05 ` [PATCH 2/4] Define TAR_CF and TAR_XF variables " lufia via GitGitGadget
2020-08-06 17:50   ` Junio C Hamano
2020-08-06  1:05 ` [PATCH 3/4] Fit to Plan 9's ANSI/POSIX compatibility layer lufia via GitGitGadget
2020-08-06  2:04   ` brian m. carlson
2020-08-06 13:49     ` Kyohei Kadota
2020-08-06 23:51       ` brian m. carlson
2020-08-06 23:57         ` Eric Sunshine
2020-08-06 18:10     ` Junio C Hamano
2020-08-10 10:53       ` Kyohei Kadota
2020-08-06  1:05 ` [PATCH 4/4] Use $(LD) instead of $(CC) for linking the object files lufia via GitGitGadget
2020-08-06  2:23 ` [PATCH 0/4] Fit the building tools to Plan 9 environment brian m. carlson
2020-09-09 19:47 ` [PATCH v2 0/2] " KADOTA, Kyohei via GitGitGadget
2020-09-09 19:47   ` [PATCH v2 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
2020-09-09 19:56     ` Eric Sunshine
2020-09-09 20:34       ` Junio C Hamano
2020-09-10  0:35       ` Kyohei Kadota
2020-09-09 19:47   ` [PATCH v2 2/2] Use $(LD) instead of $(CC) for linking the object files Kyohei Kadota via GitGitGadget
2020-09-10  2:17   ` [PATCH v3 0/2] Fit the building tools to Plan 9 environment KADOTA, Kyohei via GitGitGadget
2020-09-10  2:17     ` [PATCH v3 1/2] Fit to Plan 9's ANSI/POSIX compatibility layer Kyohei Kadota via GitGitGadget
2020-09-10  5:13       ` Junio C Hamano
2020-09-10  2:17     ` [PATCH v3 2/2] Use $(LD) instead of $(CC) for linking the object files Kyohei Kadota via GitGitGadget
2020-09-10  5:31       ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git