This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=2782c16163c8736e545ee868bdc4054e59f6f6ee

commit 2782c16163c8736e545ee868bdc4054e59f6f6ee (HEAD -> main)
Author: Guillem Jover <[email protected]>
AuthorDate: Fri Sep 1 00:27:44 2023 +0200

    scripts: Add basic support for _FOR_BUILD build flags
    
    These flags are intended to be used when building objects for the
    build system (in contrast to the host system), usually with tools
    that also end with _FOR_BUILD such as CC_FOR_BUILD.
    
    We start with basic support for these flags, as this will make it
    possible for packages to start using them, and the support can be
    extended later on.
---
 man/dpkg-buildflags.pod       | 63 +++++++++++++++++++++++++++++++++++++++++++
 scripts/Dpkg/BuildFlags.pm    | 10 +++++++
 scripts/Dpkg/BuildInfo.pm     |  9 +++++++
 scripts/Dpkg/Vendor/Debian.pm |  2 ++
 scripts/mk/buildflags.mk      | 23 ++++++++++++++++
 scripts/t/Dpkg_BuildInfo.t    |  2 +-
 scripts/t/mk/buildflags.mk    | 11 ++++++++
 7 files changed, 119 insertions(+), 1 deletion(-)

diff --git a/man/dpkg-buildflags.pod b/man/dpkg-buildflags.pod
index 4cedd0b24..c6fee046e 100644
--- a/man/dpkg-buildflags.pod
+++ b/man/dpkg-buildflags.pod
@@ -318,6 +318,69 @@ and
 B<,>
 have to be stripped from these options). Default value: empty.
 
+=item B<ASFLAGS_FOR_BUILD>
+
+Options for the build assembler.
+Default value: empty.
+Since dpkg 1.22.1.
+
+=item B<CFLAGS_FOR_BUILD>
+
+Options for the build C compiler.
+The default value set by the vendor includes B<-g> and the default
+optimization level (B<-O2> usually, or B<-O0> if the B<DEB_BUILD_OPTIONS>
+environment variable defines I<noopt>).
+Since dpkg 1.22.1.
+
+=item B<CPPFLAGS_FOR_BUILD>
+
+Options for the build C preprocessor.
+Default value: empty.
+Since dpkg 1.22.1.
+
+=item B<CXXFLAGS_FOR_BUILD>
+
+Options for the build C++ compiler.
+Same as B<CFLAGS_FOR_BUILD>.
+Since dpkg 1.22.1.
+
+=item B<OBJCFLAGS_FOR_BUILD>
+
+Options for the build Objective C compiler.
+Same as B<CFLAGS_FOR_BUILD>.
+Since dpkg 1.22.1.
+
+=item B<OBJCXXFLAGS_FOR_BUILD>
+
+Options for the build Objective C++ compiler.
+Same as B<CXXFLAGS_FOR_BUILD>.
+Since dpkg 1.22.1.
+
+=item B<DFLAGS_FOR_BUILD>
+
+Options for the build D compiler (ldc or gdc).
+Since dpkg 1.22.1.
+
+=item B<FFLAGS_FOR_BUILD>
+
+Options for the build Fortran 77 compiler.
+A subset of B<CFLAGS_FOR_BUILD>.
+Since dpkg 1.22.1.
+
+=item B<FCFLAGS_FOR_BUILD>
+
+Options for the build Fortran 9x compiler.
+Same as B<FFLAGS_FOR_BUILD>.
+Since dpkg 1.22.1.
+
+=item B<LDFLAGS_FOR_BUILD>
+
+Options passed to the build compiler when linking executables or shared
+objects (if the linker is called directly, then B<-Wl> and B<,> have to
+be stripped from these options).
+Default value: empty.
+Since dpkg 1.22.1.
+
 =back
 
 New flags might be added in the future if the need arises (for example
diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm
index 8c53e2589..8aff53ecc 100644
--- a/scripts/Dpkg/BuildFlags.pm
+++ b/scripts/Dpkg/BuildFlags.pm
@@ -75,15 +75,25 @@ sub _init_vendor_defaults {
 
     my @flags = qw(
         ASFLAGS
+        ASFLAGS_FOR_BUILD
         CPPFLAGS
+        CPPFLAGS_FOR_BUILD
         CFLAGS
+        CFLAGS_FOR_BUILD
         CXXFLAGS
+        CXXFLAGS_FOR_BUILD
         OBJCFLAGS
+        OBJCFLAGS_FOR_BUILD
         OBJCXXFLAGS
+        OBJCXXFLAGS_FOR_BUILD
         DFLAGS
+        DFLAGS_FOR_BUILD
         FFLAGS
+        FFLAGS_FOR_BUILD
         FCFLAGS
+        FCFLAGS_FOR_BUILD
         LDFLAGS
+        LDFLAGS_FOR_BUILD
     );
 
     $self->{features} = {};
diff --git a/scripts/Dpkg/BuildInfo.pm b/scripts/Dpkg/BuildInfo.pm
index 761c16658..0792659bf 100644
--- a/scripts/Dpkg/BuildInfo.pm
+++ b/scripts/Dpkg/BuildInfo.pm
@@ -71,14 +71,23 @@ my @env_allowed = (
     # Toolchain flags.
     qw(
         ASFLAGS
+        ASFLAGS_FOR_BUILD
         CFLAGS
+        CFLAGS_FOR_BUILD
         CPPFLAGS
+        CPPFLAGS_FOR_BUILD
         CXXFLAGS
+        CXXFLAGS_FOR_BUILD
         OBJCFLAGS
+        OBJCFLAGS_FOR_BUILD
         OBJCXXFLAGS
+        OBJCXXFLAGS_FOR_BUILD
         DFLAGS
+        DFLAGS_FOR_BUILD
         FFLAGS
+        FFLAGS_FOR_BUILD
         LDFLAGS
+        LDFLAGS_FOR_BUILD
         ARFLAGS
         MAKEFLAGS
     ),
diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm
index 49935c9d7..dcc3cc124 100644
--- a/scripts/Dpkg/Vendor/Debian.pm
+++ b/scripts/Dpkg/Vendor/Debian.pm
@@ -412,7 +412,9 @@ sub _add_build_flags {
     }
 
     $flags->append($_, $default_flags) foreach @compile_flags;
+    $flags->append($_ . '_FOR_BUILD', $default_flags) foreach @compile_flags;
     $flags->append('DFLAGS', $default_d_flags);
+    $flags->append('DFLAGS_FOR_BUILD', $default_d_flags);
 
     ## Area: abi
 
diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk
index 28d37765f..4b8a3d8c4 100644
--- a/scripts/mk/buildflags.mk
+++ b/scripts/mk/buildflags.mk
@@ -12,6 +12,19 @@
 #   FCFLAGS: flags for the host Fortran 9x compiler.
 #   LDFLAGS: flags for the host linker.
 #
+# And the following variables for the build tools (since dpkg 1.22.1):
+#
+#   ASFLAGS_FOR_BUILD: flags for the build assembler.
+#   CFLAGS_FOR_BUILD: flags for the build C compiler.
+#   CPPFLAGS_FOR_BUILD: flags for the build C preprocessor.
+#   CXXFLAGS_FOR_BUILD: flags for the build C++ compiler.
+#   OBJCFLAGS_FOR_BUILD: flags for the build Objective C compiler.
+#   OBJCXXFLAGS_FOR_BUILD: flags for the build Objective C++ compiler.
+#   DFLAGS_FOR_BUILD: flags for the build D compiler.
+#   FFLAGS_FOR_BUILD: flags for the build Fortran 77 compiler.
+#   FCFLAGS_FOR_BUILD: flags for the build Fortran 9x compiler.
+#   LDFLAGS_FOR_BUILD: flags for the build linker.
+#
 # You can also export them in the environment by setting
 # DPKG_EXPORT_BUILDFLAGS to a non-empty value.
 #
@@ -22,15 +35,25 @@ dpkg_lazy_eval ?= $$(or $$(value DPKG_CACHE_$(1)),$$(eval 
DPKG_CACHE_$(1) := $$(
 
 DPKG_BUILDFLAGS_LIST = \
   ASFLAGS \
+  ASFLAGS_FOR_BUILD \
   CFLAGS \
+  CFLAGS_FOR_BUILD \
   CPPFLAGS \
+  CPPFLAGS_FOR_BUILD \
   CXXFLAGS \
+  CXXFLAGS_FOR_BUILD \
   OBJCFLAGS \
+  OBJCFLAGS_FOR_BUILD \
   OBJCXXFLAGS \
+  OBJCXXFLAGS_FOR_BUILD \
   DFLAGS \
+  DFLAGS_FOR_BUILD \
   FFLAGS \
+  FFLAGS_FOR_BUILD \
   FCFLAGS \
+  FCFLAGS_FOR_BUILD \
   LDFLAGS \
+  LDFLAGS_FOR_BUILD \
   # EOL
 
 define dpkg_buildflags_export_envvar
diff --git a/scripts/t/Dpkg_BuildInfo.t b/scripts/t/Dpkg_BuildInfo.t
index 2dad01d7f..edc18183c 100644
--- a/scripts/t/Dpkg_BuildInfo.t
+++ b/scripts/t/Dpkg_BuildInfo.t
@@ -22,5 +22,5 @@ BEGIN {
     use_ok('Dpkg::BuildInfo');
 }
 
-is(scalar Dpkg::BuildInfo::get_build_env_allowed(), 51,
+is(scalar Dpkg::BuildInfo::get_build_env_allowed(), 60,
    'allowed environment variables array');
diff --git a/scripts/t/mk/buildflags.mk b/scripts/t/mk/buildflags.mk
index 7418cda6e..94d85a7e0 100644
--- a/scripts/t/mk/buildflags.mk
+++ b/scripts/t/mk/buildflags.mk
@@ -1,15 +1,26 @@
 DEB_CPPFLAGS_MAINT_APPEND = -DTEST_MK=test-host
+DEB_CPPFLAGS_FOR_BUILD_MAINT_APPEND = -DTEST_MK=test-build
 
 include $(srcdir)/mk/buildflags.mk
 
 test:
        test "$(ASFLAGS)" = "$(TEST_ASFLAGS)"
+       test "$(ASFLAGS_FOR_BUILD)" = "$(TEST_ASFLAGS_FOR_BUILD)"
        test "$(CFLAGS)" = "$(TEST_CFLAGS)"
+       test "$(CFLAGS_FOR_BUILD)" = "$(TEST_CFLAGS_FOR_BUILD)"
        test "$(CPPFLAGS)" = "$(TEST_CPPFLAGS) -DTEST_MK=test-host"
+       test "$(CPPFLAGS_FOR_BUILD)" = 
"$(TEST_CPPFLAGS_FOR_BUILD)-DTEST_MK=test-build"
        test "$(CXXFLAGS)" = "$(TEST_CXXFLAGS)"
+       test "$(CXXFLAGS_FOR_BUILD)" = "$(TEST_CXXFLAGS_FOR_BUILD)"
        test "$(DFLAGS)" = "$(TEST_DFLAGS)"
+       test "$(DFLAGS_FOR_BUILD)" = "$(TEST_DFLAGS_FOR_BUILD)"
        test "$(FCFLAGS)" = "$(TEST_FCFLAGS)"
+       test "$(FCFLAGS_FOR_BUILD)" = "$(TEST_FCFLAGS_FOR_BUILD)"
        test "$(FFLAGS)" = "$(TEST_FFLAGS)"
+       test "$(FFLAGS_FOR_BUILD)" = "$(TEST_FFLAGS_FOR_BUILD)"
        test "$(LDFLAGS)" = "$(TEST_LDFLAGS)"
+       test "$(LDFLAGS_FOR_BUILD)" = "$(TEST_LDFLAGS_FOR_BUILD)"
        test "$(OBJCFLAGS)" = "$(TEST_OBJCFLAGS)"
+       test "$(OBJCFLAGS_FOR_BUILD)" = "$(TEST_OBJCFLAGS_FOR_BUILD)"
        test "$(OBJCXXFLAGS)" = "$(TEST_OBJCXXFLAGS)"
+       test "$(OBJCXXFLAGS_FOR_BUILD)" = "$(TEST_OBJCXXFLAGS_FOR_BUILD)"

-- 
Dpkg.Org's dpkg

Reply via email to