Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#############################################################################

# Set this if you want to enable the GPLv3 toolchain

# export ENABLE_GPLV3=1

# Set this if you don't want to drop all unrecognized environment variables.

# export NO_SANITIZE_ENVIRONMENT=1
Expand Down
74 changes: 52 additions & 22 deletions download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,64 @@ URL=ftp://kernel.org/pub/linux/kernel/v4.x/linux-4.3.tar.gz \
SHA1=309d9bedd8c9ef4a79695f04dcf65c0b551d784c \
maybe_fork "download || dienow"


# 2.17 was the last GPLv2 release of binutils, but git commit
# 397a64b350470350c8e0adb2af84439ea0f89272 was the last GPLv2
# _version_ of binutils. This tarball has prebuilt release files
# so it builds without optional dependencies such as lex and yacc.

URL=http://landley.net/aboriginal/mirror/binutils-397a64b3.tar.bz2 \
SHA1=f74f1ce2e62c516ba832f99a94289930be7869cf \
maybe_fork "download || dienow"

# elf2flt needed for nommu targets which can't mmap() the elf segments.
# From git://git.sourceforge.jp/gitroot/uclinux-h8/elf2flt.git branch h8300

URL=http://landley.net/aboriginal/mirror/elf2flt-332e3d67e763.tar.gz \
SHA1=23279cdd550f557cef8e83e0e0f3e33d04b1d1bd \
maybe_fork "download || dienow"

# 4.2.1 was the last GPLv2 release of gcc

URL=ftp://ftp.gnu.org/gnu/gcc/gcc-4.2.1/gcc-core-4.2.1.tar.bz2 \
SHA1=43a138779e053a864bd16dfabcd3ffff04103213 \
maybe_fork "download || dienow"

# The g++ version must match gcc version.

URL=http://ftp.gnu.org/gnu/gcc/gcc-4.2.1/gcc-g++-4.2.1.tar.bz2 \
SHA1=8f3785bd0e092f563e14ecd26921cd04275496a6 \
maybe_fork "download || dienow"
if [ -z "$ENABLE_GPLV3" ]
then
# 2.17 was the last GPLv2 release of binutils, but git commit
# 397a64b350470350c8e0adb2af84439ea0f89272 was the last GPLv2
# _version_ of binutils. This tarball has prebuilt release files
# so it builds without optional dependencies such as lex and yacc.
URL=http://landley.net/aboriginal/mirror/binutils-397a64b3.tar.bz2 \
SHA1=f74f1ce2e62c516ba832f99a94289930be7869cf \
maybe_fork "download || dienow"

# 4.2.1 was the last GPLv2 release of gcc
URL=ftp://ftp.gnu.org/gnu/gcc/gcc-4.2.1/gcc-core-4.2.1.tar.bz2 \
SHA1=43a138779e053a864bd16dfabcd3ffff04103213 \
maybe_fork "download || dienow"

# The g++ version must match gcc version.
URL=http://ftp.gnu.org/gnu/gcc/gcc-4.2.1/gcc-g++-4.2.1.tar.bz2 \
SHA1=8f3785bd0e092f563e14ecd26921cd04275496a6 \
maybe_fork "download || dienow"

else
# 2.25.1 is latest and is tainted by GPLv3
URL=ftp.gnu.org/gnu/binutils/binutils-2.25.1.tar.bz2 \
SHA1=1d597ae063e3947a5f61e23ceda8aebf78405fcd \
maybe_fork "download || dienow"

# 5.3.0 is latest and is tainted by GPLv3
URL=ftp.gnu.org/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.bz2 \
SHA1=0612270b103941da08376df4d0ef4e5662a2e9eb \
maybe_fork "download || dienow"

# GMP Required to build GCC 5.3
#
# We're using an older version from the gcc infrastructure page
# because we run into a bug in 6.1.0 as described here:
#
# https://gmplib.org/list-archives/gmp-bugs/2015-December/003848.html
#
URL=ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2 \
SHA1=c011e8feaf1bb89158bd55eaabd7ef8fdd101a2c \
maybe_fork "download || dienow"

# MPC Required to build GCC 5.3 (We're using latest version)
URL=ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz \
SHA1=b8be66396c726fdc36ebb0f692ed8a8cca3bcc66 \
maybe_fork "download || dienow"

# MPFR Required to build GCC 5.3 (We're using latest version)
URL=http://www.mpfr.org/mpfr-current/mpfr-3.1.3.tar.bz2 \
SHA1=3e46c5ce43701f2f36f9d01f407efe081700da80 \
maybe_fork "download || dienow"
fi

# Building a native root filesystem requires linux and uClibc (above) plus
# BusyBox. Adding a native toolchain requires binutils and gcc (above) plus
Expand Down
2 changes: 1 addition & 1 deletion host-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fi
# instance of these tools that occurs in the $PATH, in order, each in its
# own fallback directory.

for i in ar as nm cc make ld gcc objdump sh $HOST_EXTRA
for i in ar as nm ranlib cc make ld gcc g++ objdump sh $HOST_EXTRA
do
if [ ! -f "$STAGE_DIR/$i" ]
then
Expand Down
12 changes: 7 additions & 5 deletions native-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ then
fi
fi

# Build binutils, gcc, and ccwrap
# Build binutils, gcc, and ccwrap, using the gplv3 variant if requested
VARIANT=
[ ! -z "$ENABLE_GPLV3" ] && VARIANT="gplv3"

build_section binutils
build_section binutils $VARIANT
[ ! -z "$ELF2FLT" ] && build_section elf2flt
build_section gcc
build_section gcc $VARIANT
build_section ccwrap

# Tell future packages to link against the libraries in the new compiler,
Expand All @@ -46,9 +48,9 @@ export "$(echo $ARCH | sed 's/-/_/g')"_CCWRAP_TOPDIR="$STAGE_DIR"

if [ ! -z "$KARCH" ]
then
# Add C++ standard library
# Add C++ standard library (if we didnt build one in GCC 5.3)

[ -z "$NO_CPLUSPLUS" ] && build_section uClibc++
[ -z "$NO_CPLUSPLUS" ] && [ -z "$ENABLE_GPLV3" ] && build_section uClibc++

# For a native compiler, build make, bash, and distcc. (Yes, this is an old
# version of Bash. It's intentional.)
Expand Down
36 changes: 31 additions & 5 deletions simple-cross-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ check_for_base_arch || exit 0

export TOOLCHAIN_PREFIX="${ARCH}-"

# Build binutils, gcc, and ccwrap
if [ -z "$ENABLE_GPLV3" ]
then

# Build GPLv2 toolchain
build_section binutils
[ ! -z "$ELF2FLT" ] && build_section elf2flt
build_section gcc
build_section ccwrap
else

# Build GPLv3 toolchain, order is a bit different
build_section binutils gplv3
[ ! -z "$ELF2FLT" ] && build_section elf2flt
BASE_GCC=1 build_section gcc gplv3
fi

build_section binutils
[ ! -z "$ELF2FLT" ] && build_section elf2flt
build_section gcc
build_section ccwrap

if [ ! -z "$KARCH" ]
then
Expand All @@ -46,6 +56,13 @@ then
fi
fi

# Build the rest of the GPLv3 toolchain
if [ ! -z "$ENABLE_GPLV3" ]
then
build_section gcc gplv3
build_section ccwrap
fi

[ ! -z "$KARCH" ] && cat > "${STAGE_DIR}"/README << EOF
Cross compiler for $ARCH from http://landley.net/aboriginal

Expand Down Expand Up @@ -80,6 +97,15 @@ then
"${ARCH}-gcc" -Os -static "${SOURCES}/root-filesystem/src/hello.c" \
-o "$WORK"/hello || dienow

# If we build GCC 5.3, it needs to have a working C++ compiler
if [ ! -z "$ENABLE_GPLV3" ]
then
echo "Sanity test: building C++ Hello World."
"${ARCH}-g++" -Os "${SOURCES}/root-filesystem/src/hello.cpp" -o "$WORK"/hello &&
"${ARCH}-g++" -Os -static "${SOURCES}/root-filesystem/src/hello.cpp" \
-o "$WORK"/hello || dienow
fi

# Does the hello world we just built actually run?

if [ ! -z "$CROSS_SMOKE_TEST" ]
Expand Down
17 changes: 13 additions & 4 deletions sources/download_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ noversion()

gather_patches()
{
ls "$PATCHDIR/${PACKAGE}"-*.patch 2> /dev/null | sort | while read i
# Variant patches are found in the sources/patches-${variant} directory
# instead of the regular path
DIRECTORY=$PATCHDIR
[ ! -z "${PACKAGE_VARIANT}" ] && DIRECTORY="${PATCHDIR}-${PACKAGE_VARIANT}"

ls "$DIRECTORY/${PACKAGE}"-*.patch 2> /dev/null | sort | while read i
do
if [ -f "$i" ]
then
Expand Down Expand Up @@ -129,14 +134,18 @@ package_cache()
# Extract tarball named in $1 and apply all relevant patches into
# "$BUILD/packages/$1". Record sha1sum of tarball and patch files in
# sha1-for-source.txt. Re-extract if tarball or patches change.

#
# If $2 is specified it is a variant of the package, as such
# the variant name will be used as a basename for the patches instead
# of $1
extract_package()
{
mkdir -p "$SRCTREE" || dienow

# Announce to the world that we're cracking open a new package

PACKAGE="$1"
[ -z "$2" ] && PACKAGE_VARIANT= || PACKAGE_VARIANT=$2

# Announce to the world that we're cracking open a new package
announce "$PACKAGE"

! is_in_list "PACKAGE" "$IGNORE_REPOS" && [ -d "$SRCDIR/$PACKAGE" ] &&
Expand Down
57 changes: 46 additions & 11 deletions sources/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,26 @@ load_target()
# during root-filesystem.sh, and the host compiler links binaries against the
# wrong libc.)
export_if_blank CROSS_HOST=`uname -m`-walrus-linux
export_if_blank CROSS_TARGET=${ARCH}-unknown-linux
if [ -z "$CROSS_TARGET" ]
then
CROSS_TARGET=${ARCH}-unknown-linux-gnu
fi

# If we are building GCC 5 with musl, we need to make
# sure that the target arch has -linux-musl* in the
# triplet.
#
# Assume that the target files specify 'gnu' and
# just change it manually here, so we will change
# things like -gnueabi for -musleabi
if [ ! -z "$ENABLE_GPLV3" ]
then
if [ -z "$UCLIBC_CONFIG" ] || [ ! -z "$MUSL" ]
then
CROSS_TARGET="${CROSS_TARGET/gnu/musl}"
fi
fi
export CROSS_TARGET

# Setup directories and add the cross compiler to the start of the path.

Expand All @@ -93,26 +112,39 @@ load_target()

# Note that this sources the file, rather than calling it as a separate
# process. That way it can set environment variables if it wants to.

#
# If $2 is given, it is used as a variant name for the build script
# and patches instead of $1, $2 is essentially a variant of the
# package $1 and allows basic support for multiple versions of the
# same package.
build_section()
{
PACKAGE_NAME=$1
SCRIPT_NAME=$1
PACKAGE_VARIANT=
if [ ! -z "$2" ]
then
PACKAGE_VARIANT="$2"
SCRIPT_NAME="${PACKAGE_NAME}-${PACKAGE_VARIANT}"
fi

# Don't build anything statically in host-tools, glibc is broken.
# See http://people.redhat.com/drepper/no_static_linking.html for
# insane rant from the glibc maintainer about why he doesn't care.
is_in_list $1 $BUILD_STATIC && [ ! -z "$ARCH" ] && STATIC_FLAGS="--static"
is_in_list $PACKAGE_NAME $BUILD_STATIC && [ ! -z "$ARCH" ] && STATIC_FLAGS="--static"

OLDCPUS=$CPUS
OLDNOCLEAN=$NO_CLEANUP
is_in_list $1 $DEBUG_PACKAGE && CPUS=1 && NO_CLEANUP=1
is_in_list $PACKAGE_NAME $DEBUG_PACKAGE && CPUS=1 && NO_CLEANUP=1

if [ -e "$SOURCES/sections/$1".build ]
if [ -e "$SOURCES/sections/$SCRIPT_NAME".build ]
then
setupfor "$1"
. "$SOURCES/sections/$1".build
setupfor "$PACKAGE_NAME" "$PACKAGE_VARIANT"
. "$SOURCES/sections/$SCRIPT_NAME".build
cleanup
else
announce "$1"
. "$SOURCES"/sections/"$1".sh
announce "$PACKAGE_NAME"
. "$SOURCES"/sections/"$SCRIPT_NAME".sh
fi
CPUS=$OLDCPUS
NO_CLEANUP=$OLDNOCLEAN
Expand Down Expand Up @@ -200,13 +232,16 @@ blank_workdir()
}

# Extract package $1

#
# If $2 is specified it is a variant of the package, as such
# the variant name will be used as a basename for the patches instead
# of $1
setupfor()
{
export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.${ARCH_NAME}.${STAGE_NAME}.setupfor"

# Make sure the source is already extracted and up-to-date.
extract_package "$1" || exit 1
extract_package "$1" "$2" || exit 1
SNAPFROM="$(package_cache "$1")"

# Delete old working copy (even in the NO_CLEANUP case) then make a new
Expand Down
Loading