This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: elfutils makefile changes


On Tue, 2010-02-16 at 14:11 -0800, Roland McGrath wrote:
> > I did have to make one little tweak to the systemtap embedded elfutils
> > build infrastructure. But that is because we only do a partial
> > build/install in that case, bypassing some of the normal make targets.
> 
> That is odd.  I don't think the behavior of any make targets should have
> changed.  Can you elaborate on this problem?

It might be broken before. And I wouldn't worry too much about it. The
systemtap build only supports is for older distros that need some of the
elfutils libs includes in the systemtap install itself. Basically when
you use --with-elfutils=/path/to/elfutils/src the configure will do:

  # Our libdw.so's libebl will look in $ORIGIN/../lib/... but that
  # $ORIGIN is where libdw.so resides, which is not where there is a ../lib.
  # Note that $libdir might be using a quoted use of $exec_prefix or $prefix.
  # So we must make sure to pass those settings to elfutils configure.
  elfutils_rpath="-Wl,--enable-new-dtags,-rpath,${libdir}/${PACKAGE_NAME}"
  here=`pwd`
  (mkdir -p build-elfutils && cd build-elfutils &&
   bash ${elfutils_srcdir}/configure --enable-libebl-subdir=${PACKAGE_NAME} \
                                --includedir="${here}/include-elfutils" \
                                --libdir="${here}/lib-elfutils" \
                                --exec-prefix="$exec_prefix" \
                                --prefix="$prefix" \
                                CFLAGS="${CFLAGS/-Wall/} $gnu89_inline_flag" \
                                LDFLAGS="$LDFLAGS $elfutils_rpath" &&
   if test -f ${elfutils_srcdir}/config/version.h.in; then
        echo Trying to install elfutils version header...
        make install-pkgincludeHEADERS
   fi
   # so that elfutils/version.h - available from 0.138 - may be found.
   # Don't use install-data because that will fail (installing in $prefix).
  )
  if test $? != 0; then exit; fi
  save_CPPFLAGS=${CPPFLAGS}
  CPPFLAGS="${CPPFLAGS} -Iinclude-elfutils" # in case bundled elfutils
  AC_CHECK_HEADERS([elfutils/version.h])
  CPPFLAGS="$save_CPPFLAGS"

Note that one make target is done early during the configure step to get
access to the version.h header. Then during the make step we do:

        if BUILD_ELFUTILS
        stap_CPPFLAGS += -Iinclude-elfutils
        stap_LDFLAGS += -Llib-elfutils -Wl,-rpath-link,lib-elfutils \
                        -Wl,--enable-new-dtags,-rpath,$(pkglibdir)
        
        
        BUILT_SOURCES += stamp-elfutils
        CLEANFILES += stamp-elfutils
        stamp-elfutils: config.status
                $(MAKE) $(AM_MAKEFLAGS) -C build-elfutils all bin_PROGRAMS=
                for dir in libelf libebl libdw libdwfl backends; do \
                  $(MAKE) $(AM_MAKEFLAGS) -C build-elfutils/$$dir bin_PROGRAMS= install; \
                done
                touch $@
        stap_DEPENDENCIES += lib-elfutils/libdw.so
        lib-elfutils/libdw.so: stamp-elfutils ;
        
Note how we are using bin_PROGRAMS= and only doing an install in the
separate build directories. This last step goes wrong when we are
running parallel make with -j BIG. Then sometimes you will get:

ranlib libebl_ppc64_pic.a
rm -f libebl_s390_pic.a
ar cru libebl_s390_pic.a s390_init.os s390_symbol.os s390_regs.os s390_retval.os 
ar cru libebl_s390_pic.a s390_init.os s390_symbol.os s390_regs.os s390_retval.os 
echo 'ELFUTILS_0.144 { global: i386_init; local: *; };' > libebl_i386.map
ranlib libebl_arm_pic.a
echo 'ELFUTILS_0.144 { global: sh_init; local: *; };' > libebl_sh.map
ranlib libebl_ppc_pic.a
echo 'ELFUTILS_0.144 { global: x86_64_init; local: *; };' > libebl_x86_64.map
ranlib libebl_sparc_pic.a
ranlib libebl_s390_pic.a
echo 'ELFUTILS_0.144 { global: ia64_init; local: *; };' > libebl_ia64.map
echo 'ELFUTILS_0.144 { global: alpha_init; local: *; };' > libebl_alpha.map
echo 'ELFUTILS_0.144 { global: ppc64_init; local: *; };' > libebl_ppc64.map
gcc -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2   -g -O2 -fstack-protector-all -D_FORTIFY_SOURCE=2 -fgnu89-inline  -Wl,--enable-new-dtags,-rpath,/usr/local/install/systemtap/lib/systemtap -o libebl_i386.so -shared -o libebl_i386.so -Wl,--whole-archive,libebl_i386_pic.a\
		../libcpu/libcpu_i386.a -Wl,--no-whole-archive \
		-Wl,--version-script,libebl_i386.map \
		-Wl,-z,defs -Wl,--as-needed ../libelf/libelf.so ../libdw/libdw.so 
[... a couple of other gcc invocations using other arches ...] 
gcc -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2   -g -O2 -fstack-protector-all -D_FORTIFY_SOURCE=2 -fgnu89-inline  -Wl,--enable-new-dtags,-rpath,/usr/local/install/systemtap/lib/systemtap -o libebl_ppc.so -shared -o libebl_ppc.so -Wl,--whole-archive,libebl_ppc_pic.a\
		 -Wl,--no-whole-archive \
		-Wl,--version-script,libebl_ppc.map \
		-Wl,-z,defs -Wl,--as-needed ../libelf/libelf.so ../libdw/libdw.so 
gcc -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2   -g -O2 -fstack-protector-all -D_FORTIFY_SOURCE=2 -fgnu89-inline  -Wl,--enable-new-dtags,-rpath,/usr/local/install/systemtap/lib/systemtap -o libebl_s390.so -shared -o libebl_s390.so -Wl,--whole-archive,libebl_s390_pic.a\
		 -Wl,--no-whole-archive \
		-Wl,--version-script,libebl_s390.map \
		-Wl,-z,defs -Wl,--as-needed ../libelf/libelf.so ../libdw/libdw.so 
/usr/bin/ld: cannot open linker script file libebl_ppc.map: No such file or directory
collect2: ld returned 1 exit status
make[1]: *** [libebl_ppc.so] Error 1
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot open linker script file libebl_s390.map: No such file or directory
collect2: ld returned 1 exit status
make[1]: *** [libebl_s390.so] Error 1
/usr/bin/ld: cannot open linker script file libebl_arm.map: No such file or directory
collect2: ld returned 1 exit status
make[1]: *** [libebl_arm.so] Error 1
if readelf -d libebl_sh.so | fgrep -q TEXTREL; then exit 1; fi
if readelf -d libebl_i386.so | fgrep -q TEXTREL; then exit 1; fi
if readelf -d libebl_x86_64.so | fgrep -q TEXTREL; then exit 1; fi
rm libebl_sh.map libebl_x86_64.map libebl_ppc64.map libebl_alpha.map libebl_i386.map libebl_ia64.map
make[1]: Leaving directory `/usr/local/build/systemtap-obj/build-elfutils/backends'
make: *** [stamp-elfutils] Error 2

Since all of the above is really ugly anyway, and it is only used in
fairly esoteric circumstances, I just worked around it by adding -j1 to
that install step and all is fine.

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]