aboutsummaryrefslogtreecommitdiff
path: root/bpkg/system-package-manager-debian.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-03-09 11:43:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-03-09 11:43:06 +0200
commit45dbab0463473e4650d9cd792673844a3e506551 (patch)
tree344a62f6fdb491ff0a38725a1bd3541e166c477f /bpkg/system-package-manager-debian.cxx
parent8f09d075541654f04a9260cc65606f0089749521 (diff)
Fixup -ffile-prefix-map in Debian implementation
Diffstat (limited to 'bpkg/system-package-manager-debian.cxx')
-rw-r--r--bpkg/system-package-manager-debian.cxx42
1 files changed, 35 insertions, 7 deletions
diff --git a/bpkg/system-package-manager-debian.cxx b/bpkg/system-package-manager-debian.cxx
index 7cac782..9350a13 100644
--- a/bpkg/system-package-manager-debian.cxx
+++ b/bpkg/system-package-manager-debian.cxx
@@ -1907,6 +1907,7 @@ namespace bpkg
generate (const packages& pkgs,
const packages& deps,
const strings& vars,
+ const dir_path& cfg_dir,
const package_manifest& pm,
const string& pt,
const small_vector<language, 1>& langs,
@@ -2693,9 +2694,9 @@ namespace bpkg
// approaches). Note that these come in the dpkg-dev package, the same
// as dpkg-buildpackage.
//
- os << "# DEB_HOST_* (DEB_HOST_MULTIARCH, etc)"
- << "#" << '\n'
- << "include /usr/share/dpkg/architecture.mk" << '\n'
+ os << "# DEB_HOST_* (DEB_HOST_MULTIARCH, etc)" << '\n'
+ << "#" << '\n'
+ << "include /usr/share/dpkg/architecture.mk" << '\n'
<< '\n';
if (ops_->debian_buildflags () != "ignore")
@@ -2707,11 +2708,36 @@ namespace bpkg
// example, they also cover Assembler, Fortran, and potentially others
// in the future).
//
- os << "# *FLAGS (CFLAGS, CXXFLAGS, etc)"
- << "#" << '\n'
- << "export DEB_BUILD_MAINT_OPTIONS := hardening=+all" << '\n'
- << "include /usr/share/dpkg/buildflags.mk" << '\n'
+ os << "# *FLAGS (CFLAGS, CXXFLAGS, etc)" << '\n'
+ << "#" << '\n'
+ << "export DEB_BUILD_MAINT_OPTIONS := hardening=+all" << '\n'
+ << "include /usr/share/dpkg/buildflags.mk" << '\n'
<< '\n';
+
+ // Fixup -ffile-prefix-map option (if specified) which is used to
+ // strip source file path prefix in debug information (besides other
+ // places). By default it points to the source directory. We change it
+ // to point to the bpkg configuration directory. Note that this won't
+ // work for external packages with source out of configuration (e.g.,
+ // managed by bdep).
+ //
+ if (lang_c || lang_cc)
+ {
+ // @@ TODO: OBJCFLAGS.
+
+ os << "CFLAGS := $(patsubst -ffile-prefix-map=%,-ffile-prefix-map="
+ << cfg_dir.string () << "=.,$(CFLAGS))" << '\n'
+ << '\n';
+ }
+
+ if (lang_cxx || lang_cc)
+ {
+ // @@ TODO: OBJCXXFLAGS.
+
+ os << "CXXFLAGS := $(patsubst -ffile-prefix-map=%,-ffile-prefix-map="
+ << cfg_dir.string () << "=.,$(CXXFLAGS))" << '\n'
+ << '\n';
+ }
}
// The debian/tmp/ subdirectory appears to be the canonical destination
@@ -2798,6 +2824,7 @@ namespace bpkg
if (lang_c || lang_cc)
{
// @@ TODO: OBJCFLAGS (we currently don't have separate options).
+ // Also see -ffile-prefix-map fixup above.
os << "config += config.c.poptions" << o << "'$(CPPFLAGS)'" << '\n'
<< "config += config.c.coptions" << o << "'$(CFLAGS)'" << '\n'
@@ -2807,6 +2834,7 @@ namespace bpkg
if (lang_cxx || lang_cc)
{
// @@ TODO: OBJCXXFLAGS (we currently don't have separate options).
+ // Also see -ffile-prefix-map fixup above.
os << "config += config.cxx.poptions" << o << "'$(CPPFLAGS)'" << '\n'
<< "config += config.cxx.coptions" << o << "'$(CXXFLAGS)'" << '\n'