aboutsummaryrefslogtreecommitdiff
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
parent8f09d075541654f04a9260cc65606f0089749521 (diff)
Fixup -ffile-prefix-map in Debian implementation
-rw-r--r--bpkg/pkg-bindist.cxx4
-rw-r--r--bpkg/system-package-manager-debian.cxx42
-rw-r--r--bpkg/system-package-manager-debian.hxx1
-rw-r--r--bpkg/system-package-manager-fedora.cxx1
-rw-r--r--bpkg/system-package-manager-fedora.hxx1
-rw-r--r--bpkg/system-package-manager.hxx3
6 files changed, 41 insertions, 11 deletions
diff --git a/bpkg/pkg-bindist.cxx b/bpkg/pkg-bindist.cxx
index f1ef84e..e3ec9fa 100644
--- a/bpkg/pkg-bindist.cxx
+++ b/bpkg/pkg-bindist.cxx
@@ -397,13 +397,11 @@ namespace bpkg
<< "manager with --distribution";
}
- // @@ TODO: pass/handle --private.
-
// Note that we pass type from here in case one day we want to provide an
// option to specify/override it (along with languages). Note that there
// will probably be no way to override type for dependencies.
//
- paths r (spm->generate (pkgs, deps, vars, pm, type, langs, rec));
+ paths r (spm->generate (pkgs, deps, vars, db.config, pm, type, langs, rec));
if (r.empty ())
return 0; // Assume prepare-only mode or similar.
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'
diff --git a/bpkg/system-package-manager-debian.hxx b/bpkg/system-package-manager-debian.hxx
index 4736a7c..cf7b1c3 100644
--- a/bpkg/system-package-manager-debian.hxx
+++ b/bpkg/system-package-manager-debian.hxx
@@ -137,6 +137,7 @@ namespace bpkg
generate (const packages&,
const packages&,
const strings&,
+ const dir_path&,
const package_manifest&,
const string&,
const small_vector<language, 1>&,
diff --git a/bpkg/system-package-manager-fedora.cxx b/bpkg/system-package-manager-fedora.cxx
index 7cffcf7..576e0ef 100644
--- a/bpkg/system-package-manager-fedora.cxx
+++ b/bpkg/system-package-manager-fedora.cxx
@@ -1799,6 +1799,7 @@ namespace bpkg
generate (const packages&,
const packages&,
const strings&,
+ const dir_path&,
const package_manifest&,
const string&,
const small_vector<language, 1>&,
diff --git a/bpkg/system-package-manager-fedora.hxx b/bpkg/system-package-manager-fedora.hxx
index 2eebb90..8da8863 100644
--- a/bpkg/system-package-manager-fedora.hxx
+++ b/bpkg/system-package-manager-fedora.hxx
@@ -200,6 +200,7 @@ namespace bpkg
generate (const packages&,
const packages&,
const strings&,
+ const dir_path&,
const package_manifest&,
const string&,
const small_vector<language, 1>&,
diff --git a/bpkg/system-package-manager.hxx b/bpkg/system-package-manager.hxx
index 8a5b891..4549fba 100644
--- a/bpkg/system-package-manager.hxx
+++ b/bpkg/system-package-manager.hxx
@@ -164,7 +164,7 @@ namespace bpkg
// out_root is only set for packages in pkgs. Note also that all the
// packages in pkgs and deps are guaranteed to belong to the same build
// configuration (as opposed to being spread over multiple linked
- // configurations).
+ // configurations). Its absolute path is bassed in cfg_dir.
//
// The passed package manifest corresponds to the first package in pkgs
// (normally used as a source of additional package metadata such as
@@ -197,6 +197,7 @@ namespace bpkg
generate (const packages& pkgs,
const packages& deps,
const strings& vars,
+ const dir_path& cfg_dir,
const package_manifest&,
const string& type,
const small_vector<language, 1>&,