dslm4515 / Musl-LFS

Linux From Scratch using Musl as Libc
GNU General Public License v3.0
167 stars 21 forks source link

Replace libelf/elfutils with elftoolchain #83

Open dslm4515 opened 1 year ago

dslm4515 commented 1 year ago

Replacing libelf/elfutils with elftoolchain will eliminate the need for musl-obstack

Binutils could be moved from /usr to /opt/gnu as secondary binutils OR Create a script to switch between elftoolchain and binutils

firasuke commented 1 year ago

May I ask why is this an enhancement?

dslm4515 commented 1 year ago

musl-obstack requires autotools to build (no configure script, just configue.ac)

But of course, elftoolchain requires libarchive ... so i guess it just trading musl-obstack for libarchive

firasuke commented 1 year ago

Doesn't the kernel also require musl-obstack? Or is that another dependency on libelf?

dslm4515 commented 1 year ago

I noticed that Chimera Linux does not have a musl-obstack package unlike Void and Linux. Per Alpine package repo, only libelf/elfutils [and other packages not built in MLFS] depends on musl-obstack. I lost my old notes when I first developed MLFS, as I'm sure i added musl-obstack for a reason [elfutils/libelf]

I am in the middle of building CMLFS with elftoolchain. I'll see if its an issue once I build the kernel

firasuke commented 1 year ago

Okay, good luck! Please keep us updated.

dslm4515 commented 1 year ago

I just realized compiling the Linux kernel (mainstream) might be tricky... i.e. objcopy will not be from binutils, but from elf toolchain. I will be using Chimera Linux's cports repo for guidance

dslm4515 commented 1 year ago

When compiling, there are lots of warnings but kernel compiles:

warning: objtool: gelf_update_symshndx: Invalid argument
warning: objtool: elf_update_symbol move
dslm4515 commented 1 year ago

And.... I built CMLFS without binutils and GCC, except when I used mussel to build stage0 clang!

firasuke commented 1 year ago

So were you able to replace libelf from elfutils and musl-obstack by using elftoolchain alone?

dslm4515 commented 1 year ago

Yes. I was able to build CMLFS without libelf (elfutils) and musl-obstack... and without binutils & GCC for the final system.

Only drawback is that elftoolchain Requires bmake and lsb-tools (or a lsb-release script). Perhaps with enough patches, elftoolchain may build with GNU's make and without lsb-tools

firasuke commented 1 year ago

Interesting, so we lost some dependencies, but gained two more.

Thanks for the update!

dslm4515 commented 1 year ago

I also realized nothing depends on argp-standalone, according to Alpine Linux package database. This is false: v4l-utils requires it. I am halfway done with a 2nd CMLFS build with elftoolchain... and came across this package. I will skip it to see if anything requires it. I think it was elfutils that did. Maybe.

In my previous CMLFS build, no package requires musl-obstack ...even up to when building mesa, wayland, and a DE.

Also, @firasuke you can now add CMLFS to projects that use mussel :P ... as master branch now does.

firasuke commented 1 year ago

I also realized nothing depends on argp-standalone, according to Alpine Linux package database. I am halfway done with a 2nd CMLFS build with elftoolchain... and came across this package. I will skip it to see if anything requires it. I think it was elfutils that did. Maybe.

I am using libuargp instead of argp-standalone, and I think only libelf from elfutils depends on it. Same goes for musl-obstack, only elfutils depends on it.

Also, @firasuke you can now add CMLFS to projects that use mussel :P ... as master branch now does.

Already did, 2 weeks ago :)

firasuke commented 1 year ago

I think oasis uses elftoolchain as well.

dslm4515 commented 1 year ago

I found an updated fork of argp-standalone.... bumping the version from 1.3 to 1.5.0... lol, i guess with the success of elftoolchain and you mentioning libuargp, its no longer needed!

I think oasis uses elftoolchain as well.

Oasis? I'll have to check that.

dslm4515 commented 10 months ago

I just checked today: Chimera Linux no longer uses elftoolchain. It apparently switched to elfutils in the past year or so. I couldn't find [a] definite reason[s].

This might make it harder for me to continue to use elftoolschain since I will have to develop patches when there is an issue.

Also, perhaps its time for me to re-evaluate my decision to replace elfutils with elftoolchain.

firasuke commented 10 months ago

Also, perhaps its time for me to re-evaluate my decision to replace elfutils with elftoolchain.

What benefit does elftoolchain provide over elfutils?

dslm4515 commented 10 months ago

From experience, elftoolchain can be used as a drop-in replacement for binutils (so far, I had no package fail to compile with elftoolchain). Although, it's not complete: 4 utilities & 2 libraries are not released (either planned, in-development, or in alpha-stage)... But enough to compile packages in CMLFS and BMLFS.

But in terms of compiling it, it requires bmake (and libarchive & LSB tools/script).

In my search for elftoolchain vs binutils comparisons, I realized elfutils is another alternative to binutils. I may consider trying elfutils as the system binary tools. I couldn't find any comparisons posted online...

For now, elftoolchain can be an alternative if for some reason Binutils fails to compile for whatever reason. Or for licensing issues(?).

q66 commented 10 months ago

elftoolchain precludes having libdw (which is a part of elfutils and links against libelf), which significantly reduces usefulness of tools like perf/strace; it also makes it impossible to build specific tools (e.g. flatpak-builder)

besides that, glacial development pace, lack of DT_RELR support, lack of debuginfod support, lack of objdump, etc

chimera has switched to having llvm provide the binutils (which are significantly more featureful and less buggy) and elfutils exists primarily for libelf/libdw