{"thread":{"id":"14082","subject":"shared lib+symlinks patch for cygwin","startedAt":"2008-06-22T07:56:23Z","lastAt":"2008-06-22T08:19:19Z","messageCount":3,"participants":["Reini Urban","Brian Dessent"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"80591","messageId":"6910a60806220056i1dda7f4elb4e5c69cdeea3cf9@mail.gmail.com","threadId":"14082","inReplyTo":null,"subject":"shared lib+symlinks patch for cygwin","fromName":"Reini Urban","fromEmail":"rurban@x-ray.at","sentAt":"2008-06-22T07:56:23Z","receivedAt":"2008-06-22T07:56:23Z","isPatch":false,"sender":{"key":"rurban@x-ray.at","avatar":"https://gravatar.com/avatar/ed0c25f7529f208fb8a0448c3e9b725cb900baeeca241b3beff8586ab35a5206?d=mp&s=160"},"body":"Attached is a semi-complete patch for a significant space reduction,\nesp. on cygwin where file hardlinks do not work as on linux.\nold bindir 5.8MB, new 2.7MB\n\n$ du git-1.5.6-1/inst/usr/bin git-1.5.6-2/inst/usr/bin\n5.8M    git-1.5.6-1/inst/usr/bin\n2.7M    git-1.5.6-2/inst/usr/bin\n\nFirst it links to a shared lib for all builtins (cygwin only),\nsecond it uses symlinks instead of hardlinks (cygwin only).\n\nmingw could also take this approach but I cannot test this.\nA shared lib for all platforms should IMHO also be considered.\n\nThe first dll approach works fine.\nThe second has open problems with git-gui, because the native windows app\ncannot handle symlinks.\nfile exists returns true but we cannot call it. So I tried to change\nthe calling sequence from git-config to git config, but Tcl is not my\nnative language. Maybe someone can help.\n\nFor reference:\nI found an old shared libgit patch at\n  http://article.gmane.org/gmane.comp.version-control.git/8680/match=shared+lib\n\n\n--- origsrc/git-1.5.6/Makefile\t2008-06-19 00:49:49.000000000 +0200\n+++ src/git-1.5.6/Makefile\t2008-06-22 09:08:22.812500000 +0200\n@@ -211,12 +211,12 @@\n AR = ar\n RM = rm -f\n TAR = tar\n+LN = ln\n FIND = find\n INSTALL = install\n RPMBUILD = rpmbuild\n TCL_PATH = tclsh\n TCLTK_PATH = wish\n-\n export TCL_PATH TCLTK_PATH\n\n # sparse is architecture-neutral, which means that we need to tell it\n@@ -639,20 +639,20 @@\n endif\n ifeq ($(uname_O),Cygwin)\n \tNO_D_TYPE_IN_DIRENT = YesPlease\n-\tNO_D_INO_IN_DIRENT = YesPlease\n \tNO_STRCASESTR = YesPlease\n \tNO_MEMMEM = YesPlease\n-\tNO_SYMLINK_HEAD = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n-\tNO_TRUSTABLE_FILEMODE = UnfortunatelyYes\n \tOLD_ICONV = UnfortunatelyYes\n \t# There are conflicting reports about this.\n \t# On some boxes NO_MMAP is needed, and not so elsewhere.\n \t# Try commenting this out if you suspect MMAP is more efficient\n-\tNO_MMAP = YesPlease\n+#\tNO_MMAP = YesPlease\n \tNO_IPV6 = YesPlease\n \tX = .exe\n+\tLIB_FILE=cyggit.dll\n+\tALL_LDFLAGS += -Wl,--enable-auto-import\n+\tLN = ln -s\n endif\n ifeq ($(uname_S),FreeBSD)\n \tNEEDS_LIBICONV = YesPlease\n@@ -1040,7 +1040,7 @@\n \t\t'-DGIT_INFO_PATH=\"$(infodir_SQ)\"' $<\n\n $(BUILT_INS): git$X\n-\t$(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@\n+\t$(QUIET_BUILT_IN)$(RM) $@ && $(LN) git$X $@\n\n common-cmds.h: ./generate-cmdlist.sh command-list.txt\n\n@@ -1169,8 +1171,17 @@\n $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)\n builtin-revert.o wt-status.o: wt-status.h\n\n+ifneq (,$(findstring .dll,$(LIB_FILE)))\n+$(LIB_FILE): $(LIB_OBJS) builtin-fetch-pack.o builtin-send-pack.o $(XDIFF_LIB)\n+\t$(QUIET_CC)$(RM) git-dll.o && $(CC) -DSHARED_LIBOBJ\n-DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n+\t\t$(ALL_CFLAGS) -o git-dll.o -c git.c\n+\t$(QUIET_LINK)$(RM) $@ && $(CC) -shared -Wl,--export-all-symbols \\\n+\t\t-o $@ $(ALL_LDFLAGS) git-dll.o $(LIB_OBJS) builtin-fetch-pack.o\nbuiltin-send-pack.o \\\n+\t\t$(filter-out $(LIB_FILE),$(LIBS)) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n+else\n $(LIB_FILE): $(LIB_OBJS)\n \t$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)\n+endif\n\n XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \\\n \txdiff/xmerge.o\n@@ -1277,15 +1288,18 @@\n endif\n \tif test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \\\n \tthen \\\n-\t\tln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \\\n+\t\t$(LN) -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \\\n \t\t\t'$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \\\n \t\tcp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \\\n \t\t\t'$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \\\n \tfi\n-\t$(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p'\n&& ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'\n'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)\n+\t$(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p'\n&& $(LN) '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'\n'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)\n ifneq (,$X)\n \t$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS)\n$(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)\n endif\n+ifneq (,$(findstring .dll,$(LIB_FILE)))\n+\t$(INSTALL) $(LIB_FILE) '$(DESTDIR_SQ)$(bindir_SQ)'\n+endif\n\n install-doc:\n \t$(MAKE) -C Documentation install\ndiff -urN  origsrc/git-1.5.6/git-gui/git-gui.sh src/git-1.5.6/git-gui/git-gui.sh\n--- origsrc/git-1.5.6/git-gui/git-gui.sh\t2008-06-19 00:49:49.000000000 +0200\n+++ src/git-1.5.6/git-gui/git-gui.sh\t2008-06-22 09:38:23.359375000 +0200\n@@ -279,8 +279,12 @@\n \t\t}\n\n \t\tset p [gitexec git-$name$::_search_exe]\n-\t\tif {[file exists $p]} {\n-\t\t\tset v [list $p]\n+\t\tif ([file exists $p]} {\n+\t\t      \tif ([is_Cygwin] && [file exists [file join $p .lnk]]) {\n+\t\t\t    set v [list $::_git $name]\n+\t\t\t} else {\n+\t\t\t    set v [list $p]\n+\t\t\t}\n \t\t} elseif {[is_Windows] && [file exists [gitexec git-$name]]} {\n \t\t\t# Try to determine what sort of magic will make\n \t\t\t# git-$name go and do its thing, because native\ndiff -urN  origsrc/git-1.5.6/git.c src/git-1.5.6/git.c\n--- origsrc/git-1.5.6/git.c\t2008-06-19 00:49:49.000000000 +0200\n+++ src/git-1.5.6/git.c\t2008-06-21 11:10:48.953125000 +0200\n@@ -384,6 +384,7 @@\n \t}\n }\n\n+#ifndef SHARED_LIBOBJ\n int main(int argc, const char **argv)\n {\n \tconst char *cmd = argv[0] ? argv[0] : \"git-help\";\n@@ -474,3 +475,4 @@\n\n \treturn 1;\n }\n+#endif\n\n\n\n\n---------- Forwarded message ----------\nFrom: Reini Urban <rurban@x-ray.at>\nDate: 2008/6/21\nSubject: Re: [ANNOUNCEMENT] Updated: git-1.5.6-1\nTo: cygwin@cygwin.com\n\n\n2008/6/20 Brian Dessent:\n> Reini Urban wrote:\n>\n>> Some attribute causes the linker to refuse to build the dll and wants\n>> to build an exe.\n>\n> That's because you used -Wl,-shared where you should have used -shared.\n> When you use -Wl the driver treats the argument as an opaque value that\n> is simply passed to the linker without interpretation.  In this case it\n> means the driver is unaware that you're trying to create a shared\n> library and instead passes to the linker the startup object and\n> corresponding options for creating a program.\n\n[Bang on the head] Stupid me.\nThanks, that compiles fine.\nUnfortunately it doesn't work yet. The testsuite works with 4 failures.\n\nI'll try it upstream now.\nThey wanted a shared lib for a long time for some perl and python libs.\nI just did a simple make and installation improvement.\n\n-- \nReini Urban\nhttp://phpwiki.org/              http://murbreak.at/\n"},{"id":"80593","messageId":"485E08F7.ADE2290C@dessent.net","threadId":"14082","inReplyTo":"6910a60806220056i1dda7f4elb4e5c69cdeea3cf9@mail.gmail.com","subject":"Re: shared lib+symlinks patch for cygwin","fromName":"Brian Dessent","fromEmail":"brian@dessent.net","sentAt":"2008-06-22T08:10:31Z","receivedAt":"2008-06-22T08:10:31Z","isPatch":false,"sender":{"key":"brian@dessent.net","avatar":null},"body":"Reini Urban wrote:\n\n> esp. on cygwin where file hardlinks do not work as on linux.\n> old bindir 5.8MB, new 2.7MB\n\nHard links work just fine on Cygwin, assuming the underlying volume is\nNTFS.  What you probably mean to say is that the Cygwin setup.exe\nprogram won't create hardlinks from the tarball when installing binary\npackages.  But this could be worked around by creating the links with\n'ln' in a postinstall script.  Then NTFS users would get the space\nsavings and FAT users would get copies.\n\nBrian\n"},{"id":"80594","messageId":"6910a60806220119g2a515f44qdfd664459923fc70@mail.gmail.com","threadId":"14082","inReplyTo":"485E08F7.ADE2290C@dessent.net","subject":"Re: shared lib+symlinks patch for cygwin","fromName":"Reini Urban","fromEmail":"rurban@x-ray.at","sentAt":"2008-06-22T08:19:19Z","receivedAt":"2008-06-22T08:19:19Z","isPatch":false,"sender":{"key":"rurban@x-ray.at","avatar":"https://gravatar.com/avatar/ed0c25f7529f208fb8a0448c3e9b725cb900baeeca241b3beff8586ab35a5206?d=mp&s=160"},"body":"2008/6/22 Brian Dessent <brian@dessent.net>:\n> Reini Urban wrote:\n>\n>> esp. on cygwin where file hardlinks do not work as on linux.\n>> old bindir 5.8MB, new 2.7MB\n>\n> Hard links work just fine on Cygwin, assuming the underlying volume is\n> NTFS.\n\nAnd you have Administrator rights, yes. On cygwin you can install packages\nwithout having root perms.\n\n> What you probably mean to say is that the Cygwin setup.exe\n> program won't create hardlinks from the tarball when installing binary\n> packages.  But this could be worked around by creating the links with\n> 'ln' in a postinstall script.  Then NTFS users would get the space\n> savings and FAT users would get copies.\n\nGood. So just postinstall.sh has to be fixed.\nAnyway, I like the symlink approach to be fixed also.\n-- \nReini Urban\nhttp://phpwiki.org/              http://murbreak.at/\n"}]}