diff --git a/api/sys/features.h b/api/sys/features.h index 8123fc2450..14d0bec648 100644 --- a/api/sys/features.h +++ b/api/sys/features.h @@ -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. @@ -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 #endif diff --git a/api/sys/math.h b/api/sys/math.h index 1117eae483..fca5d9b13f 100644 --- a/api/sys/math.h +++ b/api/sys/math.h @@ -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. @@ -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); diff --git a/api/sys/time.h b/api/sys/time.h index fc24390a5a..ea23f605ad 100644 --- a/api/sys/time.h +++ b/api/sys/time.h @@ -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. @@ -18,13 +18,12 @@ #include "features.h" #include_next #include_next + #ifndef SYS_TIME_H #define SYS_TIME_H - // We might possibly need additions here. #define CLOCK_MONOTONIC 4 #endif - diff --git a/api/sys/wchar.h b/api/sys/wchar.h index 24d41af9ff..0e3b142168 100644 --- a/api/sys/wchar.h +++ b/api/sys/wchar.h @@ -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. @@ -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); } diff --git a/etc/build_llvm32.sh b/etc/build_llvm32.sh index e4f81b3c9a..6433782e53 100755 --- a/etc/build_llvm32.sh +++ b/etc/build_llvm32.sh @@ -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 @@ -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 @@ -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" " @@ -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 # diff --git a/etc/newlib_clang.patch b/etc/newlib_clang.patch index 2d6f34822b..c9f9327984 100644 --- a/etc/newlib_clang.patch +++ b/etc/newlib_clang.patch @@ -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 @@ -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 diff --git a/install.sh b/install.sh index 5b8b12ee6b..9aea62f534 100755 --- a/install.sh +++ b/install.sh @@ -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 @@ -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 diff --git a/src/Makefile b/src/Makefile index dc9eee7b28..fd93c32991 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 diff --git a/src/seed/Makefile b/src/seed/Makefile index f8e346bd34..d23786918a 100644 --- a/src/seed/Makefile +++ b/src/seed/Makefile @@ -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