Skip to content

Commit

Permalink
Merge pull request #1285 from alfred-bratterud/new_bundle
Browse files Browse the repository at this point in the history
Fixes to dependency bundle build
  • Loading branch information
fwsGonzo authored Apr 3, 2017
2 parents e371137 + 9c8f9a6 commit d134085
Show file tree
Hide file tree
Showing 39 changed files with 201 additions and 11,025 deletions.
5 changes: 4 additions & 1 deletion api/posix/ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Trick to prevent libc++ from using old newlib locale stubs
#define _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H


#ifndef SYS_CTYPE_H
#define SYS_CTYPE_H

Expand All @@ -40,5 +44,4 @@ extern "C" {

#endif //SYS_CTYPE_H


#include_next <ctype.h>
5 changes: 5 additions & 0 deletions api/posix/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#define _POSIX_TIMERS 1
#define _POSIX_MONOTONIC_CLOCK 1

// Enable newlib multibyte support
#define _MB_CAPABLE 1



// Required to pass CMake tests for libc++
#define __GLIBC_PREREQ__(min, maj) 1
#define __GLIBC_PREREQ(min, maj) 1
Expand Down
6 changes: 5 additions & 1 deletion cmake/cross_compiled_libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ set(PRECOMPILED_DIR ${CMAKE_CURRENT_BINARY_DIR}/precompiled/src/PrecompiledLibra
set(LIBCXX_INCLUDE_DIR ${PRECOMPILED_DIR}libcxx/include/)
set(LIBCXX_LIB_DIR ${PRECOMPILED_DIR}/libcxx/)
add_library(libcxx STATIC IMPORTED)
add_library(libcxxabi STATIC IMPORTED)

add_dependencies(libcxx PrecompiledLibraries)
add_dependencies(libcxxabi PrecompiledLibraries)
set_target_properties(libcxx PROPERTIES IMPORTED_LOCATION ${LIBCXX_LIB_DIR}/libc++.a)
set_target_properties(libcxxabi PROPERTIES IMPORTED_LOCATION ${LIBCXX_LIB_DIR}/libc++abi.a)

set(NEWLIB_INCLUDE_DIR ${PRECOMPILED_DIR}/newlib/include/)
set(NEWLIB_LIB_DIR ${PRECOMPILED_DIR}/newlib/)
Expand Down Expand Up @@ -62,4 +66,4 @@ install(DIRECTORY ${NEWLIB_INCLUDE_DIR} DESTINATION includeos/include/newlib)

install(FILES ${CRTEND} ${CRTBEGIN} DESTINATION includeos/lib)

install(FILES ${NEWLIB_LIB_DIR}/libc.a ${NEWLIB_LIB_DIR}/libg.a ${NEWLIB_LIB_DIR}/libm.a ${LIBGCC_LIB_DIR}/libgcc.a ${LIBCXX_LIB_DIR}/libc++.a DESTINATION includeos/lib)
install(FILES ${NEWLIB_LIB_DIR}/libc.a ${NEWLIB_LIB_DIR}/libg.a ${NEWLIB_LIB_DIR}/libm.a ${LIBGCC_LIB_DIR}/libgcc.a ${LIBCXX_LIB_DIR}/libc++.a ${LIBCXX_LIB_DIR}/libc++abi.a DESTINATION includeos/lib)
20 changes: 18 additions & 2 deletions etc/build_binutils.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
#! /bin/bash
. $INCLUDEOS_SRC/etc/set_traps.sh

# Download, configure and build binutils

pushd $BUILD_DIR

# Downloading
if [ ! -f binutils-$binutils_version.tar.gz ]; then
echo -e "\n\n >>> Getting binutils into `pwd` \n"
wget -c --trust-server-name ftp://ftp.gnu.org/gnu/binutils/binutils-$binutils_version.tar.gz
fi


# Extracting
if [ ! -d binutils-$binutils_version ]; then
echo -e "\n\n >>> Extracting binutils \n"
tar -xf binutils-$binutils_version.tar.gz
rm -rf build_binutils # If a new version has been downloaded it will be built
else
echo -e "\n\n >>> SKIP: Extracting binutils \n"
fi

# Configuring
if [ ! -d build_binutils ]; then
echo -e "\n\n >>> Configuring binutils \n"
mkdir -p build_binutils
cd build_binutils
../binutils-$binutils_version/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --disable-werror
../binutils-$binutils_version/configure \
--target=$TARGET \
--prefix="$TEMP_INSTALL_DIR" \
--disable-nls \
--disable-werror

# Compiling
echo -e "\n\n >>> Building binutils \n"
make $num_jobs

# Installing
echo -e "\n\n >>> Installing binutils \n"
make install

Expand All @@ -30,3 +44,5 @@ else
fi

popd

trap - EXIT
30 changes: 18 additions & 12 deletions etc/cross_compiler.sh → etc/build_gcc.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Bash utils
#!/bin/bash
. $INCLUDEOS_SRC/etc/set_traps.sh

mkdir -p $BUILD_DIR
cd $BUILD_DIR
# Download, configure, compile and install gcc

GCC_LOC=ftp://ftp.nluug.nl/mirror/languages/gcc/releases/
pushd $BUILD_DIR

# Download
if [ ! -f gcc-$gcc_version.tar.gz ]; then
echo -e "\n\n >>> Getting GCC \n"
GCC_LOC=ftp://ftp.nluug.nl/mirror/languages/gcc/releases/
wget -c --trust-server-name $GCC_LOC/gcc-$gcc_version/gcc-$gcc_version.tar.gz
fi

# UNPACK GCC
if [ ! -d gcc-$gcc_version ]; then
echo -e "\n\n >>> Unpacking GCC source \n"
cd $BUILD_DIR
tar -xf gcc-$gcc_version.tar.gz

# GET GCC PREREQS
Expand All @@ -26,18 +26,23 @@ else
echo -e "\n\n >>> SKIP: Unpacking GCC + getting prerequisites Seems to be there \n"
fi

cd $BUILD_DIR


mkdir -p build_gcc
cd build_gcc
pushd build_gcc

# Configure
echo -e "\n\n >>> Configuring GCC \n"
../gcc-$gcc_version/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers

../gcc-$gcc_version/configure \
--target=$TARGET \
--prefix="$TEMP_INSTALL_DIR" \
--disable-nls \
--enable-languages=c,c++ \
--without-headers

# Compile
echo -e "\n\n >>> Building GCC \n"
make all-gcc $num_jobs

# Install
echo -e "\n\n >>> Installing GCC (Might require sudo) \n"
make install-gcc

Expand All @@ -47,5 +52,6 @@ make all-target-libgcc $num_jobs
echo -e "\n\n >>> Installing libgcc (Might require sudo) \n"
make install-target-libgcc


popd # build_gcc
popd # BUILD_DIR
trap - EXIT
131 changes: 40 additions & 91 deletions etc/build_llvm32.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
#! /bin/bash
set -e # Exit immediately on error (were trapping the exit signal)
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo -e "\nINSTALL FAILED ON COMMAND: $previous_command\n"' EXIT
. $INCLUDEOS_SRC/etc/set_traps.sh

#
# NOTE THE FOLLOWING VARIABLES HAS TO BE DEFINED:
#
# llvm_src -> path to clone llvm repo
# llvm_build-> path to build llvm-libs. (must beoutside of llvm)
# INCLUDEOS_SRC -> InclueOS git source (i.e =$HOME/IncludeOS)
# newlib_inc -> Include-path for newlib headers
# Download, configure, compile and install llvm

newlib_inc=$TEMP_INSTALL_DIR/i686-elf/include # path for newlib headers
IncludeOS_posix=$INCLUDEOS_SRC/api/posix
libcxx_inc=$BUILD_DIR/llvm/projects/libcxx/include
libcxxabi_inc=$BUILD_DIR/llvm/projects/libcxxabi/include

# OPTIONALS (required the first time, but optional later):
#
# $install_llvm_dependencies: required paackages, cmake, ninja etc.
# $download_llvm: Clone llvm svn sources
# sysroot=$BUILD_DIR/IncludeOS_TEMP_install/i686-elf

# Install dependencies
sudo apt-get install -y cmake ninja-build subversion zlib1g-dev libtinfo-dev

IncludeOS_posix=$INCLUDEOS_SRC/api/posix
libcxx_inc=$BUILD_DIR/$llvm_src/projects/libcxx/include
#LLVM_TAG=RELEASE_381/final
cd $BUILD_DIR

if [ ! -z $install_llvm_dependencies ]; then
# Dependencies
sudo apt-get install -y cmake ninja-build subversion zlib1g-dev libtinfo-dev
fi
download_llvm=${download_llvm:-"1"} # This should be more dynamic

if [ ! -z $download_llvm ]; then
# Clone LLVM
svn co http://llvm.org/svn/llvm-project/llvm/tags/$LLVM_TAG $llvm_src
# git clone http://llvm.org/git/llvm

# Clone CLANG - not necessary to build only libc++ and libc++abi
# cd llvm/tools
# svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
# svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
svn co http://llvm.org/svn/llvm-project/llvm/tags/$LLVM_TAG llvm

# Clone libc++, libc++abi, and some extra stuff (recommended / required for clang)
cd $llvm_src/projects
pushd llvm/projects

# Compiler-rt
svn co http://llvm.org/svn/llvm-project/compiler-rt/tags/$LLVM_TAG compiler-rt
Expand All @@ -57,87 +41,52 @@ if [ ! -z $download_llvm ]; then
#git clone http://llvm.org/git/libunwind

# Back to start
cd ../../
popd
fi

# Make a build-directory
mkdir -p $llvm_build
cd $llvm_build
mkdir -p build_llvm
pushd build_llvm

if [ ! -z $clear_llvm_build_cache ]; then
rm CMakeCache.txt
fi

# General options
OPTS=-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "

# LLVM General options
OPTS+=-DBUILD_SHARED_LIBS=OFF" "
OPTS+=-DCMAKE_BUILD_TYPE=MinSizeRel" "
#OPTS+=-DCMAKE_BUILD_TYPE=Release" "

# Can't build libc++ with g++ unless it's a cross compiler (need to specify target)
OPTS+=-DCMAKE_C_COMPILER=clang-$clang_version" "
OPTS+=-DCMAKE_CXX_COMPILER=clang++-$clang_version" " # -std=c++11" "

TRIPLE=i686-pc-none-elf

OPTS+=-DTARGET_TRIPLE=$TRIPLE" "
OPTS+=-DLLVM_BUILD_32_BITS=ON" "
OPTS+=-DLLVM_INCLUDE_TESTS=OFF" "
OPTS+=-DLLVM_ENABLE_THREADS=OFF" "
OPTS+=-DLLVM_DEFAULT_TARGET_TRIPLE=$TRIPLE" "

# libc++-specific options
OPTS+=-DLIBCXX_ENABLE_SHARED=OFF" "
OPTS+=-DLIBCXX_ENABLE_THREADS=OFF" "
OPTS+=-DLIBCXX_TARGET_TRIPLE=$TRIPLE" "
OPTS+=-DLIBCXX_BUILD_32_BITS=ON" "

# OPTS+=-DLIBCXX_GCC_TOOLCHAIN=/usr/local/IncludeOS/i686/" "
OPTS+=-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON" "

OPTS+=-DLIBCXX_CXX_ABI=libcxxabi" "
OPTS+=-DLIBCXX_CXX_ABI_INCLUDE_PATHS=$INCLUDEOS_SRC/src/include" "


# libunwind-specific options
OPTS+=-DLIBUNWIND_ENABLE_SHARED=OFF" "
OPTS+=-LIBCXXABI_USE_LLVM_UNWINDER=ON" "

echo "LLVM CMake Build options:" $OPTS

# CXX flags
CXX_FLAGS="-std=c++14 -nostdlibinc -mavx -maes -mfma"
CXX_FLAGS="-std=c++14 -msse3"

# CMAKE configure step
#
# NOTE: It seems impossible to pass in cxx-flags like this; I've tried \' \\" \\\" etc.
#
# Include-path ordering:
# 1. IncludeOS_posix has to come first, as it provides lots of C11 prototypes that libc++ relies on, but which newlib does not provide (see our math.h)
# 2. libcxx_inc must come before newlib, due to math.h function wrappers around C99 macros (signbit, nan etc)
# 3. newlib_inc provodes standard C headers
cmake -GNinja $OPTS -DCMAKE_CXX_FLAGS="$CXX_FLAGS -I$IncludeOS_posix -I$libcxx_inc -I$newlib_inc" $BUILD_DIR/$llvm_src
cmake -GNinja $OPTS \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS -I$IncludeOS_posix -I$libcxxabi_inc -I$libcxx_inc -I$newlib_inc " $BUILD_DIR/llvm \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_COMPILER=clang-$clang_version \
-DCMAKE_CXX_COMPILER=clang++-$clang_version \
-DTARGET_TRIPLE=$TRIPLE \
-DLLVM_BUILD_32_BITS=ON \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_ENABLE_THREADS=OFF \
-DLLVM_DEFAULT_TARGET_TRIPLE=$TRIPLE \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_ENABLE_THREADS=OFF \
-DLIBCXX_TARGET_TRIPLE=$TRIPLE \
-DLIBCXX_BUILD_32_BITS=ON \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
-DLIBCXX_CXX_ABI=libcxxabi \
-DLIBCXXABI_TARGET_TRIPLE=$TRIPLE \
-DLIBCXXABI_ENABLE_THREADS=OFF \
-DLIBCXXABI_HAS_PTHREAD_API=OFF


#
# MAKE
#
# Using ninja
#
# ninja libc++abi.a
ninja libc++.a
# ninja libunwind.a
# ninja compiler-rt

#
# MAKE
#
# Using makefiles
# make cxx
# make cxxabi
# unwind
ninja libc++abi.a
ninja libc++.a

popd

trap - EXIT
Loading

0 comments on commit d134085

Please sign in to comment.