180701. Port of elfutils to musl.
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 process that was used may be instructive.
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 procedure with others interested in "musl".
For me, at any rate, the patch file and procedure 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 download 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 contains these files. You can download the ZIP file at this link. Or you can get the files inside it at the links below. 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" procedure. You'll most likely need to make changes based on your OS configuration.
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 standard development toolkit, including recent releases of "autoconf", "automake", and related packages. "bzip2", "xzutils", and "zlib" libraries and header files as well.
In the following 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 directory that "gcc -I" knows about
2. You may, or may not, need to rebuild various 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 related to linking with existing libraries, come back to this point and decide whether or not rebuilds might help.
3. If your distro doesn't provide the "libargp.*" library and associated header files, build and install "argp-standalone". Use the two Alpine patches provided.
The following script may work, with changes:
#!/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 without 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 problem by fiddling with "tar" Makefiles.
4. If your distro doesn't provide the "libobstack.*" library and the associated header file, build and install "obstack". The following script may work, with changes:
#!/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:
+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 following script may work, with changes: