From 21ab90dcbd0a4513248509c5839c5e3f255b13b7 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 18 Aug 2015 22:00:38 +0200 Subject: [PATCH] add C++ support --- hermit/Makefile | 2 ++ hermit/usr/Makefile | 7 +++---- hermit/usr/examples/Makefile | 15 ++++++++++++-- hermit/usr/examples/hello2.cpp | 38 ++++++++++++++++++++++++++++++++++ hermit/usr/gcc | 2 +- hermit/usr/newlib | 2 +- hermit/usr/pte | 2 +- 7 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 hermit/usr/examples/hello2.cpp diff --git a/hermit/Makefile b/hermit/Makefile index fa224a95d..99dba7396 100644 --- a/hermit/Makefile +++ b/hermit/Makefile @@ -55,6 +55,7 @@ KEEP_DEBUG = --only-keep-debug OUTPUT_FORMAT = -O elf32-i386 CFLAGS_FOR_NEWLIB = #-O3 -mavx2 -mfma -mtune=intel #$(STACKPROT) +CXXFLAGS_FOR_NEWLIB = LDFLAGS_FOR_NEWLIB = NASMFLAGS_FOR_NEWLIB = -felf64 CFLAGS_FOR_TOOLS = -O2 -Wall @@ -75,6 +76,7 @@ toolchain: $Q$(MAKE) ARCH=$(ARCH) \ LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_NEWLIB)" \ CFLAGS_FOR_TARGET="$(CFLAGS_FOR_NEWLIB)" \ + CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_NEWLIB)" \ NASMFLAGS="$(NASMFLAGS_FOR_NEWLIB)" \ CC_FOR_TARGET=$(CC_FOR_TARGET) \ CXX_FOR_TARGET=$(CXX_FOR_TARGET) \ diff --git a/hermit/usr/Makefile b/hermit/usr/Makefile index 3729f73c7..72f13b7e7 100644 --- a/hermit/usr/Makefile +++ b/hermit/usr/Makefile @@ -22,8 +22,8 @@ default: demo: @echo Build demo applications - $Q$(MAKE) CC_FOR_TARGET=$(CC_FOR_TARGET) CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) -C examples depend - $Q$(MAKE) CC_FOR_TARGET=$(CC_FOR_TARGET) CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) -C examples + $Q$(MAKE) CC_FOR_TARGET=$(CC_FOR_TARGET) CXX_FOR_TARGET=$(CXX_FOR_TARGET) CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) -C examples depend + $Q$(MAKE) CC_FOR_TARGET=$(CC_FOR_TARGET) CXX_FOR_TARGET=$(CXX_FOR_TARGET) CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)" OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET) -C examples $(ARCH): $Q$(MKDIR) $(TMP) @@ -57,12 +57,11 @@ libs: $(TMP)/gcc: @echo Build final gcc $Q$(MKDIR) $(TMP)/gcc - $Q$(CD) $(TMP)/gcc; $(TOPDIR)/gcc/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) --without-headers --with-newlib --enable-languages=c --disable-nls --disable-shared --disable-libssp --enable-threads=posix --enable-tls && $(MAKE) $(NJOBS) && $(MAKE) install + $Q$(CD) $(TMP)/gcc; $(TOPDIR)/gcc/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) --without-headers --with-newlib --enable-languages=c,c++ --disable-nls --disable-shared --disable-libssp --enable-threads=posix --enable-tls && $(MAKE) $(NJOBS) && $(MAKE) install clean: @echo Cleaning toolchain $Q$(MAKE) -C examples clean - $Q$(RM) $(TMP) veryclean: @echo Propper cleaning of the toolchain diff --git a/hermit/usr/examples/Makefile b/hermit/usr/examples/Makefile index 4349d2ce8..f499248c3 100644 --- a/hermit/usr/examples/Makefile +++ b/hermit/usr/examples/Makefile @@ -33,6 +33,10 @@ endif @echo [CC] $@ $Q$(CC_FOR_TARGET) -c $(CFLAGS_FOR_TARGET) -o $@ $< +%.o: %.cpp + @echo [CXX] $@ + $Q$(CXX_FOR_TARGET) -c $(CXXFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< + default: all all: hello jacobi stream thr_hello @@ -48,6 +52,13 @@ stream: stream.o $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ $Qchmod a-x $@.sym +hello2: hello2.o + @echo [LD] $@ + $Q$(CXX_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CXXFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< + $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym + $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qchmod a-x $@.sym + hello: hello.o @echo [LD] $@ $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< @@ -75,11 +86,11 @@ thr_hello: thr_hello.o clean: @echo Cleaning examples - $Q$(RM) hello jacobi stream thr_hello *.sym *.o *~ + $Q$(RM) hello hello2 jacobi stream thr_hello *.sym *.o *~ veryclean: @echo Propper cleaning examples - $Q$(RM) hello jacobi stream thr_hello *.sym *.o *~ + $Q$(RM) hello hello2 jacobi stream thr_hello *.sym *.o *~ depend: $Q$(CC_FOR_TARGET) -MM $(CFLAGS_FOR_TARGET) *.c > Makefile.dep diff --git a/hermit/usr/examples/hello2.cpp b/hermit/usr/examples/hello2.cpp new file mode 100644 index 000000000..040db1079 --- /dev/null +++ b/hermit/usr/examples/hello2.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +using namespace std; + +int main(int argc, char** argv) +{ + cout << "Hello World from g++!!!" << endl; + + return errno; +} diff --git a/hermit/usr/gcc b/hermit/usr/gcc index 4adf1cf49..ca0a5fa4c 160000 --- a/hermit/usr/gcc +++ b/hermit/usr/gcc @@ -1 +1 @@ -Subproject commit 4adf1cf49828fa4d96d2f0acbe2ddd6c43742216 +Subproject commit ca0a5fa4c716ab7b079fbf7b1f6ade09d9d2b8e8 diff --git a/hermit/usr/newlib b/hermit/usr/newlib index c207b96be..50226da60 160000 --- a/hermit/usr/newlib +++ b/hermit/usr/newlib @@ -1 +1 @@ -Subproject commit c207b96beea140752ef5918669f480ac9388806e +Subproject commit 50226da60cf14ae5f67722473b17558a4e46f8b2 diff --git a/hermit/usr/pte b/hermit/usr/pte index 9b6f4812d..2aff438d7 160000 --- a/hermit/usr/pte +++ b/hermit/usr/pte @@ -1 +1 @@ -Subproject commit 9b6f4812d19be3c203b2ce743ed5906fc70d3d0e +Subproject commit 2aff438d76d11c2d8e9efc274d639f8e0fef455b