2

I was attempting to just compile glibc version 2.31, by first installing the dependencies by running:

and then glibc as stated here:

mkdir /home/machine/Desktop/glibc-build

then change it to current directory:

cd /home/machine/Desktop/glibc-build

and after that execute configure from the source directory:

/home/machine/Desktop/glib-xxx/./configure --prefix=/usr

One of the user even mentioned

glibc IS YOUR operating system

But doing so indeed broke my system. First I lost typical linux terminal commands such as ls then after restarting my system I got:

kernel panic - not syncing: Attempted to kill init! exit code 0x00007f00

Question How does mere compiling broke my system? As I understand Ubuntu's glibc reside in /lib/ while I was merely trying to compile it in /usr/, so how did without replacing the systems glibc broke my system? Also my laptop doesnt show full error dump so is there any way to read full terminal output during booting as I cant access /var/ anymore?

My system is using Ubuntu 18.04.6 LTS

user0193
  • 123
  • 3
    I don't know the answer to your question. I know enough to definitely not attempt compiling glibc and putting it in /usr, though. You probably should have set the prefix to your home directory and see if anything broke first... On my system, when I type which ls, it says that it resides in /usr/bin/ls. When I do an strace ls, it does (unsuccessfully, though) look for things in /usr. Might not be important...but it wasn't a good idea to try... – Ray Jan 12 '23 at 22:10
  • @guiverc thanks I was revising my question and got your comment – user0193 Jan 12 '23 at 22:11
  • @Ray its quite funny that someone in the forum mentioned not to rather put glibc in /opt – user0193 Jan 12 '23 at 22:15
  • 1
    These days, /lib is really /usr/lib (likewise bin and sbin), See ls -l / to see the links, so not really as separate as you thought. – ubfan1 Jan 12 '23 at 22:23
  • 1
    imho "mere compiling" should always be done without root privileges - that way, there's no possibility to overwrite important system components – steeldriver Jan 12 '23 at 23:24

1 Answers1

0

First, compiling glibc didn't break your system. installing glibc over top of the existing one did.

On many modern systems, /usr/lib and /lib have been merged, and even if that's not the case, many of the libraries are in /usr/lib and not in /lib.

If you are going to compile a custom glibc, you should install it in something like /opt/myglibc/ (or something in your home directory) or target it at a chroot environment, rather than installing in a system directory. It's not even safe to install it in /usr/local/ because that could also override the default glibc unless you edit the system ld.so configuration to remove /usr/local/lib.

user10489
  • 4,051
  • I didn't know that configure also installs nowadays. The last time I built Glibc manually, installation was done by make using the install target. – Jörg W Mittag Jan 12 '23 at 23:52
  • But I did not install glibc over the top of existing one because the I was unable to compile the complete glibc successfully. There was an error and it did not compile completely – user0193 Jan 13 '23 at 10:55
  • I haven't looked at the build scripts, but if things broke, it sounds like at least some of it (or the dependencies you installed?) broke things. – user10489 Jan 13 '23 at 12:28
  • Word of advise... never build as root. Build as user. Unless you are very very sure what you are doing, don't even install as root. Instead, install to a shadow directory and then chown it if you want. Most build systems support doing that. It's extra work, and much safer, but occasionally not worth the extra work. I hit one software that actually had an rm -rf in its install script and wiped all my built dependencies, so I've been following this advise since. – user10489 Jan 13 '23 at 12:29
  • @user0193 it's hard to diagnose what happened without knowing exactly what source package you downloaded - the link in your question appears to go to the Debian glibc tracking page – steeldriver Jan 13 '23 at 14:33
  • @steeldriver I actually downloaded the glibc version 2.31-13+deb11u4 but regardless of the version, mere compiling the way I did shouldn't actually break the system but since its broken, it looks like Ubuntu 18.04.6 LTS have put glibc in /usr rather then in /opt – user0193 Jan 14 '23 at 13:39
  • 1
    Yes, Ubuntu (any version) puts glibc in /usr. My point was that if you compile glibc, you should put your special version in /opt – user10489 Jan 14 '23 at 18:15