summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2022-10-01 13:30:07 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2022-10-04 09:35:04 +0200
commitb3da3e8ac706775fe8dbb5846007317f20bf0c46 (patch)
tree2164acb5dc0cc17e0c7d6d532cb56cf492cc86d5
parent521d3edfe8e6e70d259ec8328e5c81ccff8f0575 (diff)
downloadOSELAS.Toolchain-b3da3e8ac706775fe8dbb5846007317f20bf0c46.tar.gz
OSELAS.Toolchain-b3da3e8ac706775fe8dbb5846007317f20bf0c46.tar.xz
rewrite PTXCONF_TOOLCHAIN_DEBUG and generall debug handling
The regular toolchains are already built with debug symbols, so that part remains the same. PTXCONF_TOOLCHAIN_DEBUG just adds the sources for target libraries to the toolchain. Previously the source directory was changed but that makes the paths longer, which can cause problems. So instead keep the directories and copy the sources instead. Use -ffile-prefix-map= to rewrite the paths in the debug symbols. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--rules/cross-gcc.make18
-rw-r--r--rules/glibc.make13
-rw-r--r--rules/newlib.make4
-rw-r--r--rules/post/ptxd_make_world_install.make14
-rw-r--r--rules/pre/toolchain.make42
-rw-r--r--scripts/lib/ptxd_make_world_install.sh24
6 files changed, 76 insertions, 39 deletions
diff --git a/rules/cross-gcc.make b/rules/cross-gcc.make
index 98c5f03..5758326 100644
--- a/rules/cross-gcc.make
+++ b/rules/cross-gcc.make
@@ -21,8 +21,7 @@ CROSS_GCC_MD5 := $(call remove_quotes,$(PTXCONF_CROSS_GCC_MD5))
CROSS_GCC := gcc-$(CROSS_GCC_DL_VERSION)
CROSS_GCC_SUFFIX := tar.xz
CROSS_GCC_SOURCE := $(SRCDIR)/$(CROSS_GCC).$(CROSS_GCC_SUFFIX)
-CROSS_GCC_DIR := $(BUILDDIR_CROSS_DEBUG)/$(CROSS_GCC)
-CROSS_GCC_BUILDDIR := $(CROSS_BUILDDIR)/$(CROSS_GCC)-build
+CROSS_GCC_DIR := $(CROSS_BUILDDIR)/$(CROSS_GCC)
CROSS_GCC_BUILD_OOT := YES
CROSS_GCC_LICENSE := $(call remove_quotes,$(PTXCONF_CROSS_GCC_LICENSE))
CROSS_GCC_LICENSE_FILES := $(call remove_quotes,$(PTXCONF_CROSS_GCC_LICENSE_FILES))
@@ -41,7 +40,7 @@ ptx/abs2rel := $(PTXDIST_WORKSPACE)/scripts/ptxd_abs2rel.sh
$(STATEDIR)/cross-gcc.extract:
@$(call targetinfo)
@$(call clean, $(CROSS_GCC_DIR))
- @$(call extract, CROSS_GCC, $(BUILDDIR_CROSS_DEBUG))
+ @$(call extract, CROSS_GCC)
@$(call patchin, CROSS_GCC, $(CROSS_GCC_DIR))
ifdef PTXCONF_CROSS_ECJ
@cp $(CROSS_ECJ_SOURCE) $(CROSS_GCC_DIR)/ecj.jar
@@ -91,15 +90,13 @@ CROSS_GCC_AUTOCONF_COMMON := \
$(call ptx/ifdef,PTXCONF_HOST_SYSTEM_MPC,--with-mpc) \
$(call ptx/ifdef,PTXCONF_HOST_SYSTEM_ISL,--with-isl)
-ifndef PTXCONF_TOOLCHAIN_DEBUG
CROSS_GCC_AUTOCONF_COMMON += \
- --with-debug-prefix-map="$(TOOLCHAIN_CROSS_DEBUG_MAP)" \
- --enable-libstdcxx-debug-flags="-gdwarf-4 -O0 $(TOOLCHAIN_CROSS_DEBUG_FLAGS)"
+ --with-debug-prefix-map="$(call ptx/toolchain-cross-debug-map, CROSS_GCC)" \
+ --enable-libstdcxx-debug-flags="-gdwarf-4 -O0 -D_GLIBCXX_ASSERTIONS $(call ptx/toolchain-cross-debug-flags, CROSS_GCC)"
CROSS_GCC_CONF_ENV += \
- CFLAGS_FOR_TARGET="$(TOOLCHAIN_CROSS_DEBUG_FLAGS)" \
- CXXFLAGS_FOR_TARGET="$(TOOLCHAIN_CROSS_DEBUG_FLAGS)"
-endif
+ CFLAGS_FOR_TARGET="$(call ptx/toolchain-cross-debug-flags, CROSS_GCC)" \
+ CXXFLAGS_FOR_TARGET="$(call ptx/toolchain-cross-debug-flags, CROSS_GCC)"
# --enable-tls enable or disable generation of tls code
# overriding the assembler check for tls support
@@ -141,7 +138,7 @@ $(STATEDIR)/cross-gcc.prepare:
@$(call world/prepare, CROSS_GCC)
sed -i -e '/TOPLEVEL_CONFIGURE_ARGUMENTS/s;$(PTXDIST_WORKSPACE);$(PTXCONF_PROJECT);g' \
-e '/TOPLEVEL_CONFIGURE_ARGUMENTS/s;$(call ptx/sh, realpath $(PTXDIST_WORKSPACE));$(PTXCONF_PROJECT);g' \
- $(CROSS_GCC_BUILDDIR)/Makefile
+ $(CROSS_GCC_DIR)-build/Makefile
@$(call touch)
# ----------------------------------------------------------------------------
@@ -193,6 +190,7 @@ endif
$(STATEDIR)/cross-gcc.install.post:
@$(call targetinfo)
@$(call world/install.post, CROSS_GCC)
+ @$(call world/install-src, CROSS_GCC)
@ptxd_make_setup_target_compiler $(PTXDIST_SYSROOT_CROSS)$(PTXCONF_PREFIX_CROSS)/bin
@$(call touch)
diff --git a/rules/glibc.make b/rules/glibc.make
index 674118a..bf4df32 100644
--- a/rules/glibc.make
+++ b/rules/glibc.make
@@ -22,8 +22,8 @@ GLIBC_MD5 := $(call remove_quotes,$(PTXCONF_GLIBC_MD5))
GLIBC := glibc-$(GLIBC_DL_VERSION)
GLIBC_SUFFIX := tar.gz
GLIBC_SOURCE := $(SRCDIR)/$(GLIBC).$(GLIBC_SUFFIX)
-GLIBC_DIR := $(BUILDDIR_DEBUG)/$(GLIBC)
-GLIBC_BUILDDIR := $(BUILDDIR)/$(GLIBC)-build
+GLIBC_DIR := $(BUILDDIR)/$(GLIBC)
+GLIBC_BUILD_OOT := YES
GLIBC_URL := \
$(call ptx/mirror, GNU, glibc/$(GLIBC).$(GLIBC_SUFFIX)) \
https://repo.or.cz/glibc.git/snapshot/$(GLIBC).$(GLIBC_SUFFIX) \
@@ -76,8 +76,8 @@ GLIBC_CONF_OPT := \
--enable-shared \
--enable-static-nss
-GLIBC_CFLAGS = $(TOOLCHAIN_CROSS_DEBUG_FLAGS)
-GLIBC_CXXFLAGS = $(TOOLCHAIN_CROSS_DEBUG_FLAGS)
+GLIBC_CFLAGS := $(call ptx/toolchain-cross-debug-flags, GLIBC)
+GLIBC_CXXFLAGS := $(call ptx/toolchain-cross-debug-flags, GLIBC)
# ----------------------------------------------------------------------------
# Install
@@ -99,7 +99,12 @@ $(STATEDIR)/glibc.install: $(STATEDIR)/glibc.report
echo ' libraries :-( So try them secondarily. */' >> "$(GLIBC_PKGDIR)/usr/lib/libc.a" && \
echo 'GROUP ( /usr/lib/libc_ns.a /usr/lib/libnss_files.a /usr/lib/libnss_dns.a /usr/lib/libresolv.a )' >> "$(GLIBC_PKGDIR)/usr/lib/libc.a" ; \
fi
+ @$(call touch)
+$(STATEDIR)/glibc.install.post:
+ @$(call targetinfo)
+ @$(call world/install.post, GLIBC)
+ @$(call world/install-src, GLIBC)
@$(call touch)
# vim: syntax=make
diff --git a/rules/newlib.make b/rules/newlib.make
index 0565087..be48f1d 100644
--- a/rules/newlib.make
+++ b/rules/newlib.make
@@ -20,8 +20,8 @@ NEWLIB := newlib-$(NEWLIB_VERSION)
NEWLIB_SUFFIX := tar.gz
NEWLIB_URL := https://sourceware.org/pub/newlib/$(NEWLIB).$(NEWLIB_SUFFIX)
NEWLIB_SOURCE := $(SRCDIR)/$(NEWLIB).$(NEWLIB_SUFFIX)
-NEWLIB_DIR := $(BUILDDIR_DEBUG)/$(NEWLIB)
-NEWLIB_BUILDDIR := $(BUILDDIR)/$(NEWLIB)-build
+NEWLIB_DIR := $(BUILDDIR)/$(NEWLIB)
+NEWLIB_BUILD_OOT:= YES
# ----------------------------------------------------------------------------
# Prepare
diff --git a/rules/post/ptxd_make_world_install.make b/rules/post/ptxd_make_world_install.make
new file mode 100644
index 0000000..48c1353
--- /dev/null
+++ b/rules/post/ptxd_make_world_install.make
@@ -0,0 +1,14 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2022 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+world/install-src = \
+ $(call world/env, $(1)) \
+ ptxd_make_world_install_src
+
+# vim: syntax=make
+
diff --git a/rules/pre/toolchain.make b/rules/pre/toolchain.make
index 063f5ac..6d50af4 100644
--- a/rules/pre/toolchain.make
+++ b/rules/pre/toolchain.make
@@ -47,16 +47,16 @@ PTX_HOST_CROSS_AUTOCONF := \
#
PTXDIST_HOST_LDFLAGS := -L${PTXDIST_PATH_SYSROOT_HOST_PREFIX}/lib
-ifndef PTXCONF_TOOLCHAIN_DEBUG
-TOOLCHAIN_CROSS_DEBUG_MAP := \
- $(PTXDIST_WORKSPACE)/platform-=$(call remove_quotes,$(PTXCONF_PROJECT))/platform- \
- $(PTXDIST_SYSROOT_CROSS)=
+TOOLCHAIN_WORKSPACE_SYMLINK := $(subst $(PTXDIST_WORKSPACE),,$(call ptx/sh, realpath $(PTXDIST_WORKSPACE)))
-ifneq ($(PTXDIST_SYSROOT_CROSS),$(call ptx/sh, realpath $(PTXDIST_SYSROOT_CROSS)))
-TOOLCHAIN_CROSS_DEBUG_MAP += \
- $(call ptx/sh, realpath $(PTXDIST_WORKSPACE))/platform-=$(call remove_quotes,$(PTXCONF_PROJECT))/platform- \
- $(call ptx/sh, realpath $(PTXDIST_SYSROOT_CROSS))=
-endif
+define ptx/toolchain-map
+$(1)=$(2) $(if $(TOOLCHAIN_WORKSPACE_SYMLINK),$(call ptx/sh, realpath $(1))=$(2))
+endef
+
+TOOLCHAIN_CROSS_DEBUG_MAP := \
+ $(call ptx/toolchain-map,$(BUILDDIR)) \
+ $(call ptx/toolchain-map,$(CROSS_BUILDDIR)) \
+ $(call ptx/toolchain-map,$(PTXDIST_SYSROOT_CROSS))
PTXDIST_HOST_CPPFLAGS := \
$(PTXDIST_HOST_CPPFLAGS) \
@@ -64,9 +64,16 @@ PTXDIST_HOST_CPPFLAGS := \
TOOLCHAIN_CROSS_DEBUG_FLAGS := \
-g3 \
- -gno-record-gcc-switches \
- $(addprefix -ffile-prefix-map=,$(TOOLCHAIN_CROSS_DEBUG_MAP))
-endif
+ -gno-record-gcc-switches
+
+define ptx/toolchain-cross-debug-map
+$(if $(PTXCONF_TOOLCHAIN_DEBUG),$(call ptx/toolchain-map,$($(strip $(1))_DIR),$(PTXCONF_PREFIX_CROSS)/src/$($(strip $(1))))) \
+$(TOOLCHAIN_CROSS_DEBUG_MAP)
+endef
+define ptx/toolchain-cross-debug-flags
+$(TOOLCHAIN_CROSS_DEBUG_FLAGS) \
+$(addprefix -ffile-prefix-map=,$(call ptx/toolchain-cross-debug-map,$(1)))
+endef
#
# gcc-first
@@ -76,17 +83,6 @@ CROSS_PATH := $(PTXDIST_SYSROOT_HOST)/lib/wrapper:$(PTXDIST_SYSROOT_CROSS)$(PTX
HOST_CROSS_PATH := $(CROSS_PATH)
#
-# debuggable gcc/glibc
-#
-ifdef PTXCONF_TOOLCHAIN_DEBUG
-BUILDDIR_DEBUG := $(PTXDIST_SYSROOT_CROSS)$(PTXCONF_PREFIX_CROSS)/src/target
-BUILDDIR_CROSS_DEBUG := $(PTXDIST_SYSROOT_CROSS)$(PTXCONF_PREFIX_CROSS)/src/cross
-else
-BUILDDIR_DEBUG := $(BUILDDIR)
-BUILDDIR_CROSS_DEBUG := $(CROSS_BUILDDIR)
-endif
-
-#
# images
#
diff --git a/scripts/lib/ptxd_make_world_install.sh b/scripts/lib/ptxd_make_world_install.sh
index 28a9e72..651fbde 100644
--- a/scripts/lib/ptxd_make_world_install.sh
+++ b/scripts/lib/ptxd_make_world_install.sh
@@ -118,3 +118,27 @@ ptxd_make_world_install_pack() {
fi
}
export -f ptxd_make_world_install_pack
+
+ptxd_make_world_install_src() {
+ local base dst
+ ptxd_make_world_init || break
+
+ if [ "$(ptxd_get_ptxconf PTXCONF_TOOLCHAIN_DEBUG)" != "y" ]; then
+ return
+ fi
+
+ base="${PTXDIST_SYSROOT_CROSS}$(ptxd_get_ptxconf PTXCONF_PREFIX_CROSS)/src"
+ dst="${base}/$(basename ${pkg_dir})"
+ echo -e "\nCopying sources to $(ptxd_print_path "${dst}") ...\n"
+ mkdir -p "${base}" &&
+ rm -rf "${dst}" &&
+ cp -a "${pkg_dir}" "${dst}" &&
+ rm -f "${dst}/.pc/.quilt_patches" &&
+ if [ -e "${dst}/.ptxdist" ]; then
+ # patches and series are symlinked to the BSP, explicit copy the
+ # actual files here
+ rm -r "${dst}/.ptxdist" &&
+ cp -aL "${pkg_dir}/.ptxdist" "${dst}/.ptxdist"
+ fi
+}
+export -f ptxd_make_world_install_src