summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2020-05-06 10:49:52 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2020-05-11 07:41:37 +0200
commit5f734311e4fe963ea41e686b1b7bae5b0ac3260f (patch)
tree6cf628528f20cc5b6fad22d87a65e28d8bdaad22
parent73fbfa7ed205c36178f95b983e1c7eea175420af (diff)
downloadOSELAS.Toolchain-5f734311e4fe963ea41e686b1b7bae5b0ac3260f.tar.gz
OSELAS.Toolchain-5f734311e4fe963ea41e686b1b7bae5b0ac3260f.tar.xz
use icecc for cross-compiling
Multiple things are needed to make this possible: - the wrapper dir must be first in $PATH to ensure that any available wrapper is used. - when gcc-first and gcc are done building, then a new icecc environment must be created. - use icerun to limit parallelization when xgcc/xg++ is used to build the internal libraries Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--rules/cross-gcc-first.make9
-rw-r--r--rules/cross-gcc.make10
-rw-r--r--rules/pre/toolchain.make2
-rwxr-xr-xscripts/icecc-create-env-wrapper23
-rw-r--r--scripts/lib/ptxd_make_compiler.sh28
-rw-r--r--scripts/lib/ptxd_make_env_init.sh19
6 files changed, 88 insertions, 3 deletions
diff --git a/rules/cross-gcc-first.make b/rules/cross-gcc-first.make
index d842939..6953a9a 100644
--- a/rules/cross-gcc-first.make
+++ b/rules/cross-gcc-first.make
@@ -31,7 +31,7 @@ CROSS_GCC_FIRST_LICENSE := ignore
# Prepare
# ----------------------------------------------------------------------------
-CROSS_GCC_FIRST_ENV := \
+CROSS_GCC_FIRST_CONF_ENV := \
$(HOST_ENV) \
CFLAGS="-g0 -O2" \
CXXFLAGS="-g0 -O2" \
@@ -60,6 +60,11 @@ CROSS_GCC_FIRST_CONF_OPT = \
--disable-libatomic \
--with-system-zlib
+ifdef PTXDIST_ICECC
+CROSS_GCC_FIRST_MAKE_ENV := \
+ STAGE_CC_WRAPPER=icerun
+endif
+
# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------
@@ -76,7 +81,7 @@ $(STATEDIR)/cross-gcc-first.install:
ln -sfv libgcc.a `$(CROSS_GCC_FIRST_PREFIX)/bin/$(PTXCONF_GNU_TARGET)-gcc \
-print-libgcc-file-name | \
sed 's/libgcc/&_s/'`
-
+ @ptxd_make_setup_target_compiler $(CROSS_GCC_FIRST_PREFIX)/bin
@$(call touch)
# vim: syntax=make
diff --git a/rules/cross-gcc.make b/rules/cross-gcc.make
index c4ef5fa..26bb3e7 100644
--- a/rules/cross-gcc.make
+++ b/rules/cross-gcc.make
@@ -149,6 +149,11 @@ $(STATEDIR)/cross-gcc.prepare:
# Compile
# ----------------------------------------------------------------------------
+ifdef PTXDIST_ICECC
+CROSS_GCC_MAKE_ENV := \
+ STAGE_CC_WRAPPER=icerun
+endif
+
CROSS_GCC_MAKE_OPT := \
build_tooldir=$(PTXDIST_SYSROOT_CROSS)$(PTXCONF_PREFIX_CROSS)/$(PTXCONF_GNU_TARGET) \
all
@@ -178,7 +183,12 @@ ifneq ($(call remove_quotes,$(PTXDIST_SYSROOT_CROSS)),)
$(CROSS_GCC_PKGDIR)$(PTXCONF_PREFIX_CROSS)/lib/gcc/$(PTXCONF_GNU_TARGET)/$(CROSS_GCC_VERSION)/install-tools/mkheaders.conf \
$(wildcard $(CROSS_GCC_PKGDIR)$(PTXCONF_PREFIX_CROSS)/lib/gcc/$(PTXCONF_GNU_TARGET)/$(CROSS_GCC_VERSION)/include-fixed/bits/statx.h)
endif
+ @$(call touch)
+$(STATEDIR)/cross-gcc.install.post:
+ @$(call targetinfo)
+ @$(call world/install.post, CROSS_GCC)
+ @ptxd_make_setup_target_compiler $(PTXDIST_SYSROOT_CROSS)$(PTXCONF_PREFIX_CROSS)/bin
@$(call touch)
# vim: syntax=make
diff --git a/rules/pre/toolchain.make b/rules/pre/toolchain.make
index ec948f2..fd3703a 100644
--- a/rules/pre/toolchain.make
+++ b/rules/pre/toolchain.make
@@ -78,7 +78,7 @@ endif
# gcc-first
#
CROSS_GCC_FIRST_PREFIX := $(PTXDIST_PLATFORMDIR)/sysroot-target
-CROSS_PATH := $(PTXDIST_SYSROOT_CROSS)$(PTXCONF_PREFIX_CROSS)/bin:$(PTXDIST_SYSROOT_CROSS)$(PTXCONF_PREFIX_CROSS)/sbin:$(CROSS_GCC_FIRST_PREFIX)/bin:$(PATH)
+CROSS_PATH := $(PTXDIST_SYSROOT_HOST)/lib/wrapper:$(PTXDIST_SYSROOT_CROSS)$(PTXCONF_PREFIX_CROSS)/bin:$(subst $(PTXDIST_SYSROOT_HOST)/lib/wrapper:,,$(PATH))
HOST_CROSS_PATH := $(CROSS_PATH)
#
diff --git a/scripts/icecc-create-env-wrapper b/scripts/icecc-create-env-wrapper
new file mode 100755
index 0000000..31581c9
--- /dev/null
+++ b/scripts/icecc-create-env-wrapper
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+if grep -q -- --compression "${PTXDIST_ICECC_CREATE_ENV_REAL}"; then
+ args=( --compression none )
+fi
+
+"${PTXDIST_ICECC_CREATE_ENV_REAL}" "${@}" "${args[@]}" || exit
+
+ptxd_get_path *.tar*
+env="${ptxd_reply}"
+mkdir tmp
+cd tmp
+tar xf "../${env}"
+
+find -type f | xargs strip
+
+tar -ch --numeric-owner -zvf "../${env//.*}.tar.gz" *
+
+cd ..
+rm -rf tmp
+if [ "${env}" != "${env//.*}.tar.gz" ]; then
+ rm "${env}"
+fi
diff --git a/scripts/lib/ptxd_make_compiler.sh b/scripts/lib/ptxd_make_compiler.sh
new file mode 100644
index 0000000..baf6f9a
--- /dev/null
+++ b/scripts/lib/ptxd_make_compiler.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Copyright (C) 2020 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# helper to allow late wrapper / icecc setup
+#
+ptxd_make_setup_target_compiler() {
+ local wrapper_dir sysroot_host
+ local toolchain compiler_prefix
+
+ sysroot_host="$(ptxd_get_ptxconf PTXCONF_SYSROOT_HOST)"
+ wrapper_dir="${sysroot_host}/lib/wrapper"
+
+ toolchain="${1}"
+ compiler_prefix="$(ptxd_get_ptxconf PTXCONF_COMPILER_PREFIX)"
+
+ ptxd_lib_setup_target_wrapper &&
+ PTXDIST_ICECC_CREATE_ENV_REAL="${PTXDIST_ICECC_CREATE_ENV}" \
+ PTXDIST_ICECC_CREATE_ENV="${PTXDIST_WORKSPACE}/scripts/icecc-create-env-wrapper" \
+ ptxd_lib_setup_target_icecc
+}
+export -f ptxd_make_setup_target_compiler
+
diff --git a/scripts/lib/ptxd_make_env_init.sh b/scripts/lib/ptxd_make_env_init.sh
new file mode 100644
index 0000000..39b1642
--- /dev/null
+++ b/scripts/lib/ptxd_make_env_init.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Copyright (C) 2020 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# The search paths added with these variables are needed in a BSP because
+# there are two sysroots: The one from the toolchain and the BSP. This is
+# not the case when building a toolchain, so they are not necessary here.
+#
+ptxd_init_cross_env_toolchain() {
+ unset PTXDIST_CROSS_CPPFLAGS
+ unset PTXDIST_CROSS_LDFLAGS
+}
+
+ptxd_init_cross_env_toolchain