shared lib+symlinks patch for cygwin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
Date: 2008/6/21
Subject: Re: [ANNOUNCEMENT] Updated: git-1.5.6-1
To: cygwin@xxxxxxxxxx


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/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux