Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 8 additions & 19 deletions api/sys/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -17,25 +17,14 @@

#ifndef SYS_FEATURES_H
#define SYS_FEATURES_H

// Newlib needs this switch to enable clock_gettime etc.
// Also, we'll need posix timers sooner or later
#define _POSIX_TIMERS 1

#ifndef __GNUC_PREREQ
#define __GNUC_PREREQ(A, B) 0 /* Nei */
#endif

// Newlib needs this switch to enable clock_gettime etc.
#define _POSIX_TIMERS 1

/** Apparently this is necessary in order to build libc++.
@todo : It creates a warning when building os.a;
find another way to provide it to libc++.
*/
#ifndef __GNUC_PREREQ__
#define __GNUC_PREREQ__(A, B) __GNUC_PREREQ(A, B)
#endif
// Required to pass CMake tests for libc++
#define __GLIBC_PREREQ__(min, maj) 1
#define __GLIBC_PREREQ(min, maj) 1

#define __GLIBC_PREREQ__(A, B) 1 /* Jo. */
#define __GLIBC_PREREQ(A, B) 1 /* Jo. */
#include_next <sys/features.h>

#endif
8 changes: 3 additions & 5 deletions api/sys/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -59,12 +59,10 @@ long double fdiml(long double, long double);
long double fmal(long double, long double, long double);
long double fmaxl(long double, long double);
long double fminl(long double, long double);
long double hypotl(long double, long double);


long double expl(long double);
long double ldexpl(long double, long double);
long double sqrtl(long double);

long double ilogbl(long double);
long double lgammal(long double);
long double llroundl(long double);
Expand Down
7 changes: 3 additions & 4 deletions api/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -18,13 +18,12 @@
#include "features.h"
#include_next <sys/time.h>
#include_next <time.h>

#ifndef SYS_TIME_H
#define SYS_TIME_H


// We might possibly need additions here.
#define CLOCK_MONOTONIC 4


#endif

6 changes: 3 additions & 3 deletions api/sys/wchar.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -25,7 +25,7 @@ extern "C" {
#endif

/** @WARNING Loses precision **/
static inline long double wcstold (const wchar_t* str, wchar_t** endptr) {
inline long double wcstold (const wchar_t* str, wchar_t** endptr) {
return wcstod(str,endptr);
}

Expand Down
62 changes: 26 additions & 36 deletions etc/build_llvm32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ trap 'echo -e "\nINSTALL FAILED ON COMMAND: $previous_command\n"' EXIT
# 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


# OPTIONALS (required the first time, but optional later):
#
# $install_llvm_dependencies: required paackages, cmake, ninja etc.
# $install_llvm_dependencies: required paackages, cmake, ninja etc.
# $download_llvm: Clone llvm svn sources


IncludeOS_sys=$INCLUDEOS_SRC/api/sys

libcxx_inc=$BUILD_DIR/$llvm_src/projects/libcxx/include


if [ ! -z $install_llvm_dependencies ]; then
Expand All @@ -27,34 +28,34 @@ if [ ! -z $install_llvm_dependencies ]; then
fi

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

# Clone CLANG - not necessary to build only libc++ and libc++abi
# cd llvm/tools
# 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

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

# Compiler-rt
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
# git clone http://llvm.org/git/llvm compiler-rt

# libc++abi
svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi
# git clone http://llvm.org/git/libcxxabi

# libc++
svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
# git clone http://llvm.org/git/libcxx

# libunwind
svn co http://llvm.org/svn/llvm-project/libunwind/trunk libunwind
#git clone http://llvm.org/git/libunwind

# Back to start
cd ../../
fi
Expand All @@ -79,12 +80,6 @@ OPTS+=-DCMAKE_BUILD_TYPE=MinSizeRel" "
OPTS+=-DCMAKE_C_COMPILER=clang-$clang_version" "
OPTS+=-DCMAKE_CXX_COMPILER=clang++-$clang_version" " # -std=c++11" "

#
# WARNING: It seems imossible to pass in cxx-flags like this; I've tried \' \\" \\\" etc.
#
# OPTS+="-DCMAKE_CXX_FLAGS='-I/home/alfred/IncludeOS/stdlib/support -I/usr/local/IncludeOS/i686-elf/include -I/home/alfred/IncludeOS/stdlib/support/newlib -I/home/alfred/IncludeOS/src/include' "
# OPTS+='-DCMAKE_CXX_FLAGS=-I/home/alfred/IncludeOS/stdlib/support -I/usr/local/IncludeOS/i686-elf/include -I/home/alfred/IncludeOS/stdlib/support/newlib -I/home/alfred/IncludeOS/src/include '

TRIPLE=i686-pc-none-elf

OPTS+=-DTARGET_TRIPLE=$TRIPLE" "
Expand Down Expand Up @@ -113,31 +108,26 @@ OPTS+=-LIBCXXABI_USE_LLVM_UNWINDER=ON" "
echo "LLVM CMake Build options:" $OPTS


# CMAKE
# Using Ninja (slightly faster, but not by much)
#
# WARNING: The following will cause the "requires std::atomic" error.
# (For some reason - the headers should be the same as in llbm/projects/libcxx/include - our mods causes this?"
#
# -I/$IncludeOS_Source/IncludeOS/stdlib

# Various search-path stuff
# -nostdinc -nostdlib -nodefaultlibs -ffreestanding -isystem /usr/local/IncludeOS/i686/ --sysroot=/usr/local/IncludeOS/i686


# NOTE: It seems impossible to pass in cxx-flags like this; I've tried \' \\" \\\" etc.
#
# CONFIGURE
# OPTS+="-DCMAKE_CXX_FLAGS='-I/home/alfred/IncludeOS/stdlib/support -I/usr/local/IncludeOS/i686-elf/include -I/home/alfred/IncludeOS/stdlib/support/newlib -I/home/alfred/IncludeOS/src/include' "
# OPTS+='-DCMAKE_CXX_FLAGS=-I/home/alfred/IncludeOS/stdlib/support -I/usr/local/IncludeOS/i686-elf/include -I/home/alfred/IncludeOS/stdlib/support/newlib -I/home/alfred/IncludeOS/src/include '
#
# Using makefiles
# time cmake -G"Unix Makefiles" $OPTS ../$llvm_src

llvm_src_verbose=-v
libcxx_inc=$BUILD_DIR/$llvm_src/projects/libcxx/include

# Using Ninja (slightly faster, but not by much)
cmake -GNinja $OPTS -DCMAKE_CXX_FLAGS="-std=c++11 $llvm_src_verbose -I$IncludeOS_sys -I$libcxx_inc -I$INCLUDEOS_SRC/api -I$newlib_inc -I$INCLUDEOS_SRC/src/include/ -I$INCLUDEOS_SRC/stdlib/support/newlib/ " $BUILD_DIR/$llvm_src # -DCMAKE_CXX_COMPILER='clang++ -std=c++11
# Include-path ordering:
# 1. IncludeOS_sys 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
# 4. IncludeOS/api provides sys-specific paths such as "sys/time.h"
# 5.
cmake -GNinja $OPTS -DCMAKE_CXX_FLAGS="-std=c++11 $llvm_src_verbose -I$IncludeOS_sys -I$libcxx_inc -I$newlib_inc -I$INCLUDEOS_SRC/api -I$INCLUDEOS_SRC/src/include/ -I$INCLUDEOS_SRC/stdlib/support/newlib/ " $BUILD_DIR/$llvm_src


#
# MAKE
# MAKE
#
# Using ninja
#
Expand Down
12 changes: 6 additions & 6 deletions etc/newlib_clang.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -Naur newlib-2.2.0-1/newlib/libm/machine/i386/f_ldexp.S newlib-2.2.0-1_patched/newlib/libm/machine/i386/f_ldexp.S
--- newlib-2.2.0-1/newlib/libm/machine/i386/f_ldexp.S 2002-12-20 22:31:20.000000000 +0100
+++ newlib-2.2.0-1_patched/newlib/libm/machine/i386/f_ldexp.S 2015-11-01 17:00:59.215426521 +0100
diff -Naur newlib-2.4.0/newlib/libm/machine/i386/f_ldexp.S newlib-2.4.0_patched/newlib/libm/machine/i386/f_ldexp.S
--- newlib-2.4.0/newlib/libm/machine/i386/f_ldexp.S 2002-12-20 22:31:20.000000000 +0100
+++ newlib-2.4.0_patched/newlib/libm/machine/i386/f_ldexp.S 2015-11-01 17:00:59.215426521 +0100
@@ -27,7 +27,7 @@
SYM (_f_ldexp):
pushl ebp
Expand All @@ -10,9 +10,9 @@ diff -Naur newlib-2.2.0-1/newlib/libm/machine/i386/f_ldexp.S newlib-2.2.0-1_patc
fldl 8(ebp)
fscale
fstp st1
diff -Naur newlib-2.2.0-1/newlib/libm/machine/i386/f_ldexpf.S newlib-2.2.0-1_patched/newlib/libm/machine/i386/f_ldexpf.S
--- newlib-2.2.0-1/newlib/libm/machine/i386/f_ldexpf.S 2002-12-20 22:31:20.000000000 +0100
+++ newlib-2.2.0-1_patched/newlib/libm/machine/i386/f_ldexpf.S 2015-11-01 16:58:23.646121581 +0100
diff -Naur newlib-2.4.0/newlib/libm/machine/i386/f_ldexpf.S newlib-2.4.0_patched/newlib/libm/machine/i386/f_ldexpf.S
--- newlib-2.4.0/newlib/libm/machine/i386/f_ldexpf.S 2002-12-20 22:31:20.000000000 +0100
+++ newlib-2.4.0_patched/newlib/libm/machine/i386/f_ldexpf.S 2015-11-01 16:58:23.646121581 +0100
@@ -27,7 +27,7 @@
SYM (_f_ldexpf):
pushl ebp
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export build_dir=$HOME/cross-dev
# Multitask-parameter to make
export num_jobs=-j$((`lscpu -p | tail -1 | cut -d',' -f1` + 1 ))

export newlib_version=2.2.0-1
export newlib_version=2.4.0

export INCLUDEOS_SRC=`pwd`
export newlib_inc=$TEMP_INSTALL_DIR/i686-elf/include
Expand All @@ -22,7 +22,7 @@ export llvm_build=build_llvm
export clang_version=3.8

export gcc_version=6.1.0
export binutils_version=2.25
export binutils_version=2.26

# Options to skip steps
[ ! -v do_binutils ] && do_binutils=1
Expand Down
6 changes: 5 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ STACK_PROTECTOR_VALUE=$(shell awk 'BEGIN{print int(rand()*65536)}')
# the compiler seems to be really dumb in this regard, creating a misaligned stack left and right
CAPABS_COMMON = -mstackrealign -fstack-protector-all -fno-omit-frame-pointer -msse3 -D_STACK_GUARD_VALUE_=$(STACK_PROTECTOR_VALUE)

CAPABS = $(CAPABS_COMMON) -O2 -DNO_DEBUG=1 -DOS_TERMINATE_ON_CONTRACT_VIOLATION
# Various global defines
# * NO_DEBUG Disables output from the debug macro
# * OS_TERMINATE_ON_CONTRACT_VIOLATION provides classic assert-like output from Expects / Ensures
# * _GNU_SOURCE enables POSIX-extensions in newlib, such as strnlen. ("everything newlib has", ref. cdefs.h)
CAPABS = $(CAPABS_COMMON) -O2 -DNO_DEBUG=1 -DOS_TERMINATE_ON_CONTRACT_VIOLATION -D_GNU_SOURCE
WARNS = -Wall -Wextra #-pedantic
DEBUG_OPTS = -ggdb3

Expand Down
2 changes: 1 addition & 1 deletion src/seed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ all: CAPABS = $(CAPABS_COMMON) -O2
debug: CAPABS = $(CAPABS_COMMON) -O0
stripped: CAPABS = $(CAPABS_COMMON) -Oz

CPPOPTS = $(CAPABS) $(WARNS) -c -m32 -std=c++14 $(INCLUDES) -D_LIBCPP_HAS_NO_THREADS=1
CPPOPTS = $(CAPABS) $(WARNS) -c -m32 -std=c++14 $(INCLUDES) -D_LIBCPP_HAS_NO_THREADS=1 -D_GNU_SOURCE
LDOPTS = -nostdlib -melf_i386 -N --script=$(INSTALL)/linker.ld

# Objects
Expand Down