git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* shared lib+symlinks patch for cygwin
@ 2008-06-22  7:56 Reini Urban
  2008-06-22  8:10 ` Brian Dessent
  0 siblings, 1 reply; 3+ messages in thread
From: Reini Urban @ 2008-06-22  7:56 UTC (permalink / raw)
  To: git

Attached is a semi-complete patch for a significant space reduction,
esp. on cygwin where file hardlinks do not work as on linux.
old bindir 5.8MB, new 2.7MB

$ du git-1.5.6-1/inst/usr/bin git-1.5.6-2/inst/usr/bin
5.8M    git-1.5.6-1/inst/usr/bin
2.7M    git-1.5.6-2/inst/usr/bin

First it links to a shared lib for all builtins (cygwin only),
second it uses symlinks instead of hardlinks (cygwin only).

mingw could also take this approach but I cannot test this.
A shared lib for all platforms should IMHO also be considered.

The first dll approach works fine.
The second has open problems with git-gui, because the native windows app
cannot handle symlinks.
file exists returns true but we cannot call it. So I tried to change
the calling sequence from git-config to git config, but Tcl is not my
native language. Maybe someone can help.

For reference:
I found an old shared libgit patch at
  http://article.gmane.org/gmane.comp.version-control.git/8680/match=shared+lib


--- origsrc/git-1.5.6/Makefile	2008-06-19 00:49:49.000000000 +0200
+++ src/git-1.5.6/Makefile	2008-06-22 09:08:22.812500000 +0200
@@ -211,12 +211,12 @@
 AR = ar
 RM = rm -f
 TAR = tar
+LN = ln
 FIND = find
 INSTALL = install
 RPMBUILD = rpmbuild
 TCL_PATH = tclsh
 TCLTK_PATH = wish
-
 export TCL_PATH TCLTK_PATH

 # sparse is architecture-neutral, which means that we need to tell it
@@ -639,20 +639,20 @@
 endif
 ifeq ($(uname_O),Cygwin)
 	NO_D_TYPE_IN_DIRENT = YesPlease
-	NO_D_INO_IN_DIRENT = YesPlease
 	NO_STRCASESTR = YesPlease
 	NO_MEMMEM = YesPlease
-	NO_SYMLINK_HEAD = YesPlease
 	NEEDS_LIBICONV = YesPlease
 	NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
-	NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
 	OLD_ICONV = UnfortunatelyYes
 	# There are conflicting reports about this.
 	# On some boxes NO_MMAP is needed, and not so elsewhere.
 	# Try commenting this out if you suspect MMAP is more efficient
-	NO_MMAP = YesPlease
+#	NO_MMAP = YesPlease
 	NO_IPV6 = YesPlease
 	X = .exe
+	LIB_FILE=cyggit.dll
+	ALL_LDFLAGS += -Wl,--enable-auto-import
+	LN = ln -s
 endif
 ifeq ($(uname_S),FreeBSD)
 	NEEDS_LIBICONV = YesPlease
@@ -1040,7 +1040,7 @@
 		'-DGIT_INFO_PATH="$(infodir_SQ)"' $<

 $(BUILT_INS): git$X
-	$(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@
+	$(QUIET_BUILT_IN)$(RM) $@ && $(LN) git$X $@

 common-cmds.h: ./generate-cmdlist.sh command-list.txt

@@ -1169,8 +1171,17 @@
 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
 builtin-revert.o wt-status.o: wt-status.h

+ifneq (,$(findstring .dll,$(LIB_FILE)))
+$(LIB_FILE): $(LIB_OBJS) builtin-fetch-pack.o builtin-send-pack.o $(XDIFF_LIB)
+	$(QUIET_CC)$(RM) git-dll.o && $(CC) -DSHARED_LIBOBJ
-DGIT_VERSION='"$(GIT_VERSION)"' \
+		$(ALL_CFLAGS) -o git-dll.o -c git.c
+	$(QUIET_LINK)$(RM) $@ && $(CC) -shared -Wl,--export-all-symbols \
+		-o $@ $(ALL_LDFLAGS) git-dll.o $(LIB_OBJS) builtin-fetch-pack.o
builtin-send-pack.o \
+		$(filter-out $(LIB_FILE),$(LIBS)) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
+else
 $(LIB_FILE): $(LIB_OBJS)
 	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
+endif

 XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 	xdiff/xmerge.o
@@ -1277,15 +1288,18 @@
 endif
 	if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
 	then \
-		ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
+		$(LN) -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
 			'$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
 		cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
 			'$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
 	fi
-	$(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p'
&& ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'
'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
+	$(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p'
&& $(LN) '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'
'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
 ifneq (,$X)
 	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS)
$(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)
 endif
+ifneq (,$(findstring .dll,$(LIB_FILE)))
+	$(INSTALL) $(LIB_FILE) '$(DESTDIR_SQ)$(bindir_SQ)'
+endif

 install-doc:
 	$(MAKE) -C Documentation install
diff -urN  origsrc/git-1.5.6/git-gui/git-gui.sh src/git-1.5.6/git-gui/git-gui.sh
--- origsrc/git-1.5.6/git-gui/git-gui.sh	2008-06-19 00:49:49.000000000 +0200
+++ src/git-1.5.6/git-gui/git-gui.sh	2008-06-22 09:38:23.359375000 +0200
@@ -279,8 +279,12 @@
 		}

 		set p [gitexec git-$name$::_search_exe]
-		if {[file exists $p]} {
-			set v [list $p]
+		if ([file exists $p]} {
+		      	if ([is_Cygwin] && [file exists [file join $p .lnk]]) {
+			    set v [list $::_git $name]
+			} else {
+			    set v [list $p]
+			}
 		} elseif {[is_Windows] && [file exists [gitexec git-$name]]} {
 			# Try to determine what sort of magic will make
 			# git-$name go and do its thing, because native
diff -urN  origsrc/git-1.5.6/git.c src/git-1.5.6/git.c
--- origsrc/git-1.5.6/git.c	2008-06-19 00:49:49.000000000 +0200
+++ src/git-1.5.6/git.c	2008-06-21 11:10:48.953125000 +0200
@@ -384,6 +384,7 @@
 	}
 }

+#ifndef SHARED_LIBOBJ
 int main(int argc, const char **argv)
 {
 	const char *cmd = argv[0] ? argv[0] : "git-help";
@@ -474,3 +475,4 @@

 	return 1;
 }
+#endif




---------- Forwarded message ----------
From: Reini Urban <rurban@x-ray.at>
Date: 2008/6/21
Subject: Re: [ANNOUNCEMENT] Updated: git-1.5.6-1
To: cygwin@cygwin.com


2008/6/20 Brian Dessent:
> Reini Urban wrote:
>
>> Some attribute causes the linker to refuse to build the dll and wants
>> to build an exe.
>
> That's because you used -Wl,-shared where you should have used -shared.
> When you use -Wl the driver treats the argument as an opaque value that
> is simply passed to the linker without interpretation.  In this case it
> means the driver is unaware that you're trying to create a shared
> library and instead passes to the linker the startup object and
> corresponding options for creating a program.

[Bang on the head] Stupid me.
Thanks, that compiles fine.
Unfortunately it doesn't work yet. The testsuite works with 4 failures.

I'll try it upstream now.
They wanted a shared lib for a long time for some perl and python libs.
I just did a simple make and installation improvement.

-- 
Reini Urban
http://phpwiki.org/              http://murbreak.at/

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

* Re: shared lib+symlinks patch for cygwin
  2008-06-22  7:56 shared lib+symlinks patch for cygwin Reini Urban
@ 2008-06-22  8:10 ` Brian Dessent
  2008-06-22  8:19   ` Reini Urban
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Dessent @ 2008-06-22  8:10 UTC (permalink / raw)
  To: Reini Urban; +Cc: git

Reini Urban wrote:

> esp. on cygwin where file hardlinks do not work as on linux.
> old bindir 5.8MB, new 2.7MB

Hard links work just fine on Cygwin, assuming the underlying volume is
NTFS.  What you probably mean to say is that the Cygwin setup.exe
program won't create hardlinks from the tarball when installing binary
packages.  But this could be worked around by creating the links with
'ln' in a postinstall script.  Then NTFS users would get the space
savings and FAT users would get copies.

Brian

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

* Re: shared lib+symlinks patch for cygwin
  2008-06-22  8:10 ` Brian Dessent
@ 2008-06-22  8:19   ` Reini Urban
  0 siblings, 0 replies; 3+ messages in thread
From: Reini Urban @ 2008-06-22  8:19 UTC (permalink / raw)
  To: git

2008/6/22 Brian Dessent <brian@dessent.net>:
> Reini Urban wrote:
>
>> esp. on cygwin where file hardlinks do not work as on linux.
>> old bindir 5.8MB, new 2.7MB
>
> Hard links work just fine on Cygwin, assuming the underlying volume is
> NTFS.

And you have Administrator rights, yes. On cygwin you can install packages
without having root perms.

> What you probably mean to say is that the Cygwin setup.exe
> program won't create hardlinks from the tarball when installing binary
> packages.  But this could be worked around by creating the links with
> 'ln' in a postinstall script.  Then NTFS users would get the space
> savings and FAT users would get copies.

Good. So just postinstall.sh has to be fixed.
Anyway, I like the symlink approach to be fixed also.
-- 
Reini Urban
http://phpwiki.org/              http://murbreak.at/

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

end of thread, other threads:[~2008-06-22  8:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-22  7:56 shared lib+symlinks patch for cygwin Reini Urban
2008-06-22  8:10 ` Brian Dessent
2008-06-22  8:19   ` Reini Urban

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).