All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@impinj.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2] toolchain-external: Fix paths in libstdc++ gdb python file
Date: Mon, 1 Apr 2019 20:48:22 +0000	[thread overview]
Message-ID: <20190401204813.31424-1-tpiepho@impinj.com> (raw)

In the ARM ARM 2018.11 toolchain, the python file
libstdc++.so.6.0.25-gdb.py contains two paths:
pythondir = '/share/gcc-8.2.1/python'
libdir = '/arm-linux-gnueabihf/lib'

The latter is the location of the file in the toolchain and the former
the location of a python module to be used by gdb.  The python code in
the file subtracts libdir from the end of the current
libstdc++.so.6.0.25-gdb.py location and appends pythondir, to find the
current path to the python module.

Buildroot installs this file into the stage, at which point the paths
above are no longer correct.

In the Linaro ARM 2018.05 toolchain, these paths absolute paths on the
toolchain's build host and not even current before buildroot moves the
py file.

This patch uses sed to fixup the paths to reflect the installed
location, relative to HOST_DIR, and the location of the python module
relative to HOST_DIR.

External toolchains can have this fixup invoked by setting
$(PKG)_LIBSTDCPP_GDB_PY and $(PKG)_PYTHON_DIR.

Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 toolchain/toolchain-external/pkg-toolchain-external.mk        | 11 +++++++++++
 .../toolchain-external-arm-arm/toolchain-external-arm-arm.mk  |  4 ++++
 .../toolchain-external-linaro-arm.mk                          |  4 ++++
 3 files changed, 19 insertions(+)

diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk
index db3570d96f..e900507ddc 100644
--- a/toolchain/toolchain-external/pkg-toolchain-external.mk
+++ b/toolchain/toolchain-external/pkg-toolchain-external.mk
@@ -486,6 +486,16 @@ define TOOLCHAIN_EXTERNAL_FIXUP_UCLIBCNG_LDSO
 	fi
 endef
 
+define TOOLCHAIN_EXTERNAL_FIXUP_LIBSTDCPP_PYTHON
+	$(Q)if [ -n "$($(PKG)_LIBSTDCPP_GDB_PY)" ]; then \
+		echo Fixing paths in $($(PKG)_LIBSTDCPP_GDB_PY); \
+		sed -Ei \
+			-e "s:^(pythondir = ').*':\1$(patsubst $(HOST_DIR)/%,/%,$(TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR))$($(PKG)_PYTHON_DIR)':" \
+			-e "s:^(libdir = ').*':\1$(patsubst $(HOST_DIR)/%,/%,$(STAGING_DIR)/usr/lib)':" \
+			$(STAGING_DIR)/usr/lib/$($(PKG)_LIBSTDCPP_GDB_PY); \
+	fi
+endef
+
 
 ################################################################################
 # inner-toolchain-external-package -- defines the generic installation rules
@@ -562,6 +572,7 @@ define $(2)_INSTALL_STAGING_CMDS
 	$$(TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS)
 	$$(TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER)
 	$$(TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT)
+	$$(TOOLCHAIN_EXTERNAL_FIXUP_LIBSTDCPP_PYTHON)
 endef
 
 # Even though we're installing things in both the staging, the host
diff --git a/toolchain/toolchain-external/toolchain-external-arm-arm/toolchain-external-arm-arm.mk b/toolchain/toolchain-external/toolchain-external-arm-arm/toolchain-external-arm-arm.mk
index 0c21affd7b..4d9e27e7e1 100644
--- a/toolchain/toolchain-external/toolchain-external-arm-arm/toolchain-external-arm-arm.mk
+++ b/toolchain/toolchain-external/toolchain-external-arm-arm/toolchain-external-arm-arm.mk
@@ -9,4 +9,8 @@ TOOLCHAIN_EXTERNAL_ARM_ARM_SITE = https://developer.arm.com/-/media/Files/downlo
 
 TOOLCHAIN_EXTERNAL_ARM_ARM_SOURCE = gcc-arm-8.2-$(TOOLCHAIN_EXTERNAL_ARM_ARM_VERSION)-x86_64-arm-linux-gnueabihf.tar.xz
 
+# Fix up paths in python file so they points at the PYTHON_DIR
+TOOLCHAIN_EXTERNAL_ARM_ARM_LIBSTDCPP_GDB_PY = libstdc++.so.6.0.25-gdb.py
+TOOLCHAIN_EXTERNAL_ARM_ARM_PYTHON_DIR = /share/gcc-8.2.1/python
+
 $(eval $(toolchain-external-package))
diff --git a/toolchain/toolchain-external/toolchain-external-linaro-arm/toolchain-external-linaro-arm.mk b/toolchain/toolchain-external/toolchain-external-linaro-arm/toolchain-external-linaro-arm.mk
index fda356bcea..77afc6d30f 100644
--- a/toolchain/toolchain-external/toolchain-external-linaro-arm/toolchain-external-linaro-arm.mk
+++ b/toolchain/toolchain-external/toolchain-external-linaro-arm/toolchain-external-linaro-arm.mk
@@ -13,4 +13,8 @@ else
 TOOLCHAIN_EXTERNAL_LINARO_ARM_SOURCE = gcc-linaro-7.3.1-$(TOOLCHAIN_EXTERNAL_LINARO_ARM_VERSION)-x86_64_arm-linux-gnueabihf.tar.xz
 endif
 
+# Fix up paths in python file so they points at the PYTHON_DIR
+TOOLCHAIN_EXTERNAL_LINARO_ARM_LIBSTDCPP_GDB_PY = libstdc++.so.6.0.24-gdb.py
+TOOLCHAIN_EXTERNAL_LINARO_ARM_PYTHON_DIR = /share/gcc-7.3.1/python
+
 $(eval $(toolchain-external-package))
-- 
2.14.5

             reply	other threads:[~2019-04-01 20:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 20:48 Trent Piepho [this message]
2019-04-14 21:25 ` [Buildroot] [PATCH v2] toolchain-external: Fix paths in libstdc++ gdb python file Arnout Vandecappelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190401204813.31424-1-tpiepho@impinj.com \
    --to=tpiepho@impinj.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.