Add moxiebox as a choice for libc

This required some rework of the libc selection, as moxiebox is a layer on
top of another libc - newlib.

Also, moxiebox'es host VM (`sandbox`) needs a libcrypto on the host. We will
not have it if we're cross-compiling a canadian cross. Fortunately, all moxiebox
needs from libcrypto is SHA256, and it already includes a standalone implementation
of SHA256 in its runtime. Provide a little wrapper that allows moxiebox use
that implementation for the host binary, too.

Also, automate collecting/printing the list of all packages in a given category
(e.g. LIBC or COMP_TOOLS), generate a list of all Kconfig symbols for a given
category.

Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
Alexey Neyman 2018-11-23 22:14:07 -08:00
parent 172308cb1b
commit 40d5bf6440
33 changed files with 444 additions and 221 deletions

View File

@ -22,6 +22,19 @@ fi
# Iterate over NAME entities (the iterator must be set up first # Iterate over NAME entities (the iterator must be set up first
# using the set_iter function), processing the lines until the matching # using the set_iter function), processing the lines until the matching
# #!end-foreach line. # #!end-foreach line.
#
# Also, several forms of @@VAR@@ expansions are possible:
#
# @@VAR@@
# Just the value of the variable VAR
# @@VAR|@@
# The value of VAR made into Kconfig-name: all non-alphanumeric character
# replaced with underscores; upper-cased.
# @@VAR?val@@
# If VAR is non-empty, insert value "val". Otherwise, insert nothing.
# @@*ITER@@
# Expands to a space separated list of values for the iterator ITER.
# Postprocess operations, if any, are applied to each value.
declare -A info declare -A info
@ -183,7 +196,8 @@ run_lines()
{ {
local start="${1}" local start="${1}"
local end="${2}" local end="${2}"
local l lnext s s1 v vp pp p val local l lnext s s1 v vn vp pp p val val0 is_iter pp_saved
local -a vpl
debug "Running lines ${start}..${end}" debug "Running lines ${start}..${end}"
l=${start} l=${start}
@ -199,33 +213,53 @@ run_lines()
*@@*@@*) *@@*@@*)
v="${s#*@@}" v="${s#*@@}"
v="${v%%@@*}" v="${v%%@@*}"
# $v now includes variable name + any postprocessing # $v now has the complete reference. First check if it is cached already.
vp="${v%%[|?]*}"
pp="${v#${vp}}"
# $vp is name of the variable proper, $pp is any postprocessing
if [ "${info[${vp}]+set}" != "set" ]; then
error "${template}:${l}: reference to undefined variable '${vp}'"
fi
if [ "${info[${v}]+set}" != "set" ]; then if [ "${info[${v}]+set}" != "set" ]; then
# We know the base variable, need to cache postprocessed value case "${v}" in
val="${info[${vp}]}" "*"*) is_iter=y; vn="${v#\*}";;
# Apply postprocessing(s) *) is_iter=n; vn="${v}";;
while [ -n "${pp}" ]; do esac
case "${pp}" in # $vn is now the reference without the preceding iterator
"|"*) vp="${vn%%[|?]*}"
# Kconfigize pp="${vn#${vp}}"
pp="${pp#|}" # $vp is name of the variable proper, $pp is any postprocessing
val=${val//[^0-9A-Za-z_]/_} if [ "${is_iter}" = "n" ]; then
val=${val^^} if [ "${info[${vp}]+set}" != "set" ]; then
;; error "${template}:${l}: reference to undefined variable '${vp}'"
"?"*) fi
pp="${pp#?}" vpl=( "${info[${vp}]}" )
p="${pp%%[|?]*}" else
pp="${pp#${p}}" if [ "${info[iter_${vp}]+set}" != "set" ]; then
val="${val:+${p}}" error "${template}:${l}: iterator over '${vp} is not defined"
;; fi
esac vpl=( ${info[iter_${vp}]} )
fi
# ${vpl[@]} now is an array of values to be transformed.
val=
pp_saved="${pp}"
for val0 in "${vpl[@]}"; do
debug "val0 [${val0}]"
pp="${pp_saved}"
# Apply postprocessing(s)
while [ -n "${pp}" ]; do
case "${pp}" in
"|"*)
# Kconfigize
pp="${pp#|}"
val0=${val0//[^0-9A-Za-z_]/_}
val0=${val0^^}
;;
"?"*)
pp="${pp#?}"
p="${pp%%[|?]*}"
pp="${pp#${p}}"
val0="${val0:+${p}}"
;;
esac
done
val="${val:+${val} }${val0}"
done done
# Cache for future references.
info[${v}]="${val}" info[${v}]="${val}"
fi fi
s1="${s1}${s%%@@*}\${info[${v}]}" s1="${s1}${s%%@@*}\${info[${v}]}"

View File

@ -1,7 +1,7 @@
# avr-libc options # avr-libc options
## depends on ARCH_AVR ## depends on ARCH_AVR
## depends on ! LINUX && ! WINDOWS && BARE_METAL ## depends on BARE_METAL
## ##
## select LIBC_SUPPORT_THREADS_NONE ## select LIBC_SUPPORT_THREADS_NONE
## ##

16
config/libc/moxiebox.in Normal file
View File

@ -0,0 +1,16 @@
# moxiebox options
# Moxie is distributed in non-bootstrapped form, so we really need
# autoconfig and automake.
## depends on ARCH_MOXIE
## depends on BARE_METAL
## select LIBC_NEWLIB_SHOW
## select LIBC_SUPPORT_THREADS_NONE
## select COMP_TOOLS_AUTOCONF if !CONFIGURE_has_autoconf_2_65_or_newer || !CONFIGURE_has_autoreconf_2_64_or_newer
## select COMP_TOOLS_AUTOMAKE if !CONFIGURE_has_automake_1_15_or_newer
## select CC_CORE_PASSES_NEEDED if CANADIAN
## select CC_CORE_PASS_2_NEEDED if ! CANADIAN
## select LIBELF_NEEDED
##
## help Secure execution runtime for Moxie architecture.

View File

@ -182,14 +182,14 @@ config NATIVE
depends on EXPERIMENTAL depends on EXPERIMENTAL
help help
Build a native toolchain. Build a native toolchain.
See: "docs/6 - Toolchain types.txt" See: "docs/6_Toolchain_Types.md"
config CROSS config CROSS
bool bool
prompt "Cross" prompt "Cross"
help help
Build a cross-toolchain. Build a cross-toolchain.
See: "docs/6 - Toolchain types.txt" See: "docs/6_Toolchain_Types.md"
config CROSS_NATIVE config CROSS_NATIVE
bool bool
@ -197,14 +197,14 @@ config CROSS_NATIVE
depends on EXPERIMENTAL depends on EXPERIMENTAL
help help
Build a cross-native toolchain. Build a cross-native toolchain.
See: "docs/6 - Toolchain types.txt" See: "docs/6_Toolchain_Types.md"
config CANADIAN config CANADIAN
bool bool
prompt "Canadian" prompt "Canadian"
help help
Build a canadian-toolchain. Build a canadian-toolchain.
See: "docs/6 - Toolchain types.txt" See: "docs/6_Toolchain_Types.md"
endchoice endchoice

View File

@ -254,7 +254,7 @@ CT_STEPS := \
kernel_headers \ kernel_headers \
libc_start_files \ libc_start_files \
cc_core_pass_2 \ cc_core_pass_2 \
libc \ libc_main \
cc_for_build \ cc_for_build \
cc_for_host \ cc_for_host \
libc_post_cc \ libc_post_cc \

View File

@ -32,7 +32,12 @@ config @@dir|@@_CHOICE_KSYM
#!end-foreach #!end-foreach
#!foreach choice #!foreach choice
if @@dir|@@_@@choice|@@ config @@dir|@@_@@choice|@@_SHOW
bool
default y if @@dir|@@_@@choice|@@
if @@dir|@@_@@choice|@@_SHOW
comment "Options for @@choice@@"
config @@dir|@@_@@choice|@@_PKG_KSYM config @@dir|@@_@@choice|@@_PKG_KSYM
string string
default "@@pkg|@@" default "@@pkg|@@"
@ -44,3 +49,7 @@ source "config/@@dir@@/@@choice@@.in"
endif endif
#!end-foreach #!end-foreach
config ALL_@@dir|@@_CHOICES
string
default "@@*choice|@@"

View File

@ -25,3 +25,7 @@ source "config/@@dir@@/@@choice@@.in"
endif endif
#!end-foreach #!end-foreach
config ALL_@@dir|@@_CHOICES
string
default "@@*choice|@@"

View File

@ -0,0 +1,29 @@
From a59675779247f544695959646a1615a033ca2d8d Mon Sep 17 00:00:00 2001
From: Alexey Neyman <stilor@att.net>
Date: Tue, 20 Nov 2018 10:54:40 -0800
Subject: [PATCH] Remove PKG_CONFIG check
... it is not used afterwards anyway, and causes errors if pkg-config
is not installed (since one cannot just run configure - one has to
run autogen.sh first).
Signed-off-by: Alexey Neyman <stilor@att.net>
---
configure.ac | 1 -
1 file changed, 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index aeadb36..1925a88 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,6 @@ AC_PATH_TOOL(STRIP, strip)
AC_CHECK_PROG(MOX_AS, moxiebox-as, moxiebox-as)
AC_CHECK_PROG(MOX_AR, moxiebox-ar, moxiebox-ar)
AC_CHECK_PROG(MOX_GCC, moxiebox-gcc, moxiebox-gcc)
-PKG_PROG_PKG_CONFIG
AC_LANG_PUSH([C++])
--
2.14.1

View File

@ -0,0 +1,2 @@
repository='git https://github.com/jgarzik/moxiebox.git'
repository_cset='9a79ac546faa4196b66e279f8017814ba8d6fd4b'

23
packages/moxiebox/sha.h Normal file
View File

@ -0,0 +1,23 @@
/*
Wrapper around moxiebox'es implementation of SHA256 digest that
mimics the API of the OpenSSL implementation.
*/
#ifndef __SHA_H_
#define __SHA_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "../runtime/sandboxrt_crypto.h"
#define SHA256_DIGEST_LENGTH SHA256_BLOCK_SIZE
void SHA256_Init(SHA256_CTX *ctx);
void SHA256_Update(SHA256_CTX *ctx, const void *data, size_t len);
void SHA256_Final(unsigned char *md, SHA256_CTX *ctx);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,25 @@
/*
Wrapper around moxiebox'es implementation of SHA256 digest that
mimics the API of the OpenSSL implementation.
*/
#include "sha.h"
#include "../runtime/sha256.c"
void
SHA256_Init(SHA256_CTX *ctx)
{
sha256_init(ctx);
}
void
SHA256_Update(SHA256_CTX *ctx, const void *data, size_t len)
{
sha256_update(ctx, data, len);
}
void
SHA256_Final(unsigned char *md, SHA256_CTX *ctx)
{
sha256_final(ctx, md);
}

View File

View File

@ -1,8 +1,8 @@
CT_EXPERIMENTAL=y CT_EXPERIMENTAL=y
CT_ARCH_MOXIE=y CT_ARCH_MOXIE=y
CT_ARCH_BE=y CT_LIBC_NEWLIB=y
CT_NEWLIB_V_2_5_0=y
CT_DEBUG_GDB=y CT_DEBUG_GDB=y
CT_GDB_CROSS_SIM=y CT_GDB_CROSS_SIM=y
# CT_GDB_CROSS_PYTHON is not set # CT_GDB_CROSS_PYTHON is not set
CT_COMP_LIBS_LIBELF=y
CT_DTC_VERBOSE=y CT_DTC_VERBOSE=y

View File

@ -1,3 +1,10 @@
reporter_name="Alexey Neyman" reporter_name="Alexey Neyman"
reporter_url="" reporter_url=""
reporter_comment="Bare metal configuration for moxie architecture." reporter_comment="Bare metal configuration for moxie architecture.
It appears to generate a broken toolchain. E.g. newlib's CRT expects
symbols __bss_start__ and __bss_end__, while linker script generates
__bss_start (no underscores at the end) and no __bss_end__whatsoever.
This is not a bug in crosstool-NG. If you're interested in saving the
moxie, please report this upstream."

View File

@ -0,0 +1,6 @@
CT_EXPERIMENTAL=y
CT_ARCH_MOXIE=y
CT_DEBUG_GDB=y
CT_GDB_CROSS_SIM=y
# CT_GDB_CROSS_PYTHON is not set
CT_DTC_VERBOSE=y

View File

@ -0,0 +1,3 @@
reporter_name="Alexey Neyman"
reporter_url=""
reporter_comment="Moxie toolchain with moxiebox+newlib as the C library."

View File

@ -0,0 +1,9 @@
CT_EXPERIMENTAL=y
CT_ARCH_MOXIE=y
CT_CANADIAN=y
CT_HOST="x86_64-multilib-linux-uclibc"
CT_DEBUG_GDB=y
CT_GDB_CROSS_SIM=y
# CT_LIBICONV_NEEDED is not set
# CT_GETTEXT_NEEDED is not set
CT_DTC_VERBOSE=y

View File

@ -0,0 +1,3 @@
reporter_name="Alexey Neyman"
reporter_url=""
reporter_comment="Canadian cross using moxiebox lib."

View File

@ -2,4 +2,11 @@
CT_DoArchTupleValues() { CT_DoArchTupleValues() {
CT_TARGET_ARCH="${CT_ARCH}" CT_TARGET_ARCH="${CT_ARCH}"
case "${CT_LIBC}" in
avr-libc)
# avr-libc only seems to work with the non-canonical "avr" target.
CT_TARGET_SKIP_CONFIG_SUB=y
CT_TARGET_SYS= # CT_TARGET_SYS must be empty
;;
esac
} }

View File

@ -3,5 +3,9 @@
# No arch-specific overrides yet # No arch-specific overrides yet
CT_DoArchTupleValues() CT_DoArchTupleValues()
{ {
: case "${CT_LIBC}" in
moxiebox)
CT_TARGET_SYS=moxiebox
;;
esac
} }

39
scripts/build/libc.sh Normal file
View File

@ -0,0 +1,39 @@
# C library build routines. We don't invoke the corresponding functions directly
# because some of them build on top of another. E.g. moxiebox runtime requires
# newlib as a prerequisite.
# Define default hooks - download/unpack just the main package; no-op build hooks.
# The actual implementation can override just what it needs then.
eval "${CT_LIBC//[^A-Za-z0-9]/_}_get() { CT_Fetch ${CT_LIBC_CHOICE_KSYM}; }"
eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract() { CT_ExtractPatch ${CT_LIBC_CHOICE_KSYM}; }"
for _m in start_files main post_cc; do
eval "${CT_LIBC//[^A-Za-z0-9]/_}_${_m}() { :; }"
done
# Source the selected libc.
. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
do_libc_get()
{
eval "${CT_LIBC//[^A-Za-z0-9]/_}_get"
}
do_libc_extract()
{
eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract"
}
do_libc_start_files()
{
eval "${CT_LIBC//[^A-Za-z0-9]/_}_start_files"
}
do_libc_main()
{
eval "${CT_LIBC//[^A-Za-z0-9]/_}_main"
}
do_libc_post_cc()
{
eval "${CT_LIBC//[^A-Za-z0-9]/_}_post_cc"
}

View File

@ -1,22 +1,7 @@
# This file adds functions to build the avr-libc C library # This file adds functions to build the avr-libc C library
do_libc_get() { avr_libc_post_cc()
CT_Fetch AVR_LIBC {
}
do_libc_extract() {
CT_ExtractPatch AVR_LIBC
}
do_libc_start_files() {
:
}
do_libc() {
:
}
do_libc_post_cc() {
CT_DoStep INFO "Installing C library" CT_DoStep INFO "Installing C library"
CT_DoLog EXTRA "Copying sources to build directory" CT_DoLog EXTRA "Copying sources to build directory"

View File

@ -2,21 +2,15 @@
# Copyright 2017 Howard Chu # Copyright 2017 Howard Chu
# Licensed under the GPL v2. See COPYING in the root of this package # Licensed under the GPL v2. See COPYING in the root of this package
do_libc_get() {
CT_Fetch ANDROID_NDK
}
do_libc_extract() {
CT_ExtractPatch ANDROID_NDK
}
# Install Unified headers # Install Unified headers
do_libc_start_files() { bionic_start_files()
{
CT_DoStep INFO "Installing C library headers" CT_DoStep INFO "Installing C library headers"
CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/sysroot/usr" "${CT_SYSROOT_DIR}" CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/sysroot/usr" "${CT_SYSROOT_DIR}"
} }
do_libc() { bionic_main()
{
local arch="${CT_ARCH}" local arch="${CT_ARCH}"
if [ "${CT_ARCH_64}" = "y" ]; then if [ "${CT_ARCH_64}" = "y" ]; then
if [ "${CT_ARCH}" = "x86" ]; then if [ "${CT_ARCH}" = "x86" ]; then
@ -34,8 +28,3 @@ do_libc() {
# options isn't completely out of character. # options isn't completely out of character.
CT_EnvModify CT_TARGET_CFLAGS "${CT_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}" CT_EnvModify CT_TARGET_CFLAGS "${CT_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}"
} }
do_libc_post_cc() {
:
}

View File

@ -2,7 +2,8 @@
# Copyright 2007 Yann E. MORIN # Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package # Licensed under the GPL v2. See COPYING in the root of this package
do_libc_get() { glibc_get()
{
local date local date
local version local version
@ -13,7 +14,8 @@ do_libc_get() {
return 0 return 0
} }
do_libc_extract() { glibc_extract()
{
CT_ExtractPatch GLIBC CT_ExtractPatch GLIBC
if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then
CT_ExtractPatch GLIBC_PORTS CT_ExtractPatch GLIBC_PORTS
@ -29,27 +31,26 @@ do_libc_extract() {
} }
# Build and install headers and start files # Build and install headers and start files
do_libc_start_files() { glibc_start_files()
{
# Start files and Headers should be configured the same way as the # Start files and Headers should be configured the same way as the
# final libc, but built and installed differently. # final libc, but built and installed differently.
do_libc_backend libc_mode=startfiles glibc_backend libc_mode=startfiles
} }
# This function builds and install the full C library # This function builds and install the full C library
do_libc() { glibc_main()
do_libc_backend libc_mode=final {
} glibc_backend libc_mode=final
do_libc_post_cc() {
:
} }
# This backend builds the C library once for each multilib # This backend builds the C library once for each multilib
# variant the compiler gives us # variant the compiler gives us
# Usage: do_libc_backend param=value [...] # Usage: glibc_backend param=value [...]
# Parameter : Definition : Type : Default # Parameter : Definition : Type : Default
# libc_mode : 'startfiles' or 'final' : string : (none) # libc_mode : 'startfiles' or 'final' : string : (none)
do_libc_backend() { glibc_backend()
{
local libc_mode local libc_mode
local arg local arg
@ -70,17 +71,18 @@ do_libc_backend() {
esac esac
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}"
CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}" CT_IterateMultilibs glibc_backend_once multilib libc_mode="${libc_mode}"
CT_Popd CT_Popd
CT_EndStep CT_EndStep
} }
# This backend builds the C library once # This backend builds the C library once
# Usage: do_libc_backend_once param=value [...] # Usage: glibc_backend_once param=value [...]
# Parameter : Definition : Type # Parameter : Definition : Type
# libc_mode : 'startfiles' or 'final' : string : (empty) # libc_mode : 'startfiles' or 'final' : string : (empty)
# multi_* : as defined in CT_IterateMultilibs : (varies) : # multi_* : as defined in CT_IterateMultilibs : (varies) :
do_libc_backend_once() { glibc_backend_once()
{
local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target
local build_cflags build_cppflags build_ldflags local build_cflags build_cppflags build_ldflags
local startfiles_dir local startfiles_dir
@ -136,7 +138,7 @@ do_libc_backend_once() {
# values, as they CT_GLIBC_EXTRA_CONFIG_ARRAY is passed after # values, as they CT_GLIBC_EXTRA_CONFIG_ARRAY is passed after
# extra_config # extra_config
extra_config+=("$(do_libc_min_kernel_config)") extra_config+=("$(glibc_min_kernel_config)")
case "${CT_THREADS}" in case "${CT_THREADS}" in
nptl) extra_config+=("--with-__thread" "--with-tls");; nptl) extra_config+=("--with-__thread" "--with-tls");;
@ -165,9 +167,9 @@ do_libc_backend_once() {
extra_config+=("--enable-oldest-abi=${CT_GLIBC_OLDEST_ABI}") extra_config+=("--enable-oldest-abi=${CT_GLIBC_OLDEST_ABI}")
fi fi
case "$(do_libc_add_ons_list ,)" in case "$(glibc_add_ons_list ,)" in
"") extra_config+=("--enable-add-ons=no");; "") extra_config+=("--enable-add-ons=no");;
*) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");; *) extra_config+=("--enable-add-ons=$(glibc_add_ons_list ,)");;
esac esac
[ "${CT_GLIBC_ENABLE_WERROR}" != "y" ] && extra_config+=("--disable-werror") [ "${CT_GLIBC_ENABLE_WERROR}" != "y" ] && extra_config+=("--disable-werror")
@ -241,7 +243,7 @@ do_libc_backend_once() {
# Run explicitly through CONFIG_SHELL, or the build breaks badly (loop-of-death) # Run explicitly through CONFIG_SHELL, or the build breaks badly (loop-of-death)
# when the shell is not bash... Sigh... :-( # when the shell is not bash... Sigh... :-(
CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'" CT_DoLog DEBUG "Configuring with addons : '$(glibc_add_ons_list ,)'"
CT_DoLog DEBUG "Extra config args passed : '${extra_config[*]}'" CT_DoLog DEBUG "Extra config args passed : '${extra_config[*]}'"
CT_DoLog DEBUG "Extra CFLAGS passed : '${glibc_cflags}'" CT_DoLog DEBUG "Extra CFLAGS passed : '${glibc_cflags}'"
CT_DoLog DEBUG "Placing startfiles into : '${startfiles_dir}'" CT_DoLog DEBUG "Placing startfiles into : '${startfiles_dir}'"
@ -402,7 +404,7 @@ do_libc_backend_once() {
fi fi
if [ "${CT_GLIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then if [ "${CT_GLIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then
do_libc_locales glibc_locales
fi fi
fi # libc_mode = final fi # libc_mode = final
@ -410,7 +412,8 @@ do_libc_backend_once() {
} }
# Build up the addons list, separated with $1 # Build up the addons list, separated with $1
do_libc_add_ons_list() { glibc_add_ons_list()
{
local sep="$1" local sep="$1"
local addons_list local addons_list
@ -427,7 +430,8 @@ do_libc_add_ons_list() {
} }
# Compute up the minimum supported Linux kernel version # Compute up the minimum supported Linux kernel version
do_libc_min_kernel_config() { glibc_min_kernel_config()
{
local min_kernel_config local min_kernel_config
case "${CT_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in case "${CT_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in
@ -462,7 +466,8 @@ do_libc_min_kernel_config() {
} }
# Build and install the libc locales # Build and install the libc locales
do_libc_locales() { glibc_locales()
{
local src_dir="${CT_SRC_DIR}/glibc" local src_dir="${CT_SRC_DIR}/glibc"
local -a extra_config local -a extra_config
local glibc_cflags local glibc_cflags

View File

@ -1,22 +1,15 @@
# Copyright 2012 Yann Diorcet # Copyright 2012 Yann Diorcet
# Licensed under the GPL v2. See COPYING in the root of this package # Licensed under the GPL v2. See COPYING in the root of this package
do_libc_get() { mingw_w64_set_install_prefix()
CT_Fetch MINGW_W64 {
}
do_libc_extract() {
CT_ExtractPatch MINGW_W64
}
do_set_mingw_install_prefix(){
MINGW_INSTALL_PREFIX=/usr/${CT_TARGET} MINGW_INSTALL_PREFIX=/usr/${CT_TARGET}
if [[ ${CT_MINGW_W64_VERSION} == 2* ]]; then if [[ ${CT_MINGW_W64_VERSION} == 2* ]]; then
MINGW_INSTALL_PREFIX=/usr MINGW_INSTALL_PREFIX=/usr
fi fi
} }
do_libc_start_files() { mingw_w64_start_files() {
local -a sdk_opts local -a sdk_opts
CT_DoStep INFO "Installing C library headers" CT_DoStep INFO "Installing C library headers"
@ -36,7 +29,7 @@ do_libc_start_files() {
CT_DoLog EXTRA "Configuring Headers" CT_DoLog EXTRA "Configuring Headers"
do_set_mingw_install_prefix mingw_w64_set_install_prefix
CT_DoExecLog CFG \ CT_DoExecLog CFG \
${CONFIG_SHELL} \ ${CONFIG_SHELL} \
"${CT_SRC_DIR}/mingw-w64/mingw-w64-headers/configure" \ "${CT_SRC_DIR}/mingw-w64/mingw-w64-headers/configure" \
@ -96,7 +89,7 @@ do_mingw_tools()
--program-prefix=${CT_TARGET}- \ --program-prefix=${CT_TARGET}- \
--prefix="${CT_PREFIX_DIR}" --prefix="${CT_PREFIX_DIR}"
# mingw-w64 has issues with parallel builds, see do_libc # mingw-w64 has issues with parallel builds, see mingw_w64_main
CT_DoLog EXTRA "Building ${f}" CT_DoLog EXTRA "Building ${f}"
CT_DoExecLog ALL make CT_DoExecLog ALL make
CT_DoLog EXTRA "Installing ${f}" CT_DoLog EXTRA "Installing ${f}"
@ -154,7 +147,7 @@ do_mingw_pthreads()
--build=${CT_BUILD} \ --build=${CT_BUILD} \
--host=${multi_target} --host=${multi_target}
# mingw-w64 has issues with parallel builds, see do_libc # mingw-w64 has issues with parallel builds, see mingw_w64_main
CT_DoLog EXTRA "Building mingw-w64-winpthreads" CT_DoLog EXTRA "Building mingw-w64-winpthreads"
CT_DoExecLog ALL make CT_DoExecLog ALL make
@ -179,7 +172,7 @@ do_mingw_pthreads()
CT_EndStep CT_EndStep
} }
do_libc() mingw_w64_main()
{ {
# Used when iterating over libwinpthread # Used when iterating over libwinpthread
local default_libprefix local default_libprefix
@ -192,7 +185,7 @@ do_libc()
CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt" CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt"
do_set_mingw_install_prefix mingw_w64_set_install_prefix
CT_DoExecLog CFG \ CT_DoExecLog CFG \
${CONFIG_SHELL} \ ${CONFIG_SHELL} \
"${CT_SRC_DIR}/mingw-w64/mingw-w64-crt/configure" \ "${CT_SRC_DIR}/mingw-w64/mingw-w64-crt/configure" \
@ -228,6 +221,6 @@ do_libc()
fi fi
} }
do_libc_post_cc() { mingw_w64_post_cc() {
: :
} }

View File

@ -0,0 +1,84 @@
# Functions to build the moxiebox runtime.
. "${CT_LIB_DIR}/scripts/build/libc/newlib.sh"
moxiebox_get()
{
CT_Fetch NEWLIB
CT_Fetch MOXIEBOX
}
moxiebox_extract()
{
CT_ExtractPatch NEWLIB
CT_ExtractPatch MOXIEBOX
}
moxiebox_start_files()
{
newlib_start_files
}
moxiebox_main()
{
newlib_main
# newlib installs the linker script, moxiebox.ld, to the
# PREFIX/moxie-unknown-moxiebox/lib, but ld searches PREFIX/lib when
# configured for that target. ld does find scripts in PREFIX/TARGET/lib
# for other targets, so this seems to be moxie architecture's quirk.
# Move it to PREFIX/lib.
# TBD CT_DoExecLog ALL mv -v "${CT_SYSROOT_DIR}/lib/"*.ld "${CT_PREFIX_DIR}/lib"
# TBD what about moxie-*-elf? Does it need the same?
CT_DoStep INFO "Installing moxiebox runtime and VM"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-moxiebox"
CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/moxiebox/." .
CT_DoLog EXTRA "Building SHA256-only libcrypto"
# Moxiebox needs libcrypto on the host, but it only uses SHA256 digest functions
# from it. We don't want to pull the whole OpenSSL for the host; fortunately,
# moxiebox comes with a standalone SHA256 implementation - which it only uses
# for the target library. Help it use the same implementation for the host.
CT_mkdir_pushd openssl
CT_DoExecLog ALL cp -v "${CT_LIB_DIR}/packages/moxiebox/"sha*.[ch] ./
CT_DoExecLog ALL "${CT_HOST}-gcc" -c sha256_wrap.c -O2 -Wall
CT_DoExecLog ALL "${CT_HOST}-ar" cru libcrypto.a sha256_wrap.o
CT_Popd
# Moxiebox includes a VM which we're building for the
# host machine.
CT_DoLog EXTRA "Configuring moxiebox"
CT_DoExecLog CFG ./autogen.sh
# moxiebox build script create symlinks from the installation location to the build
# directory for the moxiebox library. This seems backwards. Instead, pass the search
# as part of the MOX_GCC definition.
# moxiebox also depends on the tools being named moxiebox-{gcc,as,ar}. However, failure
# to detect such tools is non-fatal in the configure and we need to override it in
# make's command line anyway.
CT_DoExecLog CFG \
LDFLAGS="${CT_LDFLAGS_FOR_HOST} -L${CT_BUILD_DIR}/build-libc-moxiebox/openssl" \
CFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \
CXXFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \
./configure \
--host="${CT_HOST}"
CT_DoLog EXTRA "Building moxiebox"
CT_DoExecLog CFG make all \
MOX_GCC="${CT_TARGET}-gcc -B ${CT_BUILD_DIR}/build-libc-moxiebox/runtime -B ${CT_SYSROOT_DIR}/lib" \
MOX_AS="${CT_TARGET}-as" \
MOX_AR="${CT_TARGET}-ar"
CT_DoLog EXTRA "Installing moxiebox"
# moxiebox does not have install target. Copy the interesting stuff manually.
CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/runtime/libsandboxrt.a" \
"${CT_BUILD_DIR}/build-libc-moxiebox/runtime/crt0.o" \
"${CT_SYSROOT_DIR}/lib/"
CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/src/sandbox" \
"${CT_PREFIX_DIR}/bin"
CT_Popd
CT_EndStep
}

View File

@ -2,33 +2,27 @@
# Copyright 2013 Timo Teräs # Copyright 2013 Timo Teräs
# Licensed under the GPL v2. See COPYING in the root of this package # Licensed under the GPL v2. See COPYING in the root of this package
do_libc_get() {
CT_Fetch MUSL
}
do_libc_extract() {
CT_ExtractPatch MUSL
}
# Build and install headers and start files # Build and install headers and start files
do_libc_start_files() { musl_start_files()
{
# Start files and Headers should be configured the same way as the # Start files and Headers should be configured the same way as the
# final libc, but built and installed differently. # final libc, but built and installed differently.
do_libc_backend libc_mode=startfiles musl_backend libc_mode=startfiles
} }
# This function builds and install the full C library # This function builds and install the full C library
do_libc() { musl_main()
do_libc_backend libc_mode=final {
musl_backend libc_mode=final
} }
do_libc_post_cc() { musl_post_cc() {
# MUSL creates dynamic linker symlink with absolute path - which works on the # MUSL creates dynamic linker symlink with absolute path - which works on the
# target but not on the host. We want our cross-ldd tool to work. # target but not on the host. We want our cross-ldd tool to work.
CT_MultilibFixupLDSO CT_MultilibFixupLDSO
} }
do_libc_backend() { musl_backend() {
local libc_mode local libc_mode
local arg local arg
@ -43,16 +37,16 @@ do_libc_backend() {
esac esac
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}"
CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}" CT_IterateMultilibs musl_backend_once multilib libc_mode="${libc_mode}"
CT_Popd CT_Popd
CT_EndStep CT_EndStep
} }
# This backend builds the C library # This backend builds the C library
# Usage: do_libc_backend param=value [...] # Usage: musl_backend param=value [...]
# Parameter : Definition : Type : Default # Parameter : Definition : Type : Default
# libc_mode : 'startfiles' or 'final' : string : (none) # libc_mode : 'startfiles' or 'final' : string : (none)
do_libc_backend_once() { musl_backend_once() {
local libc_mode local libc_mode
local -a extra_cflags local -a extra_cflags
local -a extra_config local -a extra_config

View File

@ -5,15 +5,8 @@
# Edited by Martin Lund <mgl@doredevelopment.dk> # Edited by Martin Lund <mgl@doredevelopment.dk>
# #
do_libc_get() { newlib_start_files()
CT_Fetch NEWLIB {
}
do_libc_extract() {
CT_ExtractPatch NEWLIB
}
do_libc_start_files() {
CT_DoStep INFO "Installing C library headers & start files" CT_DoStep INFO "Installing C library headers & start files"
CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." \ CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." \
"${CT_HEADERS_DIR}" "${CT_HEADERS_DIR}"
@ -25,14 +18,14 @@ do_libc_start_files() {
CT_EndStep CT_EndStep
} }
do_libc() { newlib_main()
{
local -a newlib_opts local -a newlib_opts
local cflags_for_target local cflags_for_target
CT_DoStep INFO "Installing C library" CT_DoStep INFO "Installing C library"
mkdir -p "${CT_BUILD_DIR}/build-libc" CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc"
cd "${CT_BUILD_DIR}/build-libc"
CT_DoLog EXTRA "Configuring C library" CT_DoLog EXTRA "Configuring C library"
@ -135,9 +128,6 @@ ENABLE_TARGET_OPTSPACE:target-optspace
"${CT_PREFIX_DIR}/share/doc/newlib" "${CT_PREFIX_DIR}/share/doc/newlib"
fi fi
CT_Popd
CT_EndStep CT_EndStep
} }
do_libc_post_cc() {
:
}

View File

@ -2,22 +2,12 @@
# Copyright 2008 Yann E. MORIN # Copyright 2008 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package # Licensed under the GPL v2. See COPYING in the root of this package
do_libc_get() { none_get()
{
: :
} }
do_libc_extract() { none_extract()
: {
}
do_libc_start_files() {
:
}
do_libc() {
:
}
do_libc_post_cc() {
: :
} }

View File

@ -2,30 +2,23 @@
# Copyright 2007 Yann E. MORIN # Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package # Licensed under the GPL v2. See COPYING in the root of this package
# Download uClibc
do_libc_get() {
CT_Fetch UCLIBC
}
# Extract uClibc
do_libc_extract() {
CT_ExtractPatch UCLIBC
}
# Build and install headers and start files # Build and install headers and start files
do_libc_start_files() { uclibc_start_files()
{
# Start files and Headers should be configured the same way as the # Start files and Headers should be configured the same way as the
# final libc, but built and installed differently. # final libc, but built and installed differently.
do_libc_backend libc_mode=startfiles uclibc_backend libc_mode=startfiles
} }
# This function builds and install the full C library # This function builds and install the full C library
do_libc() { uclibc_main()
do_libc_backend libc_mode=final {
uclibc_backend libc_mode=final
} }
# Common backend for 1st and 2nd passes. # Common backend for 1st and 2nd passes.
do_libc_backend() { uclibc_backend()
{
local libc_mode local libc_mode
local arg local arg
@ -40,13 +33,14 @@ do_libc_backend() {
esac esac
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}"
CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}" CT_IterateMultilibs uclibc_backend_once multilib libc_mode="${libc_mode}"
CT_Popd CT_Popd
CT_EndStep CT_EndStep
} }
# Common backend for 1st and 2nd passes, once per multilib. # Common backend for 1st and 2nd passes, once per multilib.
do_libc_backend_once() { uclibc_backend_once()
{
local libc_mode local libc_mode
local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count
local multilib_dir startfiles_dir local multilib_dir startfiles_dir
@ -215,7 +209,8 @@ do_libc_backend_once() {
# Initialises the .config file to sensible values # Initialises the .config file to sensible values
# $1: original file # $1: original file
# $2: modified file # $2: modified file
manage_uClibc_config() { manage_uClibc_config()
{
src="$1" src="$1"
dst="$2" dst="$2"
flags="$3" flags="$3"
@ -408,7 +403,8 @@ manage_uClibc_config() {
CT_DoArchUClibcCflags "${dst}" "${flags}" CT_DoArchUClibcCflags "${dst}" "${flags}"
} }
do_libc_post_cc() { uclibc_post_cc()
{
# uClibc and GCC disagree where the dynamic linker lives. uClibc always # uClibc and GCC disagree where the dynamic linker lives. uClibc always
# places it in the MULTILIB_DIR, while gcc does that for *some* variants # places it in the MULTILIB_DIR, while gcc does that for *some* variants
# and expects it in /lib for the other. So, create a symlink from lib # and expects it in /lib for the other. So, create a symlink from lib

View File

@ -669,7 +669,6 @@ if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
do_stop=0 do_stop=0
prev_step= prev_step=
[ -n "${CT_RESTART}" ] && do_it=0 || do_it=1 [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
# Aha! CT_STEPS comes from steps.mk!
for step in ${CT_STEPS}; do for step in ${CT_STEPS}; do
if [ ${do_it} -eq 0 ]; then if [ ${do_it} -eq 0 ]; then
if [ "${CT_RESTART}" = "${step}" ]; then if [ "${CT_RESTART}" = "${step}" ]; then

View File

@ -23,7 +23,7 @@ CT_LoadConfig() {
. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" . "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
. "${CT_LIB_DIR}/scripts/build/companion_libs.sh" . "${CT_LIB_DIR}/scripts/build/companion_libs.sh"
. "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh" . "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh"
. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" . "${CT_LIB_DIR}/scripts/build/libc.sh"
. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" . "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
. "${CT_LIB_DIR}/scripts/build/debug.sh" . "${CT_LIB_DIR}/scripts/build/debug.sh"
. "${CT_LIB_DIR}/scripts/build/test_suite.sh" . "${CT_LIB_DIR}/scripts/build/test_suite.sh"
@ -1095,11 +1095,6 @@ CT_DoBuildTargetTuple() {
uClibc) CT_TARGET_SYS=uclibc;; uClibc) CT_TARGET_SYS=uclibc;;
musl) CT_TARGET_SYS=musl;; musl) CT_TARGET_SYS=musl;;
bionic) CT_TARGET_SYS=android;; bionic) CT_TARGET_SYS=android;;
avr-libc)
# avr-libc only seems to work with the non-canonical "avr" target.
CT_TARGET_SKIP_CONFIG_SUB=y
CT_TARGET_SYS= # CT_TARGET_SYS must be empty too
;;
none|newlib) none|newlib)
CT_TARGET_SYS=elf CT_TARGET_SYS=elf
;; ;;
@ -1989,6 +1984,7 @@ CT_PackageRun()
src_release mirrors archive_filename archive_dirname archive_formats signature_format \ src_release mirrors archive_filename archive_dirname archive_formats signature_format \
src_devel devel_vcs devel_url devel_branch devel_revision devel_subdir devel_bootstrap \ src_devel devel_vcs devel_url devel_branch devel_revision devel_subdir devel_bootstrap \
src_custom custom_location patch_order; do src_custom custom_location patch_order; do
CT_DoLog DEBUG "Package iterator: set ${v}=\${CT_${use}_${v^^}}"
eval "local ${v}=\${CT_${use}_${v^^}}" eval "local ${v}=\${CT_${use}_${v^^}}"
done done
@ -2004,6 +2000,7 @@ CT_PackageRun()
eval "eval ${v}=\${${v}//@/$}" eval "eval ${v}=\${${v}//@/$}"
done done
CT_DoLog DEBUG "Package iterator: run ${run} $*"
${run} "$@" ${run} "$@"
# Save certain variables that may be modified by the callback. # Save certain variables that may be modified by the callback.
@ -2369,7 +2366,10 @@ CT_GetPkgBuildVersion()
fi fi
__do_GetPkgBuildVersion() { __do_GetPkgBuildVersion() {
tmp="${pkg_name}-${version}" tmp="${pkg_name}"
if [ "${version}" != "unknown" ]; then
tmp+="-${version}"
fi
if [ "${src_devel}" = "y" ]; then if [ "${src_devel}" = "y" ]; then
tmp+="-${devel_vcs}" tmp+="-${devel_vcs}"
if [ -n "${devel_revision}" ]; then if [ -n "${devel_revision}" ]; then
@ -2387,18 +2387,6 @@ CT_GetPkgBuildVersion()
eval "${var}=\"${tmp}\"" eval "${var}=\"${tmp}\""
} }
# Get a package version as selected by a generated choice in kconfig.
CT_GetChoicePkgBuildVersion()
{
local choice="${1}"
local var="${2}"
local component
# Find the selected component
eval "component=\${CT_${choice}_CHOICE_KSYM}"
CT_GetPkgBuildVersion "${choice}" "${component}" "${var}"
}
# Finally, load paths.sh. For --enable-local build, it is located in # Finally, load paths.sh. For --enable-local build, it is located in
# the current directory (CT_TOP_DIR) while the rest of the scripts are # the current directory (CT_TOP_DIR) while the rest of the scripts are
# in the source directory (CT_LIB_DIR). For other setups, paths.sh # in the source directory (CT_LIB_DIR). For other setups, paths.sh

View File

@ -20,34 +20,27 @@ dump_pkgs_desc()
{ {
local category="${1}" local category="${1}"
local field="${2}" local field="${2}"
local pkgs
shift 2 shift 2
local show_version local show_version
local tmp local tmp p
eval "pkgs=\"\${CT_ALL_${category}_CHOICES}\""
printf " %-*s :" ${fieldwidth} "${field}" printf " %-*s :" ${fieldwidth} "${field}"
while [ -n "${1}" ]; do for p in ${pkgs}; do
eval "tmp=\"\${CT_${category}_${1}}\"" # FIXME: multiple choices use category_package; single choice
# use category_package for the primary selection and category_package_SHOW
# for all other selections enabled by the primary. Cannot unify this syntax
# without a really extensive change.
eval "tmp=\"\${CT_${category}_${p}}\${CT_${category}_${p}_SHOW}\""
if [ -n "${tmp}" ]; then if [ -n "${tmp}" ]; then
CT_GetPkgBuildVersion "${category}" "${1}" show_version CT_GetPkgBuildVersion "${category}" "${p}" show_version
printf " %s" "${show_version}" printf " %s" "${show_version}"
fi fi
shift
done done
printf "\n" printf "\n"
} }
# Dump a short package description with a name and version in a format
# " <name>[-<version>]"
dump_choice_desc()
{
local category="${1}"
local field="${2}"
local show_version
CT_GetChoicePkgBuildVersion "${category}" show_version
printf " %-*s : %s\n" ${fieldwidth} "${field}" "${show_version}"
}
# Dump a single sample # Dump a single sample
# Note: we use the specific .config.sample config file # Note: we use the specific .config.sample config file
dump_single_sample() dump_single_sample()
@ -88,13 +81,6 @@ dump_single_sample()
printf " %-*s : %s\n" ${fieldwidth} "Host" "${CT_HOST}" printf " %-*s : %s\n" ${fieldwidth} "Host" "${CT_HOST}"
;; ;;
esac esac
# FIXME get choice/menu names from generated kconfig files as well
# FIXME get the list of menu components from generated kconfig files
dump_choice_desc KERNEL "OS"
dump_pkgs_desc COMP_LIBS "Companion libs" GMP MPFR MPC ISL CLOOG LIBELF EXPAT NCURSES \
LIBICONV GETTEXT
dump_choice_desc BINUTILS "Binutils"
dump_choice_desc CC "Compiler"
printf " %-*s : %s" ${fieldwidth} "Languages" "C" printf " %-*s : %s" ${fieldwidth} "Languages" "C"
[ "${CT_CC_LANG_CXX}" = "y" ] && printf ",C++" [ "${CT_CC_LANG_CXX}" = "y" ] && printf ",C++"
[ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran" [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
@ -106,9 +92,13 @@ dump_single_sample()
[ -n "${CT_CC_LANG_OTHERS}" ] && printf ",${CT_CC_LANG_OTHERS}" [ -n "${CT_CC_LANG_OTHERS}" ] && printf ",${CT_CC_LANG_OTHERS}"
printf "\n" printf "\n"
dump_choice_desc LIBC "C library" dump_pkgs_desc KERNEL "OS"
dump_pkgs_desc DEBUG "Debug tools" DUMA GDB LTRACE STRACE dump_pkgs_desc BINUTILS "Binutils"
dump_pkgs_desc COMP_TOOLS "Companion tools" AUTOCONF AUTOMAKE LIBTOOL M4 MAKE DTC dump_pkgs_desc CC "Compiler"
dump_pkgs_desc LIBC "C library"
dump_pkgs_desc DEBUG "Debug tools"
dump_pkgs_desc COMP_LIBS "Companion libs"
dump_pkgs_desc COMP_TOOLS "Companion tools"
fi fi
} }