1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

add C++ support

This commit is contained in:
Stefan Lankes 2015-08-18 22:00:38 +02:00
parent 8cccb0cee4
commit 21ab90dcbd
7 changed files with 59 additions and 9 deletions

View file

@ -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) \

View file

@ -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

View file

@ -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

View file

@ -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 <iostream>
#include <errno.h>
using namespace std;
int main(int argc, char** argv)
{
cout << "Hello World from g++!!!" << endl;
return errno;
}

@ -1 +1 @@
Subproject commit 4adf1cf49828fa4d96d2f0acbe2ddd6c43742216
Subproject commit ca0a5fa4c716ab7b079fbf7b1f6ade09d9d2b8e8

@ -1 +1 @@
Subproject commit c207b96beea140752ef5918669f480ac9388806e
Subproject commit 50226da60cf14ae5f67722473b17558a4e46f8b2

@ -1 +1 @@
Subproject commit 9b6f4812d19be3c203b2ce743ed5906fc70d3d0e
Subproject commit 2aff438d76d11c2d8e9efc274d639f8e0fef455b