Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Breaking apart link dependencies
- X-seq: zsh-workers 25273
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Breaking apart link dependencies
- Date: Tue, 8 Jul 2008 20:48:17 -0700
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=d200803; d=spodhuis.org; h=Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:MIME-Version:Content-Type:Content-Disposition; b=qsEWuEzLG7EEqY3LKFI8iVCgWYLdzuiMk+Mp+QQq4kRC6nmyKExd1XLWk8PMTvo89be7dHzfL6m09vpVPd9H5XJC/jf4TV1EeFB1N5w1imXtt9WVF2ejjigRmeGuf3o/81J6R07UMlcDBQreaoZTCUXnvpIBY7Op9Si9JcNC1J4=;
- Mail-followup-to: zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
In zsh-workers 23617 I mentioned an intention to look into some link
dependency stuff before posting a patch. Alas, that was right before I
started playing World of Warcraft and my code-hacking time disappeared
... somewhere; when I stopped playing a few months later, I never got
back to this. So, I'm kicking this out as a patch manually filtered
from amongst other changes in code I haven't touched in over a year,
tested on FreeBSD/amd64 and MacOS 10.4.x. That sounds scarier than it
is, once you see the size of the actual patch and how simple it is.
This is the first step to see if there's any linker breakage on other
platforms. If it works decently, perhaps a later step is to move the
ncurses dependency to zle?
There are of course interesting tab dependencies in patches against
portable shell generating Makefiles, so caveat patcher.
Not tested against cygwin, but it should leave the linkage of
zsh/main.so unmolested.
Does zsh still support any systems that don't support chained libraries,
as mentioned by Andrey Borzenkov in post 23347? Does zsh tend to just
statically compile on those platforms? If not, is there a deterministic
configure.ac test available, or should we just list the platforms as
exceptions to resetting LIBS and CPPFLAGS by the XXX comment in the
patch?
-Phil
----------------------------8< cut here >8------------------------------
Index: configure.ac
===================================================================
RCS file: /home/cvsroot/zsh/configure.ac,v
retrieving revision 1.105
diff -p -u -r1.105 configure.ac
--- configure.ac 1 Jun 2008 16:39:09 -0000 1.105
+++ configure.ac 9 Jul 2008 03:03:36 -0000
@@ -544,6 +544,7 @@ AC_HEADER_STAT
AC_HEADER_SYS_WAIT
oldcflags="$CFLAGS"
+pre_pcre_cppflags="$CPPFLAGS"
if test x$enable_pcre = xyes; then
AC_CHECK_PROG([PCRECONF], pcre-config, pcre-config)
dnl Typically (meaning on this single RedHat 9 box in front of me)
@@ -792,6 +793,7 @@ if test "x$ac_found_iconv" = "xyes"; the
[Define as const if the declaration of iconv() needs const.])
fi
+pre_pcre_libs="$LIBS"
if test x$enable_pcre = xyes; then
dnl pcre-config should probably be employed here
dnl AC_SEARCH_LIBS(pcre_compile, pcre)
@@ -1133,6 +1135,12 @@ AC_CHECK_FUNCS(strftime strptime mktime
regcomp regexec regerror regfree)
AC_FUNC_STRCOLL
+dnl The only stuff which needs PCRE includes is the pcre module.
+dnl On ELF systems (at least) only that module needs to be linked against pcre.
+dnl XXX Need to figure out where this isn't safe
+LIBS="$pre_pcre_libs"
+CPPFLAGS="$pre_pcre_cppflags"
+
if test x$enable_cap = xyes; then
AC_CHECK_FUNCS(cap_get_proc)
fi
Index: Src/mkmakemod.sh
===================================================================
RCS file: /home/cvsroot/zsh/Src/mkmakemod.sh,v
retrieving revision 1.17
diff -p -u -r1.17 mkmakemod.sh
--- Src/mkmakemod.sh 30 Jan 2008 10:03:49 -0000 1.17
+++ Src/mkmakemod.sh 9 Jul 2008 03:15:10 -0000
@@ -32,6 +32,8 @@
# headers extra headers for this module (default none)
# hdrdeps extra headers on which the .mdh depends (default none)
# otherincs extra headers that are included indirectly (default none)
+# modincflags extra inc flags to pass when building the module
+# modlibflags extra linkage flags to pass when building the module
#
# The .mdd file may also include a Makefile.in fragment between lines
# `:<<\Make' and `Make' -- this will be copied into Makemod.in.
@@ -46,6 +48,9 @@
# and $otherincs will be made up to date, but the .mdh file won't actually
# be rebuilt if those files change.
#
+# modincflags and modlibflags should be used for system includes and libraries
+# which are particular to this module; eg, PCRE, regex, etc.
+#
# The order of sections of the output file is thus:
# simple generated macros
# macros generated from *.mdd
@@ -191,6 +196,7 @@ if $first_stage; then
unset name moddeps nozshdep alwayslink hasexport
unset autobins autoinfixconds autoprefixconds autoparams automathfuncs
unset objects proto headers hdrdeps otherincs
+ unset modincflags modlibflags
. $top_srcdir/$the_subdir/${mddname}.mdd
q_name=`echo $name | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`
test -n "${moddeps+set}" || moddeps=
@@ -312,6 +318,26 @@ if $first_stage; then
echo "modobjs.${mddname}: \$(MODOBJS_${mddname})"
echo " echo '' \$(MODOBJS_${mddname}) $modobjs_sed>> \$(dir_src)/stamp-modobjs.tmp"
echo
+ if test -n "$modincflags"; then
+ echo "${mddname}\$(ANSIOBJ): ${mddname}.c"
+ echo " \$(COMPILE) $modincflags -o \$@ \$<"
+ echo " @rm -f \$(dir_src)/stamp-modobjs"
+ echo
+ echo "${mddname}\$(KNROBJ): ${mddname}.c"
+ echo " : ansi2knr \$< > \$@.c"
+ echo " \$(COMPILE) $modincflags -o \$@ \$@.c"
+ echo " rm -f \$@.c"
+ echo " @rm -f \$(dir_src)/stamp-modobjs"
+ echo
+ echo "${mddname}.\$(ANSIOBJ): ${mddname}.c"
+ echo " \$(DLCOMPILE) $modincflags -o \$@ \$<"
+ echo
+ echo "${mddname}.\$(KNROBJ): ${mddname}.c"
+ echo " : ansi2knr \$< > \$@.c"
+ echo " \$(DLCOMPILE) $modincflags -o \$@ \$@.c"
+ echo " rm -f \$@.c"
+ echo
+ fi
if test -z "$alwayslink"; then
case " $all_modules" in *" ${mddname}."*)
echo "install.modules-here: install.modules.${mddname}"
@@ -328,7 +354,7 @@ if $first_stage; then
echo
echo "${mddname}.\$(DL_EXT): \$(MODDOBJS_${mddname}) ${mddname}.export $exportdeps \$(@LINKMODS@_${mddname})"
echo ' rm -f $@'
- echo " \$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(MODDOBJS_${mddname}) \$(@LINKMODS@_${mddname}) \$(LIBS) "
+ echo " \$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(MODDOBJS_${mddname}) \$(@LINKMODS@_${mddname}) \$(LIBS) ${modlibflags} "
echo
fi
echo "${mddname}.mdhi: ${mddname}.mdhs \$(INCS_${mddname})"
Index: Src/Modules/pcre.mdd
===================================================================
RCS file: /home/cvsroot/zsh/Src/Modules/pcre.mdd,v
retrieving revision 1.4
diff -p -u -r1.4 pcre.mdd
--- Src/Modules/pcre.mdd 20 Jun 2007 20:59:18 -0000 1.4
+++ Src/Modules/pcre.mdd 9 Jul 2008 03:09:43 -0000
@@ -5,3 +5,6 @@ load=no
autofeatures="b:pcre_compile b:pcre_study b:pcre_match"
objects="pcre.o"
+
+modincflags="`pcre-config --cflags`"
+modlibflags="`pcre-config --libs`"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author