From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17170 invoked by alias); 27 Jul 2014 01:05:20 -0000 Mailing-List: contact crossgcc-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: crossgcc-owner@sourceware.org Received: (qmail 15045 invoked by uid 89); 27 Jul 2014 01:05:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 27 Jul 2014 01:05:08 +0000 Received: by mail-pa0-f46.google.com with SMTP id lj1so8079450pab.5 for ; Sat, 26 Jul 2014 18:05:06 -0700 (PDT) X-Received: by 10.68.139.194 with SMTP id ra2mr28382215pbb.20.1406423106421; Sat, 26 Jul 2014 18:05:06 -0700 (PDT) Received: from slurpie.hsd1.wa.comcast.net (c-50-135-131-187.hsd1.wa.comcast.net. [50.135.131.187]) by mx.google.com with ESMTPSA id y4sm13140238pbt.60.2014.07.26.18.05.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Jul 2014 18:05:05 -0700 (PDT) From: Bryan Hundven To: "Yann E. MORIN" Cc: crossgcc@sourceware.org, Bryan Hundven Subject: [PATCH 2/3] Add support for musl-libc Date: Sun, 27 Jul 2014 01:05:00 -0000 Message-Id: <1406423095-18198-3-git-send-email-bryanhundven@gmail.com> In-Reply-To: <1406423095-18198-1-git-send-email-bryanhundven@gmail.com> References: <1406423095-18198-1-git-send-email-bryanhundven@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg00034.txt.bz2 "Musl-libc is a new standard library to power a new generation of Linux-based devices. musl is lightweight, fast, simple, free, and strives to be correct in the sense of standards-conformance and safety." This patch adds support for musl to be selected and built by crosstool-ng. NOTE: Experimental patches are needed for gcc and possibly other components. Later patches include this support. Signed-off-by: Bryan Hundven --- config/libc.in | 11 +++++ config/libc/musl.in | 47 +++++++++++++++++++ config/libc/musl.in.2 | 2 + scripts/build/arch/arm.sh | 1 + scripts/build/libc/musl.sh | 111 +++++++++++++++++++++++++++++++++++++++++++++ scripts/functions | 1 + 6 files changed, 173 insertions(+) create mode 100644 config/libc/musl.in create mode 100644 config/libc/musl.in.2 create mode 100644 scripts/build/libc/musl.sh diff --git a/config/libc.in b/config/libc.in index 03f5db2..ff9ce9e 100644 --- a/config/libc.in +++ b/config/libc.in @@ -28,6 +28,10 @@ config LIBC_SUPPORT_NPTL bool select LIBC_SUPPORT_THREADS_ANY +config LIBC_SUPPORT_MUSL + bool + select LIBC_SUPPORT_THREADS_ANY + config LIBC_SUPPORT_LINUXTHREADS bool select LIBC_SUPPORT_THREADS_ANY @@ -42,6 +46,7 @@ config LIBC_SUPPORT_THREADS_NONE config THREADS string default "nptl" if THREADS_NPTL + default "musl" if THREADS_MUSL default "linuxthreads" if THREADS_LINUXTHREADS default "win32" if THREADS_WIN32THREADS default "none" if THREADS_NONE || LIBC_none @@ -55,6 +60,7 @@ choice bool prompt "Threading implementation to use:" default THREADS_NPTL if LIBC_SUPPORT_NPTL + default THREADS_MUSL if LIBC_SUPPORT_MUSL default THREADS_LINUXTHREADS if LIBC_SUPPORT_LINUXTHREADS && ! LIBC_SUPPORT_NPTL default THREADS_WIN32 if LIBC_SUPPORT_WIN32THREADS default THREADS_NONE if ! LIBC_SUPPORT_THREADS_ANY @@ -64,6 +70,11 @@ config THREADS_NPTL prompt "nptl" depends on LIBC_SUPPORT_NPTL +config THREADS_MUSL + bool + prompt "musl" + depends on LIBC_SUPPORT_MUSL + config THREADS_LINUXTHREADS bool prompt "linuxthreads" diff --git a/config/libc/musl.in b/config/libc/musl.in new file mode 100644 index 0000000..69f465c --- /dev/null +++ b/config/libc/musl.in @@ -0,0 +1,47 @@ +# musl options + +## depends on ! WINDOWS && ! BARE_METAL +## +## select LIBC_SUPPORT_MUSL +## select CC_CORE_PASSES_NEEDED +## +## help Musl is a new standard library to power a new generation of Linux-based +## help devices. musl is lightweight, fast, simple, free, and strives to be +## help correct in the sense of standards-conformance and safety. + +choice + bool + prompt "musl version" +# Don't remove next line +# CT_INSERT_VERSION_BELOW + +config LIBC_MUSL_V_1_1_3 + bool + prompt "1.1.3 (Mainline)" + select LIBC_MUSL_DEFAULTS + depends on EXPERIMENTAL + +config LIBC_MUSL_V_1_0_3 + bool + prompt "1.0.3 (Stable)" + select LIBC_MUSL_DEFAULTS + +config LIBC_MUSL_V_CUSTOM + bool + prompt "Custom musl" + select LIBC_MUSL_DEFAULTS + depends on EXPERIMENTAL + +endchoice + +config LIBC_MUSL_DEFAULTS + bool + select LIBC_SUPPORT_MUSL + +config LIBC_VERSION + string +# Don't remove next line +# CT_INSERT_VERSION_STRING_BELOW + default "1.1.3" if LIBC_MUSL_V_1_1_3 + default "1.0.3" if LIBC_MUSL_V_1_0_3 + default "custom" if LIBC_MUSL_V_CUSTOM diff --git a/config/libc/musl.in.2 b/config/libc/musl.in.2 new file mode 100644 index 0000000..bf4fb71 --- /dev/null +++ b/config/libc/musl.in.2 @@ -0,0 +1,2 @@ +# musl second-part options + diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh index 430bdde..ba87e0c 100644 --- a/scripts/build/arch/arm.sh +++ b/scripts/build/arch/arm.sh @@ -17,6 +17,7 @@ CT_DoArchTupleValues() { case "${CT_LIBC},${CT_ARCH_ARM_EABI}" in *glibc,y) CT_TARGET_SYS=gnueabi;; uClibc,y) CT_TARGET_SYS=uclibcgnueabi;; + musl,y) CT_TARGET_SYS=muslgnueabi;; *,y) CT_TARGET_SYS=eabi;; esac diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh new file mode 100644 index 0000000..f72517c --- /dev/null +++ b/scripts/build/libc/musl.sh @@ -0,0 +1,111 @@ +# 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_BUILD}" \ + --target="${CT_TARGET}" \ + --prefix="/usr" \ + --disable-gcc-wrapper +} + +do_libc_start_files() { + local ARCH + + 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" + + # musl can be installed without gcc if arch is known + case "${CT_TARGET}" in + arm*) ARCH=arm ;; + i?86*) ARCH=i386 ;; + x86_64*) ARCH=x86_64 ;; + mips-*|mipsel-*) ARCH=mips ;; + microblaze-*) ARCH=microblaze ;; + powerpc-*) ARCH=powerpc ;; + sh-*|sh[34]-*) ARCH=sh ;; + x32-*) ARCH=x32 ;; + *) return 1 ;; + esac + + CT_DoLog EXTRA "Installing headers" + CT_DoExecLog ALL make ARCH="${ARCH}" install-headers DESTDIR="${CT_SYSROOT_DIR}/" + + 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 install DESTDIR="${CT_SYSROOT_DIR}/" + + CT_EndStep +} diff --git a/scripts/functions b/scripts/functions index 2e4d4fa..eae3b95 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1182,6 +1182,7 @@ CT_DoBuildTargetTuple() { case "${CT_LIBC}" in *glibc) CT_TARGET_SYS=gnu;; uClibc) CT_TARGET_SYS=uclibc;; + musl) CT_TARGET_SYS=musl;; *) CT_TARGET_SYS=elf;; esac -- 2.0.1 -- For unsubscribe information see http://sourceware.org/lists.html#faq