dslm4515 / CMLFS

Clang-Built Musl Linux From Scratch
MIT License
105 stars 18 forks source link

extra/alt: llvm-12 fails to compile with netbsd-curses at stage 8 of cgnutools #42

Closed takusuman closed 3 years ago

takusuman commented 3 years ago

I was compiling llvm and then i got this error: 2021-09-12-224038_1013x672_scrot Full text log: https://termbin.com/eibv As you can see, it's trying to "call"/link to libc.so.6 from the host system, not the toolchain one. So, just to be sure, i ran ldd both from the toolchain and from the host just to see where exactly libterminfo.so was trying to link: 2021-09-12-225110_1003x179_scrot And yes; apparently, when i built netbsd-curses, it was linked to the wrong libc.

I'm not sure if i will fix this right now -- it's late and i have to study and work tomorrow -- , so take this as a reminder and as an advice.

dslm4515 commented 3 years ago

Ugh. I always have issues with ncurses. Even back then when developing MLFS. For my first experimental build of CMLFS, I mysteriously built cgnutools without ncurses. I could never find out why as every other attempt, I had to build ncurses.

luckily, one can use patchelf to fix/change dependencies in built libraries. A quick and dirty way to force a toolchain to work, but I prefer not.

I admit, I did use different flags for ncurses in Optimux. I can’t remember off the top of my head if it’s was only for the final system in chroot or in one of the tools chains

takusuman commented 3 years ago

Ugh. I always have issues with ncurses. Even back then when developing MLFS. For my first experimental build of CMLFS, I mysteriously built cgnutools without ncurses. I could never find out why as every other attempt, I had to build ncurses.

Yeah, i understand your pain. I've been experimenting with MLFS since January and always* ncurses was the source of some error in some part of the process.

luckily, one can use patchelf to fix/change dependencies in built libraries. A quick and dirty way to force a toolchain to work, but I prefer not.

I think it's better to just clean the toolchain and recompile it with the correct settings. For now, i will just be building an experimental toolchain for my hobby-distro, so i'm really not worried about using GNU ncurses instead of netbsd-curses.

I admit, I did use different flags for ncurses in Optimux. I can’t remember off the top of my head if it’s was only for the final system in chroot or in one of the tools chains

Don't worry about that for now. :^) May some people can solve this problem with netbsd-curses, so let's keep this issue open.

owl4ce commented 3 years ago

Hmm, mine is fine using netbsd-curses .. 🤔

takusuman commented 3 years ago

Hmm, mine is fine using netbsd-curses .. thinking

Could you share with us the config.mak or you've used that which i wrote at extra/alt/cgnutools_7a-netbsd-curses?

What are your CFLAGS too? I don't remember exactly what i was using but it wasn't not that could harm the process in fact, i think.

takusuman commented 3 years ago

BTW, removed netbsd-curses and built GNU ncurses on its place; trying to compile clang right now.

owl4ce commented 3 years ago

Could you share with us the config.mak or you've used that which i wrote at extra/alt/cgnutools_7a-netbsd-curses?

Sure. I only built dynamic libraries and the program binaries.

# Build.
time { make CC="${CMLFS_TARGET}-gcc" all-dynamic; }

# Install.
time { make PREFIX=/cgnutools install-dynamic; }
takusuman commented 3 years ago

BTW, removed netbsd-curses and built GNU ncurses on its place; trying to compile clang right now.

And got the same error when linking to libterminfo.so. 2021-09-13-035319_1014x688_scrot

May i will need to rebuild all my toolchain? 🤷🏽‍♂️ 😕

takusuman commented 3 years ago

Could you share with us the config.mak or you've used that which i wrote at extra/alt/cgnutools_7a-netbsd-curses?

Sure. I only built dynamic libraries and the program binaries.

# Build.
time { make CC="${CMLFS_TARGET}-gcc" all-dynamic; }

# Install.
time { make PREFIX=/cgnutools install-dynamic; }

Nice, i was doing all. May i edit that later.

takusuman commented 3 years ago

Well, may the problem is just mine. I will try to rebuild the entire toolchain, if i got any progress i will update this issue.

PS: May it was because ncurses was being compiled with the host GCC and not the toolchain one. Why? I don't know, i've setted CC=${CMLFS_TARGET}-gcc, it shouldn't being using host's GCC.

PS²: Besides that, i also figured out that i may have messed up with musl libc when fixing that link.

takusuman commented 3 years ago

I'm not sure, but i think i figured out what actually happened. I didn't unset'd LDFLAGS after 5-GCC-final, so may this is the cause to ncurses being mislinked.

dslm4515 commented 3 years ago

Hmm, mine is fine using netbsd-curses .. 🤔

I’d say this the curse of ncurses!

takusuman commented 3 years ago

Well, in fact, i think i've discovered the real problem here. When i was compiling LLVM (and ncurses), i was trying to ld it to the host and not to the /cgnutools toolchain. That was solved (at least i think, i'm compiling LLVM now with @owl4ce's last patch to remove ncurses dependency) using LDFLAGS="-Wl,-rpath,/cgnutools/lib", which was referenced before at the 25th line in 5-GCC-final.

I don't know if it's my host's (Arch Linux with LTS kernel) problem or if the docs are wrong in don't exporting LDFLAGS.

If you guys have any objection to this, just say. I'm closing this issue.

owl4ce commented 3 years ago

When i was compiling LLVM (and ncurses), i was trying to ld it to the host and not to the /cgnutools toolchain.

@takusuman

So strange, the GCC in the cgnutools should invoke the linker to links againts /cgnutools/lib/ld-musl-x86_64.so.1. https://github.com/dslm4515/CMLFS/blob/1b8e2d734003e3dc84dc3f7656cef4fd1c08c6b1/1-cgnutools/5-GCC-final#L53-L70

Also .. in my builds, I don't use these stuffs. The last, I only use make command. https://github.com/dslm4515/CMLFS/blob/1b8e2d734003e3dc84dc3f7656cef4fd1c08c6b1/1-cgnutools/5-GCC-final#L25 https://github.com/dslm4515/CMLFS/blob/1b8e2d734003e3dc84dc3f7656cef4fd1c08c6b1/1-cgnutools/5-GCC-final#L47-L48

takusuman commented 3 years ago

When i was compiling LLVM (and ncurses), i was trying to ld it to the host and not to the /cgnutools toolchain.

@takusuman

So strange, the GCC in the cgnutools should invoke the linker to links againts /cgnutools/lib/ld-musl-x86_64.so.1.

https://github.com/dslm4515/CMLFS/blob/1b8e2d734003e3dc84dc3f7656cef4fd1c08c6b1/1-cgnutools/5-GCC-final#L53-L70

Also .. in my builds, I don't use these stuffs. The last, I only use make command.

https://github.com/dslm4515/CMLFS/blob/1b8e2d734003e3dc84dc3f7656cef4fd1c08c6b1/1-cgnutools/5-GCC-final#L25

https://github.com/dslm4515/CMLFS/blob/1b8e2d734003e3dc84dc3f7656cef4fd1c08c6b1/1-cgnutools/5-GCC-final#L47-L48

Well, and it was, at least the dummy.c that i compiled at this step was linked to cgnutools' libc; but for some reason, after file, it was trying to link to host's libc. That's weird, really weird-- for some reason, compiling things on Arch always leads to weird and interesting errors. Well, let's see if LLVM will work anyway.

takusuman commented 3 years ago

Btw, i'll reopen as this can be a really interesting discussion.

owl4ce commented 3 years ago

Btw, i'll reopen as this can be a really interesting discussion.

Should migrate to discussion tab. 😄

takusuman commented 3 years ago

Btw, i'll reopen as this can be a really interesting discussion.

Should migrate to discussion tab. smile

How could i do this? 🧐 Although using GitHub since 2019, i still don't know how to use some features.

owl4ce commented 3 years ago

How could i do this? 🧐

Only maintainer can do that, otherwise you can start a new discussion.

takusuman commented 3 years ago

How could i do this? monocle_face

Only maintainer can do that, otherwise you can start a new discussion.

Well, may @dslm4515 could do this for us. 😃