Skip to content

Commit

Permalink
Initial FlexOS release.
Browse files Browse the repository at this point in the history
Signed-off-by: Hugo Lefeuvre <[email protected]>
Signed-off-by: Sebastian Rauch <[email protected]>
Signed-off-by: Stefan Teodorescu <[email protected]>
Signed-off-by: Vlad-Andrei Badoiu <[email protected]>
  • Loading branch information
hlef committed Nov 23, 2021
1 parent fd57791 commit f1b961c
Show file tree
Hide file tree
Showing 131 changed files with 10,567 additions and 616 deletions.
9 changes: 9 additions & 0 deletions Config.uk
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ config CROSS_COMPILE
need to set this unless you want the configured build
directory to select the cross-compiler automatically.


config LLVM_TARGET_ARCH
string "Custom cross-compiler LLVM target (optional)"
help
Same as running 'make LLVM_TARGET_ARCH=target' but stored for
default make runs in this build directory. You don't
need to set this unless you want the configured build
directory to select the cross-compiler automatically.
This is used for LLVM based compilers such as clang or rustc.
#config PARALLEL_JOBS
# int "Number of jobs to run simultaneously (0 for auto)"
# default "0"
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ CXXINCLUDES :=
CXXINCLUDES-y :=
GOCFLAGS :=
GOCFLAGS-y :=
RUSTCFLAGS :=
RUSTCFLAGS-y :=
GOCINCLUDES :=
GOCINCLUDES-y :=
DBGFLAGS :=
Expand Down Expand Up @@ -513,6 +515,7 @@ ifeq ($(sub_make_exec), 1)
ifeq ($(UK_HAVE_DOT_CONFIG),y)
# Hide troublesome environment variables from sub processes
unexport CONFIG_CROSS_COMPILE
unexport CONFIG_LLVM_TARGET_ARCH
unexport CONFIG_COMPILER
#unexport CC
#unexport LD
Expand Down Expand Up @@ -546,6 +549,10 @@ ifneq ("$(origin CROSS_COMPILE)","undefined")
CONFIG_CROSS_COMPILE := $(CROSS_COMPILE:"%"=%)
endif

ifneq ("$(origin LLVM_TARGET_ARCH)","undefined")
CONFIG_LLVM_TARGET_ARCH := $(LLVM_TARGET_ARCH:"%"=%)
endif

ifneq ("$(origin COMPILER)","undefined")
CONFIG_COMPILER := $(COMPILER:"%"=%)
else
Expand All @@ -561,6 +568,13 @@ CC := $(CONFIG_CROSS_COMPILE)$(CONFIG_COMPILER)
CPP := $(CC)
CXX := $(CPP)
GOC := $(CONFIG_CROSS_COMPILE)gccgo-7
# We use rustc because the gcc frontend is experimental and missing features such
# as borrowing checking
ifneq ("$(origin LLVM_TARGET_ARCH)","undefined")
RUSTC := rustc --target=$(CONFIG_LLVM_TARGET_ARCH)
else
RUSTC := rustc
endif
AS := $(CC)
AR := $(CONFIG_CROSS_COMPILE)gcc-ar
NM := $(CONFIG_CROSS_COMPILE)gcc-nm
Expand Down
30 changes: 30 additions & 0 deletions Makefile.uk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
COMPFLAGS += -nostdlib
COMPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
COMPFLAGS += -fno-omit-frame-pointer
# treat "attribute directive ignored" as error for FlexOS, this is indicative
# that a rewriting pass failed
COMPFLAGS += -Werror=attributes
# because of Coccinelle, a good number of __unused attributes have to be removed
# as a consequence we experience many spurious warnings. Disable them for now
COMPFLAGS += -Wno-unused-variable
COMPFLAGS-$(call have_gcc) += -fno-tree-sra -fno-split-stack -nostdinc

ifneq ($(HAVE_STACKPROTECTOR),y)
Expand All @@ -21,6 +27,30 @@ CINCLUDES += -I$(CONFIG_UK_BASE)/include
CXXINCLUDES += -I$(CONFIG_UK_BASE)/include
GOCINCLUDES += -I$(CONFIG_UK_BASE)/include

RUSTCFLAGS-y += --emit=obj --crate-type=rlib --edition=2018 \
-Cpanic=abort -Cembed-bitcode=n \
-Zbinary_dep_depinfo=y -Zsymbol-mangling-version=v0 \
-Cforce-unwind-tables=n -Ccodegen-units=1 \
-Dunsafe_op_in_unsafe_fn -Drust_2018_idioms


RUSTCFLAGS-$(CONFIG_OPTIMIZE_NONE) += -Copt-level="0"
RUSTCFLAGS-$(CONFIG_OPTIMIZE_SIZE) += -Copt-level="s"
RUSTCFLAGS-$(CONFIG_OPTIMIZE_PERF) += -Copt-level="2"

RUSTCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0) += -Cdebuginfo=0
RUSTCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1) += -Cdebuginfo=1
RUSTCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL2) += -Cdebuginfo=2
# NOTE: There is not level 3 in rustc
RUSTCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL3) += -Cdebuginfo=2

# NOTE: rustc supports LTO only with clang
ifeq ($(call have_clang),y)
RUSTCFLAGS-$(CONFIG_OPTIMIZE_LTO) += -Clinker-plugin-lto
else
RUSTCFLAGS-y += -Cembed-bitcode=n -Clto=n
endif

LIBLDFLAGS += -nostdlib -Wl,-r -Wl,-d -Wl,--build-id=none -no-pie
LIBLDFLAGS-$(call have_gcc) += -nostdinc

Expand Down
Loading

0 comments on commit f1b961c

Please sign in to comment.