WiP Move toolchain settings to conditional includes

This commit is contained in:
Ehmry - 2019-12-31 09:39:32 +01:00
parent 0ea06cc2a1
commit feccc31bed
3 changed files with 105 additions and 43 deletions

View File

@ -1,26 +1,40 @@
.gitignore
export CC
export CXX
export LD
CC = $CC
CXX = $CXX
LD= $LD
OBJCOPY = $OBJCOPY
OUT_DIR=$(TUP_CWD)/out
DEV_DIR = $(TUP_CWD)/dev
DEV_LIB_DIR = $(DEV_DIR)/lib
ifdef IS_GCC
include tup-genode/gcc.tup
endif
ifdef IS_LLVM
include tup-genode/llvm.tup
endif
ifeq ($(TOOLCHAIN_CONFIGURED),)
error no toolchain configuration is active
endif
ifneq ($(TOOLCHAIN_CONFIGURED),X)
error "multiple toolchain configurations are active "
endif
ifeq (@(TUP_ARCH),i386)
X86 = y
CC_MARCH = -march=i686 -m32
LD_MARCH = -melf_i386
AS_MARCH = -march=i686 --32
endif
ifeq (@(TUP_ARCH),x86_64)
X86 = y
TOOL_CHAIN_PREFIX=genode-x86-
CC_MARCH = -m64 -mcmodel=large
LD_MARCH = -melf_x86_64
endif
ifeq (@(TUP_ARCH),arm_v8)
CC_MARCH = -march=armv8-a
endif
GENODE_DIR = $(TUP_CWD)
@ -50,23 +64,6 @@ GENODE_DIR = $(TUP_CWD)
|> $(DEV_LIB_DIR)/%b \
$(DEV_DIR)/<lib> \
export CC
export CXX
export LD
CC = $CC
CXX = $CXX
LD= $LD
OBJCOPY = $OBJCOPY
ifdef CXXFLAGS
CXXFLAGS = @(CXXFLAGS)
endif
CXXFLAGS += -Wno-undefined-bool-conversion -Wno-unknown-attributes -Wsystem-headers -Werror -Wno-uninitialized -Wno-mismatched-tags
LIBGCC = `$(CC) $(CC_MARCH) -print-libgcc-file-name`
export PKG_CONFIG_PATH
PKG_CONFIG_DIR = $(DEV_DIR)/lib/pkgconfig
PKG_CONFIG = PKG_CONFIG_PATH=$(PKG_CONFIG_DIR):$PKG_CONFIG_PATH pkg-config
@ -80,27 +77,11 @@ else
OLEVEL = -O2
endif
!ir = | $(DEV_DIR)/<pkg-config> |> clang $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS)` $(CPPFLAGS) -S -emit-llvm %f |> %B.ll
!asm = |> ^ CC %b^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -D__ASSEMBLY__ $(CPPFLAGS) -c %f -o %o |> %B.o
!cc = | $(DEV_DIR)/<pkg-config> |> ^o CC %f^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS) $(LIBS_CFLAGS)` -c -fPIC %f -o %o |> %B.o
!cxx = | $(DEV_DIR)/<pkg-config> |> ^o CXX %b^ @(CC_WRAPPER) $(CXX) $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS)` -c -fPIC %f -o %o |> %B.o
!ld = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LDFLAGS) `$(PKG_CONFIG) --libs $(LIBS)` --whole-archive --start-group %f --no-whole-archive --end-group -o %o |>
export STRIP
!strip = |> $STRIP -o %o %f |>
!ln = |> ln -s %f %o |>
!incbin = |> ^ incbin %f^ \
export SYM=_binary_`echo %f | sed 's/\./_/g'`; \
echo ".global ${SYM}_start, ${SYM}_end; .data; .align 4; ${SYM}_start:; .incbin \"%f\"; ${SYM}_end:" \
| llvm-mc -filetype=obj - > %o \
|> binary_%b.o
export AR
!ar = |> $AR -rcs %o %f |> %d.a

41
tup-genode/gcc.tup Normal file
View File

@ -0,0 +1,41 @@
TOOLCHAIN_CONFIGURED=$(TOOLCHAIN_CONFIGURED)X
ifeq (@(TUP_ARCH),i386)
CC_MARCH = -march=i686 -m32
LD_MARCH = -melf_i386
AS_MARCH = -march=i686 --32
endif
ifeq (@(TUP_ARCH),x86_64)
CC_MARCH = -m64 -mcmodel=large
LD_MARCH = -melf_x86_64
endif
ifeq (@(TUP_ARCH),arm_v8)
CC_MARCH = -march=armv8-a
endif
ifdef CXXFLAGS
CXXFLAGS = @(CXXFLAGS)
endif
CXXFLAGS += -Wno-undefined-bool-conversion -Wno-unknown-attributes -Wsystem-headers -Werror -Wno-uninitialized -Wno-mismatched-tags
LIBGCC = `$(CC) $(CC_MARCH) -print-libgcc-file-name`
!ir = | $(DEV_DIR)/<pkg-config> |> clang $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS)` $(CPPFLAGS) -S -emit-llvm %f |> %B.ll
!asm = |> ^ CC %b^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -D__ASSEMBLY__ $(CPPFLAGS) -c %f -o %o |> %B.o
!cc = | $(DEV_DIR)/<pkg-config> |> ^o CC %f^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS) $(LIBS_CFLAGS)` -c -fPIC %f -o %o |> %B.o
!cxx = | $(DEV_DIR)/<pkg-config> |> ^o CXX %b^ @(CC_WRAPPER) $(CXX) $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS)` -c -fPIC %f -o %o |> %B.o
!ld = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LDFLAGS) `$(PKG_CONFIG) --libs $(LIBS)` --whole-archive --start-group %f --no-whole-archive --end-group -o %o |>
!incbin = |> ^ incbin %f^ \
export SYM=_binary_`echo %f | sed 's/\./_/g'`; \
echo ".global ${SYM}_start, ${SYM}_end; .data; .align 4; ${SYM}_start:; .incbin \"%f\"; ${SYM}_end:" \
| llvm-mc -filetype=obj - > %o \
|> binary_%b.o

40
tup-genode/llvm.tup Normal file
View File

@ -0,0 +1,40 @@
TOOLCHAIN_CONFIGURED=$(TOOLCHAIN_CONFIGURED)X
ifeq (@(TUP_ARCH),i386)
CC_MARCH = -march=i686 -m32
LD_MARCH = -melf_i386
AS_MARCH = -march=i686 --32
endif
ifeq (@(TUP_ARCH),x86_64)
CC_MARCH = -m64 -mcmodel=large
LD_MARCH = -melf_x86_64
endif
ifeq (@(TUP_ARCH),arm_v8)
CC_MARCH = -march=armv8-a
endif
ifdef CXXFLAGS
CXXFLAGS = @(CXXFLAGS)
endif
CXXFLAGS += -Wno-undefined-bool-conversion -Wno-unknown-attributes -Wsystem-headers -Werror -Wno-uninitialized -Wno-mismatched-tags
LIBGCC = `$(CC) $(CC_MARCH) -print-libgcc-file-name`
!ir = | $(DEV_DIR)/<pkg-config> |> clang $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) `$(PKG_CONFIG) --cflags $(LIBS)` $(CPPFLAGS) -S -emit-llvm %f |> %B.ll
!asm = |> ^ CC %b^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) -D__ASSEMBLY__ $(CPPFLAGS) -c %f -o %o |> %B.o
!cc = | $(DEV_DIR)/<pkg-config> |> ^o CC %f^ @(CC_WRAPPER) $(CC) $(OLEVEL) $(CFLAGS) $(CFLAGS_%e) $(CFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS) $(LIBS_CFLAGS)` -c -fPIC %f -o %o |> %B.o
!cxx = | $(DEV_DIR)/<pkg-config> |> ^o CXX %b^ @(CC_WRAPPER) $(CXX) $(OLEVEL) $(CXXFLAGS) $(CXXFLAGS_%e) $(CXXFLAGS_%f) $(CPPFLAGS) `$(PKG_CONFIG) --cflags $(LIBS)` -c -fPIC %f -o %o |> %B.o
!ld = | $(DEV_DIR)/<lib> $(DEV_DIR)/<pkg-config> |> ^o LD %o^ $(LD) $(LDFLAGS) `$(PKG_CONFIG) --libs $(LIBS)` --whole-archive --start-group %f --no-whole-archive --end-group -o %o |>
!incbin = |> ^ incbin %f^ \
export SYM=_binary_`echo %f | sed 's/\./_/g'`; \
echo ".global ${SYM}_start, ${SYM}_end; .data; .align 4; ${SYM}_start:; .incbin \"%f\"; ${SYM}_end:" \
| llvm-mc -filetype=obj - > %o \
|> binary_%b.o