develooper Front page | perl.perl5.porters | Postings from October 2003

5.8.1: static build completely busted?

Thread Next
From:
Ilya Zakharevich
Date:
October 7, 2003 14:36
Subject:
5.8.1: static build completely busted?
Message ID:
20031007213339.GA7070@math.berkeley.edu
Yesterday I tried a static build on OS/2, and things turned out to be
broken in many different ways [for all of which I now know a fix, but
this is a different story].

One of the most pronounced ones is that ./perl is not linked with half
of the built extensions.  Why?  Here is the rule of Makefile.SH:

perlmain.c: miniperlmain.c config.sh $(FIRSTMAKEFILE)
	sh writemain $(DYNALOADER) $(static_ext) > writemain.tmp
	sh mv-if-diff writemain.tmp perlmain.c

perl$(EXE_EXT): $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
	-@rm -f miniperl.xok
	$(SHRPENV) $(LDLIBPTH) $(CC) -o perl$(PERL_SUFFIX) $(PERL_PROFILE_LDFLAGS) $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)

Note that only extensions which are in static_ext are put into
perlmain.c, and linked into ./perl.  However, many (most?) of the
extensions are actually a subdirectory of another extension; the
corresponding .a archives *are* build, but are not linked into ./perl
and perlmain.c.

Aside: remember the mess generated by having both threads and
       threads/shared in static_ext?  And the resulting mess of having
       NORECURS=1 in ext/threads/Makefile.PL?  [And many other
       resulting messes - e.g., static OS/2 build being broken by this
       NORECURS. ;-(  ;-)]

       I think the reason for why this mess started is that somebody
       noticed that threads/shared was not linked in, and made this a
       special case - not noticing that a dozen of other extensions is
       not linked too.

I tested two solutions:

a) put $(static_ext) as a dependence of perlmain.c; then replace
   $(static_ext) by `cat extlist` with

   # Assume that extensions are at most 4 deep (this is so with 5.8.1)
   aout_extlist: $(aout_static_ext)
	      echo lib/auto/*.a lib/auto/*/*.a lib/auto/*/*/*.a lib/auto/*/*/*/*.a | tr ' ' '\n' | grep -v '\*' > $@.tmp
	      sh mv-if-diff $@.tmp $@

b) Do not use writemain at all (why is it needed?!):

   ext/perl/Makefile.PL:
	-mkdir ext/perl
	echo "use ExtUtils::MakeMaker; WriteMakefile(NAME => q(aperl))" > $@

   ext/perl/Makefile: ext/perl/Makefile.PL miniperl_
		   cd ext/perl; ../../miniperl_ -I../../lib Makefile.PL

   aperl_: miniperl_ $(aout_static_ext) ext/perl/Makefile
	cd ext/perl; make perl && make -f Makefile.aperl inst_perl MAP_TARGET=../../$@

(in both this examples there are some prefixes aout_ and postfix `_'
specific to the OS/2 build procedure - we construct two different
architectures in the same directory).

[In both these solutions ./perl is not rebuilt if a change in a kid
directory of ext/ causes a rebuild of the "kid" library (recall that
they are not in $(static_ext)).]

Opinions?
Ilya

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About