Skip to content

Commit d134085

Browse files
authored
Merge pull request #1285 from alfred-bratterud/new_bundle
Fixes to dependency bundle build
2 parents e371137 + 9c8f9a6 commit d134085

39 files changed

+201
-11025
lines changed

api/posix/ctype.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
// See the License for the specific language governing permissions and
1616
// limitations under the License.
1717

18+
// Trick to prevent libc++ from using old newlib locale stubs
19+
#define _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H
20+
21+
1822
#ifndef SYS_CTYPE_H
1923
#define SYS_CTYPE_H
2024

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

4145
#endif //SYS_CTYPE_H
4246

43-
4447
#include_next <ctype.h>

api/posix/features.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
#define _POSIX_TIMERS 1
2828
#define _POSIX_MONOTONIC_CLOCK 1
2929

30+
// Enable newlib multibyte support
31+
#define _MB_CAPABLE 1
32+
33+
34+
3035
// Required to pass CMake tests for libc++
3136
#define __GLIBC_PREREQ__(min, maj) 1
3237
#define __GLIBC_PREREQ(min, maj) 1

cmake/cross_compiled_libraries.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ set(PRECOMPILED_DIR ${CMAKE_CURRENT_BINARY_DIR}/precompiled/src/PrecompiledLibra
3232
set(LIBCXX_INCLUDE_DIR ${PRECOMPILED_DIR}libcxx/include/)
3333
set(LIBCXX_LIB_DIR ${PRECOMPILED_DIR}/libcxx/)
3434
add_library(libcxx STATIC IMPORTED)
35+
add_library(libcxxabi STATIC IMPORTED)
36+
3537
add_dependencies(libcxx PrecompiledLibraries)
38+
add_dependencies(libcxxabi PrecompiledLibraries)
3639
set_target_properties(libcxx PROPERTIES IMPORTED_LOCATION ${LIBCXX_LIB_DIR}/libc++.a)
40+
set_target_properties(libcxxabi PROPERTIES IMPORTED_LOCATION ${LIBCXX_LIB_DIR}/libc++abi.a)
3741

3842
set(NEWLIB_INCLUDE_DIR ${PRECOMPILED_DIR}/newlib/include/)
3943
set(NEWLIB_LIB_DIR ${PRECOMPILED_DIR}/newlib/)
@@ -62,4 +66,4 @@ install(DIRECTORY ${NEWLIB_INCLUDE_DIR} DESTINATION includeos/include/newlib)
6266

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

65-
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)
69+
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)

etc/build_binutils.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
1+
#! /bin/bash
2+
. $INCLUDEOS_SRC/etc/set_traps.sh
3+
4+
# Download, configure and build binutils
5+
16
pushd $BUILD_DIR
27

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

8-
14+
# Extracting
915
if [ ! -d binutils-$binutils_version ]; then
1016
echo -e "\n\n >>> Extracting binutils \n"
1117
tar -xf binutils-$binutils_version.tar.gz
18+
rm -rf build_binutils # If a new version has been downloaded it will be built
1219
else
1320
echo -e "\n\n >>> SKIP: Extracting binutils \n"
1421
fi
1522

23+
# Configuring
1624
if [ ! -d build_binutils ]; then
1725
echo -e "\n\n >>> Configuring binutils \n"
1826
mkdir -p build_binutils
1927
cd build_binutils
20-
../binutils-$binutils_version/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --disable-werror
28+
../binutils-$binutils_version/configure \
29+
--target=$TARGET \
30+
--prefix="$TEMP_INSTALL_DIR" \
31+
--disable-nls \
32+
--disable-werror
2133

34+
# Compiling
2235
echo -e "\n\n >>> Building binutils \n"
2336
make $num_jobs
2437

38+
# Installing
2539
echo -e "\n\n >>> Installing binutils \n"
2640
make install
2741

@@ -30,3 +44,5 @@ else
3044
fi
3145

3246
popd
47+
48+
trap - EXIT
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# Bash utils
1+
#!/bin/bash
22
. $INCLUDEOS_SRC/etc/set_traps.sh
33

4-
mkdir -p $BUILD_DIR
5-
cd $BUILD_DIR
4+
# Download, configure, compile and install gcc
65

7-
GCC_LOC=ftp://ftp.nluug.nl/mirror/languages/gcc/releases/
6+
pushd $BUILD_DIR
87

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

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

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

29-
cd $BUILD_DIR
30-
31-
3229
mkdir -p build_gcc
33-
cd build_gcc
30+
pushd build_gcc
3431

32+
# Configure
3533
echo -e "\n\n >>> Configuring GCC \n"
36-
../gcc-$gcc_version/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
37-
34+
../gcc-$gcc_version/configure \
35+
--target=$TARGET \
36+
--prefix="$TEMP_INSTALL_DIR" \
37+
--disable-nls \
38+
--enable-languages=c,c++ \
39+
--without-headers
40+
41+
# Compile
3842
echo -e "\n\n >>> Building GCC \n"
3943
make all-gcc $num_jobs
4044

45+
# Install
4146
echo -e "\n\n >>> Installing GCC (Might require sudo) \n"
4247
make install-gcc
4348

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

50-
55+
popd # build_gcc
56+
popd # BUILD_DIR
5157
trap - EXIT

etc/build_llvm32.sh

Lines changed: 40 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
11
#! /bin/bash
2-
set -e # Exit immediately on error (were trapping the exit signal)
3-
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
4-
trap 'echo -e "\nINSTALL FAILED ON COMMAND: $previous_command\n"' EXIT
2+
. $INCLUDEOS_SRC/etc/set_traps.sh
53

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

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

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

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

21-
IncludeOS_posix=$INCLUDEOS_SRC/api/posix
22-
libcxx_inc=$BUILD_DIR/$llvm_src/projects/libcxx/include
23-
#LLVM_TAG=RELEASE_381/final
16+
cd $BUILD_DIR
2417

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

3020
if [ ! -z $download_llvm ]; then
3121
# Clone LLVM
32-
svn co http://llvm.org/svn/llvm-project/llvm/tags/$LLVM_TAG $llvm_src
33-
# git clone http://llvm.org/git/llvm
34-
35-
# Clone CLANG - not necessary to build only libc++ and libc++abi
36-
# cd llvm/tools
37-
# svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
38-
# svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
22+
svn co http://llvm.org/svn/llvm-project/llvm/tags/$LLVM_TAG llvm
3923

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

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

5943
# Back to start
60-
cd ../../
44+
popd
6145
fi
6246

6347
# Make a build-directory
64-
mkdir -p $llvm_build
65-
cd $llvm_build
48+
mkdir -p build_llvm
49+
pushd build_llvm
6650

6751
if [ ! -z $clear_llvm_build_cache ]; then
6852
rm CMakeCache.txt
6953
fi
7054

71-
# General options
72-
OPTS=-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "
73-
74-
# LLVM General options
75-
OPTS+=-DBUILD_SHARED_LIBS=OFF" "
76-
OPTS+=-DCMAKE_BUILD_TYPE=MinSizeRel" "
77-
#OPTS+=-DCMAKE_BUILD_TYPE=Release" "
78-
79-
# Can't build libc++ with g++ unless it's a cross compiler (need to specify target)
80-
OPTS+=-DCMAKE_C_COMPILER=clang-$clang_version" "
81-
OPTS+=-DCMAKE_CXX_COMPILER=clang++-$clang_version" " # -std=c++11" "
82-
8355
TRIPLE=i686-pc-none-elf
84-
85-
OPTS+=-DTARGET_TRIPLE=$TRIPLE" "
86-
OPTS+=-DLLVM_BUILD_32_BITS=ON" "
87-
OPTS+=-DLLVM_INCLUDE_TESTS=OFF" "
88-
OPTS+=-DLLVM_ENABLE_THREADS=OFF" "
89-
OPTS+=-DLLVM_DEFAULT_TARGET_TRIPLE=$TRIPLE" "
90-
91-
# libc++-specific options
92-
OPTS+=-DLIBCXX_ENABLE_SHARED=OFF" "
93-
OPTS+=-DLIBCXX_ENABLE_THREADS=OFF" "
94-
OPTS+=-DLIBCXX_TARGET_TRIPLE=$TRIPLE" "
95-
OPTS+=-DLIBCXX_BUILD_32_BITS=ON" "
96-
97-
# OPTS+=-DLIBCXX_GCC_TOOLCHAIN=/usr/local/IncludeOS/i686/" "
98-
OPTS+=-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON" "
99-
100-
OPTS+=-DLIBCXX_CXX_ABI=libcxxabi" "
101-
OPTS+=-DLIBCXX_CXX_ABI_INCLUDE_PATHS=$INCLUDEOS_SRC/src/include" "
102-
103-
104-
# libunwind-specific options
105-
OPTS+=-DLIBUNWIND_ENABLE_SHARED=OFF" "
106-
OPTS+=-LIBCXXABI_USE_LLVM_UNWINDER=ON" "
107-
108-
echo "LLVM CMake Build options:" $OPTS
109-
110-
# CXX flags
111-
CXX_FLAGS="-std=c++14 -nostdlibinc -mavx -maes -mfma"
56+
CXX_FLAGS="-std=c++14 -msse3"
11257

11358
# CMAKE configure step
11459
#
115-
# NOTE: It seems impossible to pass in cxx-flags like this; I've tried \' \\" \\\" etc.
116-
#
11760
# Include-path ordering:
11861
# 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)
11962
# 2. libcxx_inc must come before newlib, due to math.h function wrappers around C99 macros (signbit, nan etc)
12063
# 3. newlib_inc provodes standard C headers
121-
cmake -GNinja $OPTS -DCMAKE_CXX_FLAGS="$CXX_FLAGS -I$IncludeOS_posix -I$libcxx_inc -I$newlib_inc" $BUILD_DIR/$llvm_src
64+
cmake -GNinja $OPTS \
65+
-DCMAKE_CXX_FLAGS="$CXX_FLAGS -I$IncludeOS_posix -I$libcxxabi_inc -I$libcxx_inc -I$newlib_inc " $BUILD_DIR/llvm \
66+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
67+
-DBUILD_SHARED_LIBS=OFF \
68+
-DCMAKE_C_COMPILER=clang-$clang_version \
69+
-DCMAKE_CXX_COMPILER=clang++-$clang_version \
70+
-DTARGET_TRIPLE=$TRIPLE \
71+
-DLLVM_BUILD_32_BITS=ON \
72+
-DLLVM_INCLUDE_TESTS=OFF \
73+
-DLLVM_ENABLE_THREADS=OFF \
74+
-DLLVM_DEFAULT_TARGET_TRIPLE=$TRIPLE \
75+
-DLIBCXX_ENABLE_SHARED=OFF \
76+
-DLIBCXX_ENABLE_THREADS=OFF \
77+
-DLIBCXX_TARGET_TRIPLE=$TRIPLE \
78+
-DLIBCXX_BUILD_32_BITS=ON \
79+
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
80+
-DLIBCXX_CXX_ABI=libcxxabi \
81+
-DLIBCXXABI_TARGET_TRIPLE=$TRIPLE \
82+
-DLIBCXXABI_ENABLE_THREADS=OFF \
83+
-DLIBCXXABI_HAS_PTHREAD_API=OFF
12284

12385

124-
#
12586
# MAKE
126-
#
127-
# Using ninja
128-
#
129-
# ninja libc++abi.a
130-
ninja libc++.a
131-
# ninja libunwind.a
132-
# ninja compiler-rt
133-
134-
#
135-
# MAKE
136-
#
137-
# Using makefiles
138-
# make cxx
139-
# make cxxabi
140-
# unwind
87+
ninja libc++abi.a
88+
ninja libc++.a
14189

90+
popd
14291

14392
trap - EXIT

0 commit comments

Comments
 (0)