How to compile glibc?

Using applications, configuring, problems
Message
Author
User avatar
john biles
Posts: 1458
Joined: Sun 17 Sep 2006, 14:05
Location: Australia
Contact:

How to compile glibc?

#1 Post by john biles »

Hello Everyone,
I want to compile a newer glibc and the install file has this.
GNU libc cannot be compiled in the source directory. You must build it
in a separate build directory. For example, if you have unpacked the
glibc sources in `/src/gnu/glibc-2.4', create a directory
`/src/gnu/glibc-build' to put the object files in. This allows
removing the whole build directory in case an error occurs, which is
the safest way to get a fresh start and should always be done.

From your object directory, run the shell script `configure' located
at the top level of the source tree. In the scenario above, you'd type

$ ../glibc-2.4/configure ARGS...

Please note that even though you're building in a separate build
directory, the compilation needs to modify a few files in the source
directory, especially some files in the manual subdirectory.

I made the /src/gnu/glibc-build directory now what are these so called "object files" and how do I get them into the /src/gnu/glibc-build Directory.

What do I write in terminal to do this?
Legacy OS 2017 has been released.

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#2 Post by Sit Heel Speak »

Hi John,

The obvious (and probably wrong) answer would be something like this:

Code: Select all

export CHOST=

User avatar
john biles
Posts: 1458
Joined: Sun 17 Sep 2006, 14:05
Location: Australia
Contact:

#3 Post by john biles »

Hello Sit Heel Speak,
I want to update glibc 2.3.5 in puppy 2.14 to glibc 2.7
I'm using the devx_214sfs package.
I thought that may be I could compile it against the 2.6.18.1 kernel and remaster.
I'm getting the feeling it's a waste of time trying.
Just out of interest? could it be done? has it been done?
Legacy OS 2017 has been released.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#4 Post by mikeb »

What app is demanding a newer glibc?

mike

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#5 Post by Sit Heel Speak »

Good morning, John,

As far as I know, you'll be the pioneer. I gather that libc 2.7 has wider locale support than 2.3.5. Sufficient reason IMHO for a Puppyist to try it. Besides, failure is harmless to the computer and gives you a manly physique, provided you have either a backup of your savefile, or > about 200 MB free space on the host drive.

Change into the glibc-build subdir and issue simply

Code: Select all

../configure --prefix=/src/gnu/glibc-build
which will take only a minute or two. Then run

Code: Select all

make
and come back in half an hour or so. Then, let us see what errors it exited ungracefully with, if any.

User avatar
john biles
Posts: 1458
Joined: Sun 17 Sep 2006, 14:05
Location: Australia
Contact:

#6 Post by john biles »

Hello mikeb,
As I am the creator of TEENpup, I want to update it base libs to be of use to anyone currently using TEENpup. So it's not just for me.

Hello Sit Heel Speak,
I will be away all day and will try your again with your terminal instructions when I get home. Thank You :D
Legacy OS 2017 has been released.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#7 Post by mikeb »

Ok

I updated to glibc 2.3.6 with TLS on puppy 2.xx which supports latest wine, qt and some other apps. Thats why I was asking as not everything needs glibc 2.4+.

regards

mike

User avatar
john biles
Posts: 1458
Joined: Sun 17 Sep 2006, 14:05
Location: Australia
Contact:

#8 Post by john biles »

Hello Sit Heel Speak,
I came home and tried your instructions with no luck.

I'm in the /src/gnu/glibc-build directory and type in your command ../configure --prefix=/src/gnu/glibc-build in the terminal and all I get is the files not found.
I try the same command in /src/gnu/glibc-2.7 and I get told I can't compile in the same folder what am I doing wrong?

Sit Heel Speak,
Can you just pretend that you have just downloaded the file and have opened a terminal, you untar the files change directory etc. While I've created TEENpup from many different packages from many different distro's. I haven't done much compiling. I am a real newbie at it.

So once again imagine your siting in front of your PC with the file just downloaded to your PC, you open a terminal and type what?? to get this lib compiling.
Legacy OS 2017 has been released.

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#9 Post by Sit Heel Speak »

Hi John,

Let's try going from where you are, first, before I resort to writing another one of my novel-length how-to's.

When it says to create glibc-build, it means create it as a subdir of whatever folder you unpacked to. In your case this was (I think) /src/gnu/glibc-2.7 --the file "configure" and about 122 other items should be in this. So, if I understand correctly, you would issue

Code: Select all

cd /src/gnu/glibc-2.7
mkdir ./glibc-build
cd glibc-build
../configure --prefix=/src/gnu/glibc-2.7/glibc-build
make
and this should populate glibc-build with many new items, which you can see the progress of, if you keep a rox window open to the initially-empty glibc-build while doing the configure+make in an rxvt window off to the side of or below the rox window.

If for some reason the above code does not work, then let me duplicate your steps so I can see what's going on. First, which 2.14 are you starting from--i.e. standard Puppy 2.14, TeenPup, Rudy Puppy, pakt-and-Dougal's 2.14R, or...?

When I compile the Gnu gcc and coreutils and so forth, I habitually unpack to a subfolder named after the gcc version and then to separate subfolders of that for gcc, glibc, g++ and the coreutils, in other words I create subfolder gcc-4.3.2 in /root/my-applications and unpack glibc to

/root/my-applications/gcc-4.3.2/glibc-2.6.1

but there is no particular advantage to this placement. Where you placed it, /src, is as good as any. If I used an unpack-subfolder named src I would probably instead choose /usr/src just from force of habit, since /usr/src/linux-2.6.n(.n) is where kernel source for custom-compiling the kernel goes.

But there is no reason why you can't do the glibc compile anywhere you want, even on a mounted partition e.g. /mnt/sda1.

Keep us advised of progress,
Philip

User avatar
john biles
Posts: 1458
Joined: Sun 17 Sep 2006, 14:05
Location: Australia
Contact:

#10 Post by john biles »

Hello Sit Heel Speak,
Thank you for your reply. I've have just enough time to check the forum as I have to go to Work. It's 10am at the moment so hopefully tonight I will be able to try again. Again thank you for the help your giving.

I trying to compile with TEENpup 2008 which still has all the same base files as Puppy 2.14
If I have trouble when it does finally want to start the compiling process with TEENpup, I'll run the same experiment with the original Puppy 2.14 iso
Legacy OS 2017 has been released.

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#11 Post by Sit Heel Speak »

You're quite welcome. I look forward to seeing the new TeenPup.

I'll be out of town and offline til Monday evening Seattle time, GMT-9. I guess that's Tuesday morning in Australia, where you are (i.e. it's quarter to five PM Saturday here, as I write this).

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#12 Post by amigo »

You can't simply update glibc. Everything on your system revolves around the specific glibc version and the headers it was compiled against. Updating, or re-compiling to change the optimizations of glibc is the same as bootstrapping a new system. If you simply recompile it as any other app, you will find that most of your system is broken. Go read up on Linux From Scratch to learn how to do this.
BTW, run this command:
/lib/libc.so.6
and post the output. That will you/us exactly what glibc you are worling with.

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#13 Post by Sit Heel Speak »

amigo wrote:You can't simply update glibc. Everything on your system revolves around the specific glibc version and the headers it was compiled against...
I could be wrong, and if I am then please point out an example of what will crash...but I did consider that, and don't think it's as apocalyptic as you claim.

John will be going from glibc 2.3.5 compiled under k2.6.12.5 (and already running smoothly under k2.6.18.1) to glibc 2.7 compiled under k2.6.18.1. Unless I'm wildly mistaken--and I admit it would not be the first time--it is not that radical a difference.

But I agree that John will need the kernel headers. I was overlooking that simply because, every time I have updated glibc, it has been as a step in compiling a new kernel. So I'm updating the kernel, gcc, glibc, binutils, the loadable modules, java etc. --everything all at once, pretty much as per Linux From Scratch.

But as long as John has the correct kernel headers, and compiles into a scratch directory first, I don't see where he will have any problem.

May I presume the needed headers are in

http://puptrix.org/sources/kernel-2.6.1 ... 14.tar.bz2

?

User avatar
john biles
Posts: 1458
Joined: Sun 17 Sep 2006, 14:05
Location: Australia
Contact:

#14 Post by john biles »

Hello Sit Heel Speak,
Using your sequence of steps in Terminal I could finally compile glibc 2.7 but it errored out with an error2 message.
May be these header things are needed. Where do you put them?
Also Sit Heel Speak I'm thinking of just rebuilding TEENpup into Puppy 4.1.1 it has glibc 2.6.1 which is a step in the right direction.

Hello amigo,
In building TEENpup 2008 I have taken apps that have been compiled on older and newer glibc's (glibc 2.2 and glibc 2.4) as well as different kernels with a very good success rate. While some give the dreaded "segment fault" a lot don't.
Legacy OS 2017 has been released.

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#15 Post by Sit Heel Speak »

Just a moment...or a day or two or three or four...the Thanksgiving holiday is coming up here, so I will have Friday and the weekend free. If you are thinking of changing the TeenPup base to Puppy 4.1.1...TeenPup being the eclectic collage that it is...then I want to try it myself before dispensing advice.

Barry's patched kernel source is designed to be downloaded to and unpacked in /usr/src so that you end up with a subdir /usr/src/linux-2.6.18.1 (or whatever kernel version number). Then, you should create a relative symlink /usr/src/linux which points to it. This is the standard arrangement in all Linux distro's for setting up kernel compilation. Obviously, if for safety's sake you unpack the Barry-source .tar.bz2 archive to a scratchdir, then before drag'n'dropping it over you first need to create subdir /usr/src.

The headers are all the files within the /usr/src/linux-2.6.n(.n) subdir tree that have the extension .h. In a nutshell: the program's headers define the global data structures which all subroutines under the program's source (.c) code reference.

By 2.4-kernel-era convention and in many if not most other 2.6 Linuxes, including source obtained from Linus's own kernel.org, some, or even a great many, kernel-compile-time headers (depending on what objects you select in "make menuconfig"), and the majority of application-compile-time headers, are stationed in /usr/include.

So, while in compiling just Barry's kernels for my own relatively older hardware I have not found this to be of concern, when compiling a third-party app, for example VLC, or when compiling the kernel from kernel.org source for either very new or else very old hardware, you must peruse the compile output (no matter whether it's the kernel or an app you are compiling) to make sure that make (or whatever linker you use) didn't look for (and not find) needed headers in /usr/include.

I don't know whether or not the compile of glibc requires any header(s) from /usr/include not present in 2.14's (or 4.1.1's) Barry's-patched-kernel /usr/src/linux-2.6.n.n source tree. My Puppies get extravagantly added-onto with such wild abandon or foolish recklessness, depending on point of view, that, almost every time I've discovered make to need /usr/include headers, they've already been present from some previous compiling jag.

So,...(deep breath)...if your compile fails because missing one or more headers, then you must either go out on the web (or some CD/DVD) and get them, and put them either in /usr/include or in whatever subdir of /usr/src/linux that your make error tells you that make expected to find them in.

One big advantage to Puppy 3 (which is, in a nutshell, Slackware 12.1 meticulously, painstakingly shorn-and-shoehorned with Barry's usual extreme craftsmanship into the Puppy architecture and init scripts) over Puppy 4 is, all desired headers are practically guaranteeable to be somewhere in the vast Slackware 12.1 trove. If you have Barry's source and make tells you it needs a header that is not present in /usr/include, and PFind can find it in the /usr/src/linux kernel-source tree, then you just copy it over and try the compile again.

And so...if you are going to rebuild the whole TeenPup shebang...and are contemplating whether or not to re-base it on Puppy 4.1.1, which implies a "from scratch" rebuild...let me try it first myself, including the upgrade-compile to glibc 2.7, before I dare to boldly offer further questionable advice where no man has gone before.

HTH, SHS

User avatar
john biles
Posts: 1458
Joined: Sun 17 Sep 2006, 14:05
Location: Australia
Contact:

#16 Post by john biles »

Hello Sit Heel Speak,
Thank you for this interesting info. I've been experimenting for a few days with Puppy 4.1.1 and while there is success, there's also a lot of problems coming up as well. I think it will take along time to get the bugs out. I don't think I have the talent to compile a new glibc without your help. I'm 95% of the way with TEENpup 2008 EVO the last TEENpup based on Puppy 2.14 and think I will finish that first.
Legacy OS 2017 has been released.

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#17 Post by Sit Heel Speak »

I now have the next three days free and clear, and intend to figure this out. Stay tuned.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#18 Post by amigo »

Compiling glibc does not require any of the headers under /usr/include. It will supply some though, once installed. To compile glibc you must point the configure script specfically at the headers included in the kernel sources. The raw headers are under the 'include' directory in the kernel sources. However, it is not a good idea to use the raw headers -especially with kernel 2.6. For older 2.6 kernel versions, a package was made available of 'sanitized' headers for use when compiling glibc or other programs. For kernel >=2.6.18 you can create these sanitized headers with the command make headers_check && make headers_install. This will create a directory called 'usr' insode the kernel sources and copy the sanitized headers there. To compile glibc you should point the config script to these headers with --with-kernel-includes=/usr/src/linux-X.X.X/usr/include.

When building a distro from scratch, these kernel headers are then included in the /usr/include directory -the subdirs 'linux' , 'asm-generic' and 'asm' (which is a link to 'asm-i386' or whatever the architecture you are running. These are usually called libc-headers or kernel-headers(Slackware). It is important that these be the same headers which were used to compile glibc with and have nothing at all to do with the kernel version which is running. these headers should never be upgraded even when using a later kernel.

When building glibc, you should provide a target -this is something like: 'i486-slackware-linux' or 'i386-pc-linux-gnu'. This target is supposed to match the target which is used to compile binutils and the gcc compiler collection. These three must be matched or they will not run, and you can't arbitrarily change them without going through a bootstrap sequence which, in the end, provides you with a glib which was compiled with the binutils and gcc using the same target -which were in turn compiled against the new libs. This is why it takes more thasn one 'pass' of compiling these three so that you get a finished toolchain.

For the OP's purposes, a new glibc could be compiled using the existing toolchain and installed in a non-standard directory. Then programs could be manually linked against those libs and then the programs run using a wrapper which would set the LD_LIBRARY_PATH to the location where these libs are installed.
While true that many programs will be able to run even with a different version of glibc than what they were compiled for, the most important programs will not -namely the toolchain.

Do have a look at the output from this command:
/lib/libc.so.6
It will tell you which compiler and kernel headers were used to compile your running glibc with. To find out which target was used, look under /usr for a unique directory named 'i?86-something-something' -I mean with the system compiler and binutils installed. Running 'gcc -dumpspecs' will give you some info about how the compiler was compiled. I somehow doubt that you'll be able to get more info than that unless you are using one of the Puppy versions
built from T2. Other versions are patched together from sundry binaries from any old source -which explains why so many things don't work as they should. I really doubt that Barry knows enough to bootstrap a distro without some build system like T2 or whatever.

I strongly recommend not installing a new glibc, compiler or binutils over existing ones until you know what you are doing, or at least know enough to be able to access a non-bootable system to recover from a disaster. It is not for no reason that very few people fool around with such things.
Have fun compiling glibc! It will make you have a hairy chest...

User avatar
Sit Heel Speak
Posts: 2595
Joined: Fri 31 Mar 2006, 03:22
Location: downwind

#19 Post by Sit Heel Speak »

I've just finished testing, to my satisfaction, a recompiled 2.6.25.16 kernel built using the new glibc-2.7, and am just about ready to write instructions out for John, and for anyone else who is interested.

There are six questions I need help with, first; and then, I just received my 4.1.1 Unleashed CD today, and want to see how my steps and their result interfaces with Unleashed, before I describe the procedure.

Questions:

1. (deleted by poster, I now know the answer)

2. I know that Barry, in making a Puppy, omits the man pages which an ordinary compile produces. Are there any other omissions?

3. Since I am building on a P4, gcc automatically targets for i686 (i.e. Pentium Pro and higher). I don't know of any problems this might cause, but it does result in a set of the e.g. binutils being created in /usr/i686-pc-linux-gnu instead of Barry's default of /usr/i486-t2-linux-gnu. Is there any problem with that? Will it harm anything if I remove the folder /usr/i486-t2-linux-gnu?

4. (deleted by poster, I now know the answer)

5. A related question: can someone advise me exactly what Barry et al mean, when referring to a "conservative" kernel? What has been found to successfully shut down an e.g. SIS chipset?

6. (deleted by poster, I've decided which choice to make)
Last edited by Sit Heel Speak on Sat 29 Nov 2008, 20:25, edited 1 time in total.

User avatar
john biles
Posts: 1458
Joined: Sun 17 Sep 2006, 14:05
Location: Australia
Contact:

#20 Post by john biles »

Hello Sit Heel Speak,
I hope your instructions will include kernel 2.6.18.1 and not just 2.6.25.16
I think that if the Puppy 2 series has access to a later version of glibc then this will extend the life of the puppy 2 series.
I thank you for this work your doing and know that it will benefit a lot of Puppy users out there.
Again Thank You!
Legacy OS 2017 has been released.

Post Reply