CoderBits Geolocation bytehisto This page MURB Hack9 Old 2012 Site Laclin Minetest Contact Exit to Top Site

180701 Sunday — Port of elfutils to musl

180701. Port of elfutils to musl.

musl elfutils

This post is for those who know what "elfutils" and "musl" are and would like to get one into the other.

In 2018, I ported "elfutils" 0.173, which seemed to be the latest official release as of 180701, to musl 1.1.19.

Other ports existed. However, most were distro-specific or for older releases of "elfutils".

My 2018 port is undoubtedly obsolete today. However, the pro­cess that was used may be instruc­tive.

This wasn't a small task.

elfutils is madness
elfutils is horror
elfutils is descent into pit
Into musl elfutils does not fit

So, I'll share the resulting patch file and pro­ce­dure with others inter­est­ed in "musl".


For me, at any rate, the patch file and pro­ce­dure produce a clean "elfutils" build including executables and both static and dynamic libraries.

The "gcc" and "binutils" used were releases 6.4.0 and 2.27, respectively, as built by Rich Felker's "musl" cross make toolkit, which was located at:

https://github.com/richfelker/musl-cross-make

You can down­load all of the special files required, not including musl cross make, in a single ZIP archive at this link:

http://coderbits.haggishell.com/elfmusl/elfutils-oldcoder-180701.zip

The link will probably change later.

The ZIP file con­tains these files. You can down­load the ZIP file at this link. Or you can get the files inside it at the links be­low. Text files linked here have been renamed to "*.txt".


Name Notes
README A copy of this post
argp-standalone-1.3.tar.gz "libargp" library sources
argp-standalone-1.3.tar.gz.url URL where I obtained preceding
elfutils-0.173.tar.bz2 "elfutils" 0.173 sources
elfutils-0.173.tar.bz2.url URL where I obtained preceding
libargp-01-alpine-funcdef.patch An Alpine patch for argp*
libargp-02-alpine-gnu89.patch Ditto
musl-elfutils-180701.patch My "musl-elfutils" patch
obstack-git-180701.tar.bz2 "obstack" library sources
obstack-git-180701.tar.bz2.url URL where I obtained preceding

Here's the "build" pro­ce­dure. You'll most like­ly need to make changes based on your OS con­fig­ur­a­tion.

1. Start with a distro based on "musl" 1.1.19, "gcc" 6.4.0 or 7.2.0 or above, and "binutils" 2.27 or 2.28.

You'll need a full stand­ard development toolkit, including recent releases of "autoconf", "automake", and re­la­ted packages. "bzip2", "xzutils", and "zlib" libraries and header files as well.

In the fol­low­ing sections, you can change the PREFIX setting used, but two rules apply:

* The same PREFIX setting should be used in each script
* $PREFIX/include should be a dir­ec­tory that "gcc -I" knows about

2. You may, or may not, need to rebuild var­ious existing libraries with either or both of these two changes:

* Use the "gcc -fPIC" flag
* Build both static and dynamic libraries

Skip this part initially. If you get error messages later re­la­ted to linking with existing libraries, come back to this point and decide whether or not rebuilds might help.

3. If your distro doesn't pro­vide the "libargp.*" library and as­soc­i­a­ted header files, build and install "argp-standalone". Use the two Alpine patches provided.

The fol­low­ing script may work, with changes:

Your phone or window is too narrow to show the code. If it's a phone, try rotating the phone or switching to a PC.

#!/bin/bash -e PREFIX=/usr/local mkdir -p $PREFIX/{bin,sbin,include,lib} # rm -fr argp-standalone-1.3 tar zxf argp-standalone-1.3.tar.gz pushd argp-standalone-1.3 patch -p1 < ../libargp-01-alpine-funcdef.patch patch -p1 < ../libargp-02-alpine-gnu89.patch touch compile autoreconf export CFLAGS="-fPIC -O2" # ./configure --prefix=$PREFIX make mv argp*.h $PREFIX/include/ mv libargp.a $PREFIX/lib/ popd

Warning: This package shouldn't be installed on a "glibc"-based system unless you take steps to prevent it from being used with­out special "gcc -I" and "ld -L" switches.

Even on a "musl"-based system, this package may break GNU "tar". If this happens, you'll probably be able to fix the prob­lem by fiddling with "tar" Makefiles.

4. If your distro doesn't pro­vide the "libobstack.*" library and the as­soc­i­a­ted header file, build and install "obstack". The fol­low­ing script may work, with changes:

Your phone or window is too narrow to show the code. If it's a phone, try rotating the phone or switching to a PC.

#!/bin/bash -e PREFIX=/usr/local mkdir -p $PREFIX/{bin,sbin,include,lib} # rm -fr obstack-git-180701 tar jxf obstack-git-180701.tar.bz2 pushd obstack-git-180701 ./bootstrap.sh export CFLAGS="-fPIC -O2" # ./configure --prefix=$PREFIX make && make install popd

5. Edit "musl-elfutils-180701.patch". Look for this part:

Your phone or window is too narrow to show the code. If it's a phone, try rotating the phone or switching to a PC.

+argp_LDADD="-L/usr/local/lib -Wl,-R/usr/local/lib ... ... +obstack_LDADD="-L/usr/local/lib -Wl,-R/usr/local/lib ...

If "libargp.* is installed somewhere besides "/usr/local/lib", modify the "argp_LDADD" line appropriately.

If "libobstack.* is installed somewhere besides "/usr/local/lib", modify the "obstack_LDADD" line appropriately.

6. Build and install "elfutils". The fol­low­ing script may work, with changes:

Your phone or window is too narrow to show the code. If it's a phone, try rotating the phone or switching to a PC.

#!/bin/bash -e PREFIX=/usr/local mkdir -p $PREFIX/{bin,sbin,include,lib} # rm -fr elfutils-0.173 tar jxf elfutils-0.173.tar.bz2 cd elfutils-0.173 patch -p1 < ../musl-elfutils-180701.patch autoreconf # export LIBS="-L$PREFIX/lib -Wl,-R$PREFIX/lib -lbz2 -lz" export CFLAGS="-fPIC -O2" # ./configure --prefix=$PREFIX make && make install

© 2012-2020 Robert Kiraly aka OldCoder and BoldCoder    |  Privacy policy    |  Contact   |  Notices