diff options
author | Bryan Hundven <bryanhundven@gmail.com> | 2014-08-01 02:01:46 (GMT) |
---|---|---|
committer | Yann E. MORIN <yann.morin.1998@free.fr> | 2014-08-08 20:49:37 (GMT) |
commit | 52260ccebb73465eacbc292bdc343bdd75e14801 (patch) | |
tree | 5c3bc3421aabafccea418618a04d8f7b2b30bc98 /scripts/build/libc | |
parent | 152b7ad4b456eec1ef7f1174c6c18074d35c66b5 (diff) |
libc/musl: add musl-libc support
This patch adds initial support for musl-libc.
Musl-libc versions currently supported:
* 1.0.3 (Stable)
* 1.1.3 (Previous Mainline)
* 1.1.4 (Mainline)
Futher improvements are needed.
* gcc-4.9.x has issues (Might be fixed in musl-1.1.4).
* Multilib support is needed.
* Checks to make sure paths are correct.
* Move to 2-step gcc build. 3-step build is not necessary.
Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
[yann.morin.1998@free.fr: removed the gcc musl patch, to be added later;
removed dead code do_get_arch()]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Diffstat (limited to 'scripts/build/libc')
-rw-r--r-- | scripts/build/libc/musl.sh | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh new file mode 100644 index 0000000..7172cf2 --- /dev/null +++ b/scripts/build/libc/musl.sh @@ -0,0 +1,103 @@ +# This file adds functions to build the musl C library +# Copyright 2013 Timo Teräs +# Licensed under the GPL v2. See COPYING in the root of this package + +do_libc_get() { + local libc_src + + libc_src="http://www.musl-libc.org/releases" + + if [ "${CT_LIBC_MUSL_CUSTOM}" = "y" ]; then + CT_GetCustom "musl" "${CT_LIBC_VERSION}" \ + "${CT_LIBC_MUSL_CUSTOM_LOCATION}" + else # ! custom location + CT_GetFile "musl-${CT_LIBC_VERSION}" "${libc_src}" + fi # ! custom location +} + +do_libc_extract() { + # If using custom directory location, nothing to do. + if [ "${CT_LIBC_MUSL_CUSTOM}" = "y" ]; then + # Abort if the custom directory is not found. + if ! [ -d "${CT_SRC_DIR}/musl-${CT_LIBC_VERSION}" ]; then + CT_Abort "Directory not found: ${CT_SRC_DIR}/musl-${CT_LIBC_VERSION}" + fi + + return 0 + fi + + CT_Extract "musl-${CT_LIBC_VERSION}" + CT_Patch "musl" "${CT_LIBC_VERSION}" +} + +do_libc_check_config() { + : +} + +do_libc_configure() { + CT_DoLog EXTRA "Configuring C library" + local -a extra_cflags + + # From buildroot: + # gcc constant folding bug with weak aliases workaround + # See http://www.openwall.com/lists/musl/2014/05/15/1 + if [ "${CT_CC_GCC_4_9_or_later}" = "y" ]; then + extra_cflags+=("-fno-toplevel-reorder") + fi + + # NOTE: musl handles the build/host/target a little bit differently + # then one would expect: + # build : not used + # host : the machine building musl + # target : the machine musl runs on + CT_DoExecLog CFG \ + CFLAGS="${extra_cflags[@]}" \ + CROSS_COMPILE="${CT_TARGET}-" \ + ./configure \ + --host="${CT_TARGET}" \ + --target="${CT_TARGET}" \ + --prefix="/usr" \ + --disable-gcc-wrapper +} + +do_libc_start_files() { + CT_DoStep INFO "Installing C library headers" + + # Simply copy files until musl has the ability to build out-of-tree + CT_DoLog EXTRA "Copying sources to build directory" + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/musl-${CT_LIBC_VERSION}" \ + "${CT_BUILD_DIR}/build-libc-headers" + cd "${CT_BUILD_DIR}/build-libc-headers" + + do_libc_configure + + CT_DoLog EXTRA "Installing headers" + CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install-headers + + CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" \ + crt/crt1.o crt/crti.o crt/crtn.o + CT_DoExecLog ALL cp -av crt/crt*.o "${CT_SYSROOT_DIR}/usr/lib" + CT_DoExecLog ALL ${CT_TARGET}-gcc -nostdlib \ + -nostartfiles -shared -x c /dev/null -o "${CT_SYSROOT_DIR}/usr/lib/libc.so" + CT_EndStep +} + +do_libc() { + CT_DoStep INFO "Installing C library" + + # Simply copy files until musl has the ability to build out-of-tree + CT_DoLog EXTRA "Copying sources to build directory" + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/musl-${CT_LIBC_VERSION}" \ + "${CT_BUILD_DIR}/build-libc" + cd "${CT_BUILD_DIR}/build-libc" + + do_libc_configure + + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make ${JOBSFLAGS} + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install + + CT_EndStep +} |