[klibc] Detecting KLIBC from userspace

Martin Schlemmer azarah at nosferatu.za.org
Sun Mar 6 07:41:24 PST 2005


Hi

Currently I am trying to get device-mapper and dmraid ported to compile
against klibc.  So far there was no real issues, as the only thing they
used was fscanf and feof not available presently in klibc (but easy to
work around).

Other than that there are really no way to easily check for installed
klibc's other than trying to mangle the output of klcc (from adjusted
configure.in):

-----
dnl Enables linking to klibc
dnl We need to do this before header checks, as we need to set CFLAGS
AC_ARG_ENABLE(klibc, [  --enable-klibc            Use this to link the tools to klibc.
                          Set KLCC to the absolute file name of klcc if not
                          in the PATH. ],  \
KLIBC=yes, KLIBC=no)

if test x$KLIBC = xyes; then
        dnl Basic cross compiling support.  I do not think it is wise to use
        dnl AC_CHECK_TOOL, because if we are cross compiling, we do not want
        dnl just 'klcc' to be returned ...
        if test x$cross_compiling = xyes; then
                AC_CHECK_PROGS(KLCC, ${host_alias}-klcc, no)
        else
                AC_CHECK_PROGS(KLCC, klcc, no)
        fi
        if test x$KLCC = xno; then
                AC_MSG_ERROR(Cannot find klibc frontend 'klcc'!)
                exit 1
        fi
        dnl Check what CFLAGS klcc passes to gcc, but filter gcc, -g
        dnl and the -v option we passed
        CFLAGS="`$KLCC -v -c 2>&1 | $AWK '{ $1 = ""; gsub(/(^| )(-v|-g)( +|$)/, " "); print; exit }'`"
        dnl Check what LDFLAGS klcc passes to ld, but filter ld and '-o a.out'
        KLIBC_LDFLAGS="`$KLCC -v 2>&1 | $AWK '{ $1 = ""; gsub(/(^| )-o *[[^ ]]*( +|$)/, " "); print; exit }'`"
        KLIBC_LIBDIR="`echo $KLIBC_LDFLAGS | sed -e 's:\(^.* \|^\)\(/[[^[:space:]]]*\)/crt0.o.*:\2:'`"
        FLAVOUR="klibc "
fi
-----

Which is imho ugly.  Anyhow, how about attached patch that produces a
klibc-config which can be used to retrieve all needed info to build
against klibc (or even cross-compiled versions of klibc if need be) ?

Comments or suggestions will be appreciated.


Thanks,

-- 
Martin Schlemmer



-- 
---------------------[ Ciphire Signature ]----------------------
From: azarah at nosferatu.za.org signed email body (1516 characters)
Date: on 06 March 2005 at 15:38:26 UTC
To:   klibc at zytor.com
----------------------------------------------------------------
: Ciphire has secured this email against identity theft.
: Free download at www.ciphire.com. The garbled lines
: below are the sender's verifiable digital signature.
----------------------------------------------------------------
00fAAAAAEAAADyIytC7AUAAPACAAIAAgACACAjYe/qeWoHRrdDE3mOifT0WPgp92
kbkclxgX1lQsV9VwEAJOQiG+Djg3e7Ai63e8AMF0Hl/gle8q4Ud88Lecx5fcVWcY
60TLaOA6zKSRpkf0V2K1C8j1cmJFTt9h9IvCCAZg==
------------------[ End Ciphire Signed Message ]----------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: klibc-0.213-klibc-config.patch
Type: text/x-patch
Size: 6672 bytes
Desc: not available
Url : http://www.vas.nu/pipermail/klibc/attachments/20050306/941cdfec/klibc-0.213-klibc-config.bin
-------------- next part --------------
---------------------[ Ciphire Signature ]----------------------
From: azarah at nosferatu.za.org signed 'text' (6931 bytes)
Date: on 06 March 2005 at 15:38:26 UTC
To:   klibc at zytor.com
----------------------------------------------------------------
: Ciphire has secured this email against identity theft.
: Free download at www.ciphire.com. The garbled lines
: below are the sender's verifiable digital signature.
----------------------------------------------------------------
01fAAAAAEAAADyIytCExsAAC0CAAIAAgACACAjYe/qeWoHRrdDE3mOifT0WPgp92
kbkclxgX1lQsV9VwEAJOQiG+Djg3e7Ai63e8AMF0Hl/gle8q4Ud88Lecx5fcWzo+
+FWYXPjFL0tm66mHEesIs6jFVgzK+jq62QX7OWLw==
--------------------[ End Ciphire Signature ]-------------------


More information about the klibc mailing list