WiP! patch genodeSources to use clang
This commit is contained in:
parent
527c449bc6
commit
21e518049c
|
@ -35,7 +35,11 @@ let
|
|||
version = builtins.substring 0 7 upstreamSources.rev;
|
||||
src = upstreamSources;
|
||||
nativeBuildInputs = [ expect gnumake tcl ];
|
||||
patches = [ ./patches/binary-labels.patch ./patches/label-fail.patch ];
|
||||
patches = [
|
||||
./patches/binary-labels.patch
|
||||
./patches/label-fail.patch
|
||||
./patches/clang.patch
|
||||
];
|
||||
configurePhase = ''
|
||||
patchShebangs ./tool
|
||||
substituteInPlace repos/base/etc/tools.conf \
|
||||
|
|
|
@ -0,0 +1,814 @@
|
|||
From 0f36d2b4ffad5ff3ff37f448de227abab610126f Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Fri, 28 Aug 2020 23:59:38 +0200
|
||||
Subject: [PATCH 01/14] Add support for building Genode with clang
|
||||
|
||||
TODO: description
|
||||
---
|
||||
repos/base/etc/tools.conf | 30 +++++++++++++++++----
|
||||
repos/base/mk/global.mk | 56 ++++++++++++++++++++++++++++++++++++---
|
||||
tool/builddir/build.mk | 7 +++++
|
||||
tool/run/depot.inc | 3 +++
|
||||
tool/run/run | 26 ++++++++++++------
|
||||
5 files changed, 105 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/repos/base/etc/tools.conf b/repos/base/etc/tools.conf
|
||||
index f0182612f7..6c1e3fb6b9 100644
|
||||
--- a/repos/base/etc/tools.conf
|
||||
+++ b/repos/base/etc/tools.conf
|
||||
@@ -1,3 +1,13 @@
|
||||
+#
|
||||
+# Default location of Genode GCC toolchain.
|
||||
+#
|
||||
+GENODE_GCC_TOOLCHAIN_DIR ?= /usr/local/genode/tool/19.05
|
||||
+
|
||||
+#
|
||||
+# Default location of Genode LLVM toolchain.
|
||||
+#
|
||||
+GENODE_LLVM_TOOLCHAIN_DIR ?= /usr/local/genode/tool/llvm-11.0.0
|
||||
+
|
||||
#
|
||||
# The following options let you define non-default tools to use
|
||||
#
|
||||
@@ -19,21 +29,31 @@
|
||||
# package build tool.
|
||||
#
|
||||
ifeq ($(filter-out $(SPECS),x86_32),)
|
||||
-CROSS_DEV_PREFIX ?= /usr/local/genode/tool/19.05/bin/genode-x86-
|
||||
+CROSS_DEV_PREFIX ?= $(GENODE_GCC_TOOLCHAIN_DIR)/bin/genode-x86-
|
||||
+CLANG_TARGET ?= x86_64-genode
|
||||
endif
|
||||
ifeq ($(filter-out $(SPECS),x86_64),)
|
||||
-CROSS_DEV_PREFIX ?= /usr/local/genode/tool/19.05/bin/genode-x86-
|
||||
+CROSS_DEV_PREFIX ?= $(GENODE_GCC_TOOLCHAIN_DIR)/bin/genode-x86-
|
||||
+CLANG_TARGET ?= x86_64-genode
|
||||
endif
|
||||
ifeq ($(filter-out $(SPECS),arm_64),)
|
||||
-CROSS_DEV_PREFIX ?= /usr/local/genode/tool/19.05/bin/genode-aarch64-
|
||||
+CROSS_DEV_PREFIX ?= $(GENODE_GCC_TOOLCHAIN_DIR)/bin/genode-aarch64-
|
||||
+CLANG_TARGET ?= aarch64-genode
|
||||
endif
|
||||
ifeq ($(filter-out $(SPECS),arm),)
|
||||
-CROSS_DEV_PREFIX ?= /usr/local/genode/tool/19.05/bin/genode-arm-
|
||||
+CROSS_DEV_PREFIX ?= $(GENODE_GCC_TOOLCHAIN_DIR)/bin/genode-arm-
|
||||
+CLANG_TARGET ?= arm-genode-gnueabi
|
||||
endif
|
||||
ifeq ($(filter-out $(SPECS),riscv),)
|
||||
-CROSS_DEV_PREFIX ?= /usr/local/genode/tool/19.05/bin/genode-riscv-
|
||||
+CROSS_DEV_PREFIX ?= $(GENODE_GCC_TOOLCHAIN_DIR)/bin/genode-riscv-
|
||||
+CLANG_TARGET ?= riscv-genode
|
||||
endif
|
||||
|
||||
+#
|
||||
+# Use clang based compiler instead of GCC to build the code.
|
||||
+#
|
||||
+#USE_CLANG = yes
|
||||
+
|
||||
#
|
||||
# We use libsupc++ from g++ version 3 because
|
||||
# this version does not use thread-local storage
|
||||
diff --git a/repos/base/mk/global.mk b/repos/base/mk/global.mk
|
||||
index 808989f248..d1aaf3c5b2 100644
|
||||
--- a/repos/base/mk/global.mk
|
||||
+++ b/repos/base/mk/global.mk
|
||||
@@ -8,26 +8,59 @@
|
||||
-include $(call select_from_repositories,etc/tools.conf)
|
||||
-include $(BUILD_BASE_DIR)/etc/tools.conf
|
||||
|
||||
+#
|
||||
+# Use clang based toolchain to build the code.
|
||||
+#
|
||||
+USE_CLANG ?= no
|
||||
+
|
||||
#
|
||||
# Set undefined CUSTOM_ tools to their default values
|
||||
#
|
||||
+ifeq ($(USE_CLANG),yes)
|
||||
+CUSTOM_CC ?= $(GENODE_LLVM_TOOLCHAIN_DIR)/bin/clang
|
||||
+CUSTOM_CXX ?= $(GENODE_LLVM_TOOLCHAIN_DIR)/bin/clang++
|
||||
+CUSTOM_CPP ?= $(CUSTOM_CC) -E
|
||||
+CUSTOM_CXX_LIB ?= $(CROSS_DEV_PREFIX)g++
|
||||
+CUSTOM_HOST_CC ?= $(CUSTOM_CC)
|
||||
+CUSTOM_HOST_CXX ?= $(CUSTOM_CXX)
|
||||
+CUSTOM_AR ?= $(GENODE_LLVM_TOOLCHAIN_DIR)/bin/llvm-ar
|
||||
+CUSTOM_NM ?= $(GENODE_LLVM_TOOLCHAIN_DIR)/bin/llvm-nm
|
||||
+CUSTOM_OBJCOPY ?= $(GENODE_LLVM_TOOLCHAIN_DIR)/bin/llvm-objcopy
|
||||
+CUSTOM_RANLIB ?= $(GENODE_LLVM_TOOLCHAIN_DIR)/bin/llvm-ranlib
|
||||
+CUSTOM_STRIP ?= $(GENODE_LLVM_TOOLCHAIN_DIR)/bin/llvm-strip
|
||||
+else
|
||||
CUSTOM_CC ?= $(CROSS_DEV_PREFIX)gcc
|
||||
CUSTOM_CXX ?= $(CROSS_DEV_PREFIX)g++
|
||||
CUSTOM_CPP ?= $(CROSS_DEV_PREFIX)cpp
|
||||
CUSTOM_CXX_LIB ?= $(CUSTOM_CXX)
|
||||
-CUSTOM_LD ?= $(CROSS_DEV_PREFIX)ld
|
||||
-CUSTOM_AS ?= $(CROSS_DEV_PREFIX)as
|
||||
+CUSTOM_HOST_CC ?= $(HOST_DEV_PREFIX)gcc
|
||||
+CUSTOM_HOST_CXX ?= $(HOST_DEV_PREFIX)g++
|
||||
CUSTOM_AR ?= $(CROSS_DEV_PREFIX)ar
|
||||
CUSTOM_NM ?= $(CROSS_DEV_PREFIX)nm
|
||||
CUSTOM_OBJCOPY ?= $(CROSS_DEV_PREFIX)objcopy
|
||||
CUSTOM_RANLIB ?= $(CROSS_DEV_PREFIX)ranlib
|
||||
CUSTOM_STRIP ?= $(CROSS_DEV_PREFIX)strip
|
||||
+endif
|
||||
+
|
||||
+CUSTOM_LD ?= $(CROSS_DEV_PREFIX)ld
|
||||
+CUSTOM_AS ?= $(CROSS_DEV_PREFIX)as
|
||||
CUSTOM_GNATBIND ?= $(CROSS_DEV_PREFIX)gnatbind
|
||||
-CUSTOM_HOST_CC ?= $(HOST_DEV_PREFIX)gcc
|
||||
-CUSTOM_HOST_CXX ?= $(HOST_DEV_PREFIX)g++
|
||||
CUSTOM_ADA_CC ?= $(CUSTOM_CC)
|
||||
CUSTOM_ALI2DEP ?= $(CROSS_DEV_PREFIX)ali2dep
|
||||
|
||||
+ifeq ($(USE_CLANG),yes)
|
||||
+# Clang is a multi-target compiler when one binary can cross-compile
|
||||
+# code for mutliple targets. To do this however we need to tell it
|
||||
+# which target platform its supposed to generate code for.
|
||||
+CLANG_FLAGS := --target=$(CLANG_TARGET)
|
||||
+# Genode clang support still relies on GCC to provide libgcc and C++
|
||||
+# runtime. As such we need to instruct clang where to look for
|
||||
+# appropriate, genode specific gcc toolchain.
|
||||
+CLANG_FLAGS += --gcc-toolchain=$(GENODE_GCC_TOOLCHAIN_DIR)
|
||||
+CUSTOM_CC += ${CLANG_FLAGS}
|
||||
+CUSTOM_CXX += ${CLANG_FLAGS}
|
||||
+endif
|
||||
+
|
||||
#
|
||||
# GNU utilities
|
||||
#
|
||||
@@ -135,6 +168,21 @@ endif
|
||||
CC_OLEVEL ?= -O2
|
||||
CC_WARN ?= -Wall
|
||||
|
||||
+ifeq ($(USE_CLANG),yes)
|
||||
+CC_OPT += -fno-builtin-memset
|
||||
+CC_WARN += -Wno-mismatched-tags
|
||||
+CC_WARN += -Wno-undefined-bool-conversion
|
||||
+CC_WARN += -Wno-uninitialized
|
||||
+CC_WARN += -Wno-deprecated-copy
|
||||
+CC_WARN += -Wno-asm-operand-widths
|
||||
+CC_WARN += -Wno-null-dereference
|
||||
+CC_WARN += -Wno-overloaded-virtual
|
||||
+# Don't warn about unrecognized, GCC specific pragmas.
|
||||
+CC_WARN += -Wno-unknown-pragmas
|
||||
+# Triggered by code in x86_64 base-hw, would be nice to have on arm.
|
||||
+CC_WARN += -Wno-address-of-packed-member
|
||||
+endif
|
||||
+
|
||||
#
|
||||
# XXX fix the warnings and remove this option
|
||||
#
|
||||
diff --git a/tool/builddir/build.mk b/tool/builddir/build.mk
|
||||
index 85487aebf7..00f5b4eb76 100644
|
||||
--- a/tool/builddir/build.mk
|
||||
+++ b/tool/builddir/build.mk
|
||||
@@ -137,6 +137,7 @@ endif
|
||||
#
|
||||
# Empty DST_DIRS is interpreted as a tool-chain agnostic target, e.g., clean.
|
||||
#
|
||||
+ifneq ($(USE_CLANG),yes)
|
||||
ifneq ($(DST_DIRS),)
|
||||
REQUIRED_GCC_VERSION ?= 8.3.0
|
||||
GCC_VERSION := $(filter $(REQUIRED_GCC_VERSION) ,$(shell $(CUSTOM_CXX) --version))
|
||||
@@ -144,6 +145,7 @@ ifneq ($(GCC_VERSION), $(REQUIRED_GCC_VERSION))
|
||||
$(error "$(CUSTOM_CXX) version $(REQUIRED_GCC_VERSION) is required")
|
||||
endif
|
||||
endif
|
||||
+endif
|
||||
|
||||
ifneq ($(STATIC_ANALYZE),)
|
||||
check_tool = $(if $(shell which $(1)),,$(error Need to have '$(1)' installed.))
|
||||
@@ -336,6 +338,11 @@ run/%: $(call select_from_repositories,run/%.run) $(RUN_ENV)
|
||||
--board "$(BOARD)" \
|
||||
--repositories "$(REPOSITORIES)" \
|
||||
--cross-dev-prefix "$(CROSS_DEV_PREFIX)" \
|
||||
+ --cross-cc "$(CUSTOM_CC)" \
|
||||
+ --cross-cxx "$(CUSTOM_CXX)" \
|
||||
+ --llvm-tc-dir "$(GENODE_LLVM_TOOLCHAIN_DIR)" \
|
||||
+ --gcc-tc-dir "$(GENODE_GCC_TOOLCHAIN_DIR)" \
|
||||
+ --use-clang "$(USE_CLANG)" \
|
||||
--qemu-args "$(QEMU_OPT)" \
|
||||
--make "$(MAKE)" \
|
||||
$(RUN_OPT) \
|
||||
diff --git a/tool/run/depot.inc b/tool/run/depot.inc
|
||||
index 0a70438fa8..505eacb9eb 100644
|
||||
--- a/tool/run/depot.inc
|
||||
+++ b/tool/run/depot.inc
|
||||
@@ -208,6 +208,9 @@ proc _depot_auto_update { archives } {
|
||||
set cmd "[genode_dir]/tool/depot/create $archives_to_create "
|
||||
append cmd "CROSS_DEV_PREFIX=[cross_dev_prefix] "
|
||||
append cmd "DEPOT_DIR=[depot_dir] "
|
||||
+ append cmd "USE_CLANG=[use_clang] "
|
||||
+ append cmd "GENODE_GCC_TOOLCHAIN_DIR=[gcc_tc_dir] "
|
||||
+ append cmd "GENODE_LLVM_TOOLCHAIN_DIR=[llvm_tc_dir] "
|
||||
append cmd "UPDATE_VERSIONS=1 FORCE=1 REBUILD= "
|
||||
|
||||
set make_j_arg ""
|
||||
diff --git a/tool/run/run b/tool/run/run
|
||||
index d1b6149646..d8241ec522 100755
|
||||
--- a/tool/run/run
|
||||
+++ b/tool/run/run
|
||||
@@ -508,9 +508,14 @@ proc get_cmd_arg_first { arg_name default_value } {
|
||||
set run_name [get_cmd_arg --name "noname"]
|
||||
set genode_dir [get_cmd_arg --genode-dir ""]
|
||||
set cross_dev_prefix [get_cmd_arg --cross-dev-prefix ""]
|
||||
+set cross_cxx [get_cmd_arg --cross-cxx ""]
|
||||
+set cross_cc [get_cmd_arg --cross-cc ""]
|
||||
set specs [get_cmd_arg --specs ""]
|
||||
set board_var [get_cmd_arg --board ""]
|
||||
set repositories [get_cmd_arg --repositories ""]
|
||||
+set use_clang [get_cmd_arg --use-clang ""]
|
||||
+set llvm_tc_dir [get_cmd_arg --llvm-tc-dir ""]
|
||||
+set gcc_tc_dir [get_cmd_arg --gcc-tc-dir ""]
|
||||
|
||||
|
||||
# accessor functions for command-line arguments
|
||||
@@ -518,6 +523,11 @@ proc run_name { } { global run_name; return $run_name }
|
||||
proc run_dir { } { global run_name; return var/run/$run_name }
|
||||
proc genode_dir { } { global genode_dir; return $genode_dir }
|
||||
proc cross_dev_prefix { } { global cross_dev_prefix; return $cross_dev_prefix }
|
||||
+proc cross_cxx { } { global cross_cxx; return [split $cross_cxx " "] }
|
||||
+proc cross_cc { } { global cross_cc; return [split $cross_cc " " ] }
|
||||
+proc use_clang { } { global use_clang; return $use_clang }
|
||||
+proc llvm_tc_dir { } { global llvm_tc_dir; return $llvm_tc_dir }
|
||||
+proc gcc_tc_dir { } { global gcc_tc_dir; return $gcc_tc_dir }
|
||||
|
||||
##
|
||||
# Return true if spec value is set for the build
|
||||
@@ -933,18 +943,18 @@ proc build_core {lib modules target link_address} {
|
||||
if {[have_spec "x86_32"]} { set arch -m32 }
|
||||
|
||||
# determine the libgcc
|
||||
- set libgcc [exec [cross_dev_prefix]gcc -print-libgcc-file-name {*}$arch]
|
||||
+ set libgcc [exec {*}[cross_cc] -print-libgcc-file-name {*}$arch]
|
||||
|
||||
# compile the boot modules into one object file
|
||||
- exec [cross_dev_prefix]gcc {*}$arch -c -x assembler -o [run_dir].boot_modules.o - << $asm_src
|
||||
+ exec {*}[cross_cc] {*}$arch -c -x assembler -o [run_dir].boot_modules.o - << $asm_src
|
||||
|
||||
# link final image
|
||||
- exec [cross_dev_prefix]g++ {*}$arch -nostdlib {*}[core_ld_opts] \
|
||||
- -Wl,-z -Wl,max-page-size=0x1000 \
|
||||
- -Wl,-Ttext=$link_address -Wl,-gc-sections \
|
||||
- -Wl,-nostdlib -Wl,--whole-archive -Wl,--start-group \
|
||||
- $lib [run_dir].boot_modules.o -Wl,--no-whole-archive \
|
||||
- -Wl,--end-group $libgcc -o $target
|
||||
+ exec {*}[cross_cxx] {*}$arch -nostdlib {*}[core_ld_opts] \
|
||||
+ -Wl,-z -Wl,max-page-size=0x1000 \
|
||||
+ -Wl,-Ttext=$link_address -Wl,-gc-sections \
|
||||
+ -Wl,-nostdlib -Wl,--whole-archive -Wl,--start-group \
|
||||
+ $lib [run_dir].boot_modules.o -Wl,--no-whole-archive \
|
||||
+ -Wl,--end-group $libgcc -o $target
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From 02cb3df7b817f47c744081e6de5a363f2ca735fc Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Fri, 28 Aug 2020 00:09:26 +0200
|
||||
Subject: [PATCH 02/14] Reduce the number of flags passed to compiler invoked
|
||||
as assembler.
|
||||
|
||||
Right now majority of flags passed to cc when invoked to generate
|
||||
assembly code are not actuall valid in such mode. GCC does not care about
|
||||
this, but clang does. It prints extra warnigns when specified flags are not
|
||||
actually being used or valid in a specific compilation mode. Refoactor this
|
||||
code to make both GCC and clang happy.
|
||||
---
|
||||
repos/base-hw/lib/mk/bootstrap-hw.inc | 3 ++-
|
||||
repos/base-hw/lib/mk/core-hw.inc | 3 ++-
|
||||
repos/base/mk/generic.mk | 2 +-
|
||||
3 files changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/repos/base-hw/lib/mk/bootstrap-hw.inc b/repos/base-hw/lib/mk/bootstrap-hw.inc
|
||||
index 3f7cecb45b..2dfd49af68 100644
|
||||
--- a/repos/base-hw/lib/mk/bootstrap-hw.inc
|
||||
+++ b/repos/base-hw/lib/mk/bootstrap-hw.inc
|
||||
@@ -31,7 +31,8 @@ INC_DIR += $(BASE_DIR)/src/core/include # for boot_modules.h only
|
||||
|
||||
# configure multiprocessor mode
|
||||
NR_OF_CPUS ?= 1
|
||||
-CC_OPT += -Wa,--defsym -Wa,NR_OF_CPUS=$(NR_OF_CPUS) -DNR_OF_CPUS=$(NR_OF_CPUS)
|
||||
+CC_AS_OPT += -Wa,--defsym,NR_OF_CPUS=$(NR_OF_CPUS)
|
||||
+CC_OPT += -DNR_OF_CPUS=$(NR_OF_CPUS)
|
||||
|
||||
vpath base/% $(BASE_HW_DIR)/src
|
||||
vpath bootstrap/% $(BASE_HW_DIR)/src
|
||||
diff --git a/repos/base-hw/lib/mk/core-hw.inc b/repos/base-hw/lib/mk/core-hw.inc
|
||||
index 4e224e8cee..7c093abe93 100644
|
||||
--- a/repos/base-hw/lib/mk/core-hw.inc
|
||||
+++ b/repos/base-hw/lib/mk/core-hw.inc
|
||||
@@ -73,7 +73,8 @@ include $(BASE_DIR)/src/core/version.inc
|
||||
|
||||
# configure multiprocessor mode
|
||||
NR_OF_CPUS ?= 1
|
||||
-CC_OPT += -Wa,--defsym -Wa,NR_OF_CPUS=$(NR_OF_CPUS) -DNR_OF_CPUS=$(NR_OF_CPUS)
|
||||
+CC_AS_OPT += -Wa,--defsym,NR_OF_CPUS=$(NR_OF_CPUS)
|
||||
+CC_OPT += -DNR_OF_CPUS=$(NR_OF_CPUS)
|
||||
|
||||
# declare source locations
|
||||
vpath % $(BASE_HW_DIR)/src/core
|
||||
diff --git a/repos/base/mk/generic.mk b/repos/base/mk/generic.mk
|
||||
index 0531c08d58..03b0f4280f 100644
|
||||
--- a/repos/base/mk/generic.mk
|
||||
+++ b/repos/base/mk/generic.mk
|
||||
@@ -66,7 +66,7 @@ endif
|
||||
|
||||
%.o: %.s
|
||||
$(MSG_ASSEM)$@
|
||||
- $(VERBOSE)$(CC) $(CC_DEF) $(CC_C_OPT) $(INCLUDES) -c $< -o $@
|
||||
+ $(VERBOSE)$(CC) $(CC_MARCH) $(CC_AS_OPT) -c $< -o $@
|
||||
|
||||
#
|
||||
# Compiling Ada source codes
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From 312fc837d9c23ca40cd0f1c093186612fe36fee3 Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Wed, 28 Oct 2020 23:49:28 +0100
|
||||
Subject: [PATCH 03/14] base: Don't include global.mk from cxx.mk
|
||||
|
||||
According to the comment this is needed to set CUSTOM_CXX_LIB in order
|
||||
to obtain the location libsupc++ and libgcc_eh. It seems however that
|
||||
nowadays CUSTOM_CXX_LIB is defined even without global.mk include.
|
||||
Including it however results in most of the compilation flags being
|
||||
duplicated, resulting in much less readable verbose build logs.
|
||||
---
|
||||
repos/base/lib/mk/cxx.mk | 12 ------------
|
||||
1 file changed, 12 deletions(-)
|
||||
|
||||
diff --git a/repos/base/lib/mk/cxx.mk b/repos/base/lib/mk/cxx.mk
|
||||
index 80faa49f3f..7281e3abfb 100644
|
||||
--- a/repos/base/lib/mk/cxx.mk
|
||||
+++ b/repos/base/lib/mk/cxx.mk
|
||||
@@ -25,18 +25,6 @@ EH_SYMBOLS = _Unwind_Resume _Unwind_Complete _Unwind_DeleteException
|
||||
#
|
||||
EH_SYMBOLS += __aeabi_unwind_cpp_pr0 __aeabi_unwind_cpp_pr1
|
||||
|
||||
-#
|
||||
-# Take the right system libraries
|
||||
-#
|
||||
-# Normally, we never include build-system-internal files from library-
|
||||
-# description files. For building the 'cxx' library, however, we need the
|
||||
-# information about the used 'gcc' for resolving the location of the C++
|
||||
-# support libraries. This definition is performed by 'mk/lib.mk' after
|
||||
-# including this library description file. Hence, we need to manually
|
||||
-# include 'global.mk' here.
|
||||
-#
|
||||
-include $(BASE_DIR)/mk/global.mk
|
||||
-
|
||||
LIBCXX_GCC = $(shell $(CUSTOM_CXX_LIB) $(CC_MARCH) -print-file-name=libsupc++.a) \
|
||||
$(shell $(CUSTOM_CXX_LIB) $(CC_MARCH) -print-file-name=libgcc_eh.a || true)
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From 9a28c26813489cd38ec62c6cda8f7d9b77cffd75 Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Thu, 29 Oct 2020 16:11:01 +0100
|
||||
Subject: [PATCH 04/14] clang: Don't use optimize __atribute__ when using
|
||||
clang.
|
||||
|
||||
Unfortunately clang does not support fine grained per-function
|
||||
optimization tuning. The best we can do to disable null ptr check
|
||||
elimination is to compile affected functions without any optimizations
|
||||
at all. Not ideal, but problaby not measurable in practise.
|
||||
---
|
||||
repos/base-hw/src/lib/base/thread_bootstrap.cc | 4 ++++
|
||||
repos/base/include/base/trace/logger.h | 4 ++++
|
||||
repos/base/src/lib/base/trace.cc | 8 ++++++++
|
||||
3 files changed, 16 insertions(+)
|
||||
|
||||
diff --git a/repos/base-hw/src/lib/base/thread_bootstrap.cc b/repos/base-hw/src/lib/base/thread_bootstrap.cc
|
||||
index 48e0754f4a..7cdd9ea627 100644
|
||||
--- a/repos/base-hw/src/lib/base/thread_bootstrap.cc
|
||||
+++ b/repos/base-hw/src/lib/base/thread_bootstrap.cc
|
||||
@@ -63,7 +63,11 @@ void prepare_reinit_main_thread() { prepare_init_main_thread(); }
|
||||
************/
|
||||
|
||||
/* prevent the compiler from optimizing out the 'this' pointer check */
|
||||
+#ifdef __clang__
|
||||
+[[clang::optnone]]
|
||||
+#else
|
||||
__attribute__((optimize("-fno-delete-null-pointer-checks")))
|
||||
+#endif
|
||||
Native_utcb *Thread::utcb()
|
||||
{
|
||||
if (this) { return &_stack->utcb(); }
|
||||
diff --git a/repos/base/include/base/trace/logger.h b/repos/base/include/base/trace/logger.h
|
||||
index 73e93bb4b6..9ce8af1426 100644
|
||||
--- a/repos/base/include/base/trace/logger.h
|
||||
+++ b/repos/base/include/base/trace/logger.h
|
||||
@@ -78,7 +78,11 @@ struct Genode::Trace::Logger
|
||||
* Log event to trace buffer
|
||||
*/
|
||||
template <typename EVENT>
|
||||
+#ifdef __clang__
|
||||
+ [[clang::optnone]]
|
||||
+#else
|
||||
__attribute__((optimize("-fno-delete-null-pointer-checks")))
|
||||
+#endif
|
||||
void log(EVENT const *event)
|
||||
{
|
||||
if (!this || !_evaluate_control()) return;
|
||||
diff --git a/repos/base/src/lib/base/trace.cc b/repos/base/src/lib/base/trace.cc
|
||||
index 6c597b5571..3676f4d7c5 100644
|
||||
--- a/repos/base/src/lib/base/trace.cc
|
||||
+++ b/repos/base/src/lib/base/trace.cc
|
||||
@@ -147,7 +147,11 @@ bool Trace::Logger::_evaluate_control()
|
||||
}
|
||||
|
||||
|
||||
+#ifdef __clang__
|
||||
+[[clang::optnone]]
|
||||
+#else
|
||||
__attribute__((optimize("-fno-delete-null-pointer-checks")))
|
||||
+#endif
|
||||
void Trace::Logger::log(char const *msg, size_t len)
|
||||
{
|
||||
if (!this || !_evaluate_control()) return;
|
||||
@@ -157,7 +161,11 @@ void Trace::Logger::log(char const *msg, size_t len)
|
||||
}
|
||||
|
||||
|
||||
+#ifdef __clang__
|
||||
+[[clang::optnone]]
|
||||
+#else
|
||||
__attribute__((optimize("-fno-delete-null-pointer-checks")))
|
||||
+#endif
|
||||
bool Trace::Logger::log_captured(char const *msg, size_t len)
|
||||
{
|
||||
if (!this || !_evaluate_control()) return false;
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From fcab75f09f23465e8084a152a8a30d73e060f814 Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Mon, 2 Nov 2020 21:35:31 +0100
|
||||
Subject: [PATCH 05/14] base-hw: Fix src/include/hw/spec/arm/lpae.h build with
|
||||
clang.
|
||||
|
||||
The code contains the following construct:
|
||||
|
||||
enum { X = 12; }
|
||||
|
||||
class A {
|
||||
public:
|
||||
static constexpr size_t Y = X;
|
||||
} __attribute__((aligned(1 << Y)));
|
||||
|
||||
This works fine with GCC, but clang complains it has no clue what Y is
|
||||
when processing the __atribute__ specifier. I'm not an expert in this
|
||||
area, but it does look like clang is correct here. Technically Y should
|
||||
be out of scope after class closing curly bracket.
|
||||
|
||||
This patch does 2 things.
|
||||
1. It uses the original enum value defined outside of aligned class
|
||||
scope.
|
||||
2. It uses C++11 alignas instead of algined atribute. The reason for
|
||||
this is simple. One is a compiler specific extension, while the other
|
||||
is fully defined language feature. Both should be semantically the
|
||||
same.
|
||||
---
|
||||
repos/base-hw/src/include/hw/spec/arm/lpae.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/repos/base-hw/src/include/hw/spec/arm/lpae.h b/repos/base-hw/src/include/hw/spec/arm/lpae.h
|
||||
index 0e41b0eda4..5635c11ec0 100644
|
||||
--- a/repos/base-hw/src/include/hw/spec/arm/lpae.h
|
||||
+++ b/repos/base-hw/src/include/hw/spec/arm/lpae.h
|
||||
@@ -112,7 +112,7 @@ namespace Hw {
|
||||
|
||||
|
||||
template <unsigned BLOCK_SIZE_LOG2, unsigned SZ_LOG2>
|
||||
-class Hw::Long_translation_table
|
||||
+class alignas(1 << Hw::SIZE_LOG2_4KB) Hw::Long_translation_table
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -321,7 +321,7 @@ class Hw::Long_translation_table
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
-} __attribute__((aligned(1 << ALIGNM_LOG2)));
|
||||
+};
|
||||
|
||||
|
||||
template <Hw::Stage STAGE>
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From 49af3d120602e5a59c1eb1aada22f80e094bfd37 Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Mon, 2 Nov 2020 22:05:46 +0100
|
||||
Subject: [PATCH 06/14] base-hw: Fix invalid structure alignments on
|
||||
arm/arm_64.
|
||||
|
||||
The code requests 4 byte alignment for Genode::Arm_cpu::Context.
|
||||
The Context structure inherits Genode::Arm_cpu::Fpu_context which
|
||||
has minimum alignment requirement of 8 bytes, due to uint64_t d0_d31
|
||||
member. This makes the 4 byte value in Context's alignas specifier
|
||||
invalid (smaller than allowed minimum).
|
||||
|
||||
Similar situation takes place in Arm_64 case. The claimed minimum
|
||||
alignment of Context is 8 bytes, but the fpu_state member imposes 16
|
||||
bytes alignment (explicitly specified in Fpu_state declaration).
|
||||
|
||||
In both cases the code builds fine with GCC 8.3.0, but fails with
|
||||
clang which claims that "requested alignment is less than minimum
|
||||
alignment of X for type", where X is 8 on ARM and 16 on AArch64.
|
||||
---
|
||||
repos/base-hw/src/core/spec/arm/cpu_support.h | 2 +-
|
||||
repos/base-hw/src/core/spec/arm_v8/cpu.h | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/repos/base-hw/src/core/spec/arm/cpu_support.h b/repos/base-hw/src/core/spec/arm/cpu_support.h
|
||||
index 13a35d9965..a203de9a8d 100644
|
||||
--- a/repos/base-hw/src/core/spec/arm/cpu_support.h
|
||||
+++ b/repos/base-hw/src/core/spec/arm/cpu_support.h
|
||||
@@ -43,7 +43,7 @@ struct Genode::Arm_cpu : public Hw::Arm_cpu
|
||||
uint64_t d0_d31[32]; /* VFP/SIMD - general purpose registers */
|
||||
};
|
||||
|
||||
- struct alignas(4) Context : Cpu_state, Fpu_context
|
||||
+ struct alignas(8) Context : Cpu_state, Fpu_context
|
||||
{
|
||||
Context(bool privileged);
|
||||
};
|
||||
diff --git a/repos/base-hw/src/core/spec/arm_v8/cpu.h b/repos/base-hw/src/core/spec/arm_v8/cpu.h
|
||||
index e3b114cccc..ca5f84bbec 100644
|
||||
--- a/repos/base-hw/src/core/spec/arm_v8/cpu.h
|
||||
+++ b/repos/base-hw/src/core/spec/arm_v8/cpu.h
|
||||
@@ -56,7 +56,7 @@ struct Genode::Cpu : Hw::Arm_64_cpu
|
||||
Genode::uint32_t fpsr;
|
||||
};
|
||||
|
||||
- struct alignas(8) Context : Cpu_state
|
||||
+ struct alignas(16) Context : Cpu_state
|
||||
{
|
||||
Genode::uint64_t pstate { };
|
||||
Genode::uint64_t exception_type { RESET };
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From c2b93611df003adad7a14b97a741c09a8f6cdde9 Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Wed, 28 Oct 2020 00:56:30 +0100
|
||||
Subject: [PATCH 07/14] base: Silence unused arg warning in rpc_server.h
|
||||
|
||||
The msg argument in Genode::Rpc_dispatcher::_read_arg is not used. GCC
|
||||
does not care about this, but clang does and prints a warning regaring
|
||||
this. Silence it via the usual void cast method.
|
||||
---
|
||||
repos/base/include/base/rpc_server.h | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/repos/base/include/base/rpc_server.h b/repos/base/include/base/rpc_server.h
|
||||
index 6749849d22..95ca60695a 100644
|
||||
--- a/repos/base/include/base/rpc_server.h
|
||||
+++ b/repos/base/include/base/rpc_server.h
|
||||
@@ -101,6 +101,7 @@ class Genode::Rpc_dispatcher : public RPC_INTERFACE
|
||||
template <typename ARG>
|
||||
ARG _read_arg(Ipc_unmarshaller &, Rpc_arg_out)
|
||||
{
|
||||
+ (void)msg;
|
||||
return ARG();
|
||||
}
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From 2b02c29c1aac0d6b3308dc9e58208183b026ac60 Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Wed, 4 Nov 2020 00:43:55 +0100
|
||||
Subject: [PATCH 08/14] base: Fix Genode::List build with clang.
|
||||
|
||||
---
|
||||
repos/base/include/util/list.h | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/repos/base/include/util/list.h b/repos/base/include/util/list.h
|
||||
index e93cc53288..8f63a76196 100644
|
||||
--- a/repos/base/include/util/list.h
|
||||
+++ b/repos/base/include/util/list.h
|
||||
@@ -76,11 +76,11 @@ class Genode::List
|
||||
{
|
||||
/* insert at beginning of the list */
|
||||
if (at == 0) {
|
||||
- le->List::Element::_next = _first;
|
||||
+ ((Element const *)le)->_next = _first;
|
||||
_first = const_cast<LT *>(le);
|
||||
} else {
|
||||
- le->List::Element::_next = at->List::Element::_next;
|
||||
- at->List::Element::_next = const_cast<LT *>(le);
|
||||
+ ((Element const *)le)->_next = ((Element const *)at)->_next;
|
||||
+ ((Element const *)at)->_next = const_cast<LT *>(le);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class Genode::List
|
||||
|
||||
/* if specified element is the first of the list */
|
||||
if (le == _first) {
|
||||
- _first = le->List::Element::_next;
|
||||
+ _first = ((Element const *)le)->_next;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -106,10 +106,10 @@ class Genode::List
|
||||
if (!e->_next) return;
|
||||
|
||||
/* e->_next is the element to remove, skip it in list */
|
||||
- e->List::Element::_next = e->List::Element::_next->List::Element::_next;
|
||||
+ e->_next = ((Element *)e->_next)->_next;
|
||||
}
|
||||
|
||||
- le->List::Element::_next = 0;
|
||||
+ ((Element const *)le)->_next = 0;
|
||||
}
|
||||
};
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From da56cf36681b82061759044b9538067e6dcfa65c Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Wed, 4 Nov 2020 00:26:22 +0100
|
||||
Subject: [PATCH 09/14] base: Drop unused
|
||||
Genode::Trace::Session_component::_parent_levels.
|
||||
|
||||
Clang correctly asserts this private member variable is not used
|
||||
anywhere in the code. I'm not sure what the intention of the code is,
|
||||
might be this is a part of some unfinished feature. This patch just does
|
||||
the minimum amount of work to allow the code to build with clang. If
|
||||
required I can also drop the parent_levels constructor argument and
|
||||
clean up the call sites.
|
||||
---
|
||||
repos/base/src/core/trace_session_component.cc | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/repos/base/src/core/trace_session_component.cc b/repos/base/src/core/trace_session_component.cc
|
||||
index fd86783754..f06c42c728 100644
|
||||
--- a/repos/base/src/core/trace_session_component.cc
|
||||
+++ b/repos/base/src/core/trace_session_component.cc
|
||||
@@ -186,7 +186,9 @@ Session_component::Session_component(Rpc_entrypoint &ep,
|
||||
_policies(policies),
|
||||
_subjects(_subjects_slab, _sources),
|
||||
_argument_buffer(_ram, local_rm, arg_buffer_size)
|
||||
-{ }
|
||||
+{
|
||||
+ (void)parent_levels;
|
||||
+}
|
||||
|
||||
|
||||
Session_component::~Session_component()
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From 4e80673d2d1aeada439c3dd1435e390812b27951 Mon Sep 17 00:00:00 2001
|
||||
From: Piotr Tworek <tworaz@tworaz.net>
|
||||
Date: Fri, 13 Nov 2020 21:40:00 +0100
|
||||
Subject: [PATCH 10/14] os: Fix char as array subscript warning raised by
|
||||
clang.
|
||||
|
||||
Do an explicit cast to silence this warning.
|
||||
---
|
||||
repos/os/include/nitpicker_gfx/tff_font.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/repos/os/include/nitpicker_gfx/tff_font.h b/repos/os/include/nitpicker_gfx/tff_font.h
|
||||
index 3de0bccdbf..e4dfe4f6db 100644
|
||||
--- a/repos/os/include/nitpicker_gfx/tff_font.h
|
||||
+++ b/repos/os/include/nitpicker_gfx/tff_font.h
|
||||
@@ -227,7 +227,7 @@ class Tff_font : public Text_painter::Font
|
||||
|
||||
unsigned baseline() const override
|
||||
{
|
||||
- Tff::Vertical_metrics const m = _vertical_metrics['m'];
|
||||
+ Tff::Vertical_metrics const m = _vertical_metrics[(int)'m'];
|
||||
return m.vpos + m.height;
|
||||
}
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From a8b26680fe92bbae74882bac442f66fa3ba00115 Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Fri, 25 Dec 2020 22:35:00 +0100
|
||||
Subject: [PATCH 11/14] Add Clang CC_WARNs to base-nova internals
|
||||
|
||||
---
|
||||
repos/base-nova/lib/mk/base-nova-common.mk | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/repos/base-nova/lib/mk/base-nova-common.mk b/repos/base-nova/lib/mk/base-nova-common.mk
|
||||
index 81ebc9f3d3..be66ab995e 100644
|
||||
--- a/repos/base-nova/lib/mk/base-nova-common.mk
|
||||
+++ b/repos/base-nova/lib/mk/base-nova-common.mk
|
||||
@@ -14,3 +14,6 @@ SRC_CC += stack_area_addr.cc
|
||||
SRC_CC += cap_map.cc
|
||||
SRC_CC += capability.cc
|
||||
SRC_CC += signal_transmitter.cc
|
||||
+
|
||||
+CC_WARN += -Wno-unknown-attributes
|
||||
+CC_WARN += -Wno-tautological-undefined-compare
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From d75b1cf9197ad4dd20e03a9f32b7fd08c21ccd04 Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Sat, 26 Dec 2020 01:31:46 +0100
|
||||
Subject: [PATCH 12/14] base-nova/core: cast Nova::Hip::Mem_desc::Type to
|
||||
uint32
|
||||
|
||||
---
|
||||
repos/base-nova/src/core/platform.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc
|
||||
index 3d3919f687..0018eba3ef 100644
|
||||
--- a/repos/base-nova/src/core/platform.cc
|
||||
+++ b/repos/base-nova/src/core/platform.cc
|
||||
@@ -497,7 +497,7 @@ Platform::Platform()
|
||||
*/
|
||||
for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) {
|
||||
/* 32/64bit EFI image handle pointer - see multiboot spec 2 */
|
||||
- if (mem_desc->type == 20 || mem_desc->type == 19)
|
||||
+ if ((uint32_t)mem_desc->type == 20 || (uint32_t)mem_desc->type == 19)
|
||||
efi_boot = true;
|
||||
|
||||
if (mem_desc->type == Hip::Mem_desc::FRAMEBUFFER)
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From ca0d74007a2480764eff5843e0c4f968a259633c Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Sat, 26 Dec 2020 01:32:20 +0100
|
||||
Subject: [PATCH 13/14] base-nova: mark Genode::Native_utcb::_utcb as unused
|
||||
|
||||
---
|
||||
repos/base-nova/src/include/base/internal/native_utcb.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/repos/base-nova/src/include/base/internal/native_utcb.h b/repos/base-nova/src/include/base/internal/native_utcb.h
|
||||
index 2f309b65ef..fd3c1bf767 100644
|
||||
--- a/repos/base-nova/src/include/base/internal/native_utcb.h
|
||||
+++ b/repos/base-nova/src/include/base/internal/native_utcb.h
|
||||
@@ -35,7 +35,7 @@ class Genode::Native_utcb
|
||||
* and the user process. It is not backed by a
|
||||
* dataspace but provided by the kernel.
|
||||
*/
|
||||
- addr_t _utcb[UTCB_SIZE/sizeof(addr_t)];
|
||||
+ addr_t _utcb[UTCB_SIZE/sizeof(addr_t)] __attribute__((unused));
|
||||
|
||||
public:
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
||||
From c6e8ce61dc8f936e1f25e0c477796666cacf1088 Mon Sep 17 00:00:00 2001
|
||||
From: Emery Hemingway <ehmry@posteo.net>
|
||||
Date: Sat, 26 Dec 2020 01:34:53 +0100
|
||||
Subject: [PATCH 14/14] cxx: use stdinc headers from ports for Clang
|
||||
|
||||
---
|
||||
repos/base/lib/mk/cxx.mk | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/repos/base/lib/mk/cxx.mk b/repos/base/lib/mk/cxx.mk
|
||||
index 7281e3abfb..1e764d0b61 100644
|
||||
--- a/repos/base/lib/mk/cxx.mk
|
||||
+++ b/repos/base/lib/mk/cxx.mk
|
||||
@@ -3,6 +3,14 @@ INC_DIR += $(REP_DIR)/src/include
|
||||
# We need the libsupc++ include directory
|
||||
STDINC = yes
|
||||
|
||||
+ifeq ($(USE_CLANG),yes)
|
||||
+INC_DIR += $(call select_from_ports,gcc)/src/noux-pkg/gcc/libstdc++-v3/libsupc++
|
||||
+INC_DIR += $(call select_from_ports,stdcxx)/include/stdcxx
|
||||
+INC_DIR += $(call select_from_ports,stdcxx)/include/stdcxx/std
|
||||
+endif
|
||||
+
|
||||
+INC_DIR += $(REP_DIR)/../libports/include/stdcxx
|
||||
+
|
||||
vpath %.cc $(BASE_DIR)/src/lib/cxx
|
||||
vpath %.c $(BASE_DIR)/src/lib/cxx
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
Loading…
Reference in New Issue