From: "Reini Urban" <rurban@x-ray.at>
To: git@vger.kernel.org
Subject: shared lib+symlinks patch for cygwin
Date: Sun, 22 Jun 2008 09:56:23 +0200 [thread overview]
Message-ID: <6910a60806220056i1dda7f4elb4e5c69cdeea3cf9@mail.gmail.com> (raw)
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/
next reply other threads:[~2008-06-22 7:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-22 7:56 Reini Urban [this message]
2008-06-22 8:10 ` shared lib+symlinks patch for cygwin Brian Dessent
2008-06-22 8:19 ` Reini Urban
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6910a60806220056i1dda7f4elb4e5c69cdeea3cf9@mail.gmail.com \
--to=rurban@x-ray.at \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).