[klibc] [klibc:master] README.klibc: update build information

Neal Murphy neal.p.murphy at alum.wpi.edu
Wed Aug 21 10:33:08 PDT 2013

On Wednesday, August 21, 2013 11:36:03 AM klibc-bot for maximilian attems 
> Commit-ID:  25a66fa8d8623fae267f6807b56438cd7c40e034
> Gitweb:    
> http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=25a66fa8d8623fae2
> 67f6807b56438cd7c40e034 Author:     maximilian attems <max at stro.at>
> AuthorDate: Wed, 21 Aug 2013 17:31:25 +0200
> Committer:  maximilian attems <max at stro.at>
> CommitDate: Wed, 21 Aug 2013 17:32:16 +0200
> README.klibc: update build information
> It seems this file was still conveying the old way to build klibc
> and hence confusing the users, simplify and reword build instructions.
> Signed-off-by: maximilian attems <max at stro.at>
> ---
>  usr/klibc/README.klibc | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> diff --git a/usr/klibc/README.klibc b/usr/klibc/README.klibc
> index 47618ec..7de5fea 100644
> --- a/usr/klibc/README.klibc
> +++ b/usr/klibc/README.klibc
> @@ -7,13 +7,12 @@ work in progress, and a lot of things are still missing.
>  The build procedure is not very polished yet, but it should work like
>  this:
> -a) In the source root directory (the directory above the one in which
> -   this file is found) create a symlink called "linux" pointing to the
> -   target of "make headers_install" from a recent Linux kernel tree.
> -   This can be done by extracting the Linux kernel into a directory,
> -   running "make headers_install" for the appropriate architecture,
> -   and then making a symlink to the "usr" subdirectory of that directory
> -   tree.
> +a) Extract a recent Linux kernel into a directory and run
> +   "make headers_install".
> +   Now enter the klibc dir and point KLIBCKERNELSRC to the
> +   path of the configured linux tree
> +   "make  KLIBCKERNELSRC=`pwd`/../linux/usr/".
> +

If I may, this is still too confusing; the bit about making the symlink to the 
kernel headers is gone.  And the symlink must be in the klibc source root dir 
(usr/klibc/../..), not in "usr/klibc/..". The problem is that the makefile 
uses -nostdinc (which should prevent the host from polluting the build).

I think I understand how the build works now. It is inconsistent. As a first 
proposal, how about:

The build procedure isn't very polished, but it does work. It uses -nostdinc 
so that the build host does not pollute the compile. So you must provide a 
symlink to valid kernel headers for your desired target.

To compile klibc
 a) Extract a recent kernel (e.g. 3.10.9) into a directory (e.g., /usr/src),
    provide a .config file and run "make headers_install". If you are building
    a distro, you should already have fresh kernel headers to hand; use them.
 b) Enter the klibc source root dir (e.g. "cd .../klibc-2.0.2") and make a
    symlink to the usr/ dir (the dir that contains 'include/') in that
    kernel tree:
        "ln -s /usr/src/linux-3.10.9/usr linux"

    The symlink can point to any dir where valid kernel headers have been
    installed. For example, if you are building in a chroot jail and the
    kernel headers have been installed in /usr/include, you could:
        "ln -s /usr linux"
 c) Now, still in the klibc source root dir, run "make" (or "make all").
klibc will now successfully build.

To install klibc
Install again uses -nostdinc. Also, for those building a binary package for 
distribution, set INSTALLROOT to point to the root of your pkg dir (e.g., 
INSTALLROOT=/home/my_distro/build/buildroot/klibc). INSTALLROOT defaults to 
""; it will install on your host which may not be what you want. Also, instead 
of using the 'linux' symlink you create to compile, you will use the 
KLIBCKERNELSRC variable to point to the same place. Thus, installing is a two-
step process:
 a) cd to the klibc root source dir (e.g., "cd .../klibc-2.0.2")
 b) Now run 'make KLIBCKERNELSRC="`pwd`/linux" install' to install to your
    root filesystem.

    To prepare to make an installable package, run:
    'make INSTALLROOT="klibc pkg root' KLIBCKERNELSRC="`pwd`/linux" install'
klibc will now be installed on your system or will be ready to be packaged.

The compile step is OK. It works. This world is perfect (or nearly so).

Alas, there's trouble in Install City. The 'install:' make rule is wrong 
because the makefile runs 'make headers_install'. If klibc needs a copy of the 
headers in its /lib/klibc dir, it should just copy them from the location it 
was directed to (KLIBCKERNELSRC). One of Leroy's patches correct this problem.

The install make rule is also wrong because KLIBCKERNELSRC really should 
default to the symlink created to compile the pkg. If those headers were good 
enough to compile, they should be good enough to install.

Leroy's other patch corrects a bug in Kbuild, where $(INSTALLDIR) was 
inadvertently omitted.

Again, I inquire why 'make install' compiles, links or assembles anything; 
those actions should have been completed in the compile stage. The install 
stage should only copy files to the desired location.

As I said above, my suggestion is a proposal because more changes are needed 
to tidy the build.
  - Would it be preferred to use KLIBCKERNELSRC to point to the kernel headers
    for *both* compile and install?
  - Or would it be preferred to simply use the created symlink (e.g.,
    klibc-2.0.2/linux) to point to the kernel headers for both compile and


More information about the klibc mailing list