.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "dpkg-buildflags 1" .TH dpkg-buildflags 1 "2022-09-01" "1.20.12" "dpkg suite" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dpkg\-buildflags \- returns build flags to use during package build .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBdpkg-buildflags\fR [\fIoption\fR...] [\fIcommand\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBdpkg-buildflags\fR is a tool to retrieve compilation flags to use during build of Debian packages. .PP The default flags are defined by the vendor but they can be extended/overridden in several ways: .IP "1." 4 system-wide with \fB/etc/dpkg/buildflags.conf\fR; .IP "2." 4 for the current user with \fB\f(CB$XDG_CONFIG_HOME\fB/dpkg/buildflags.conf\fR where \fB\f(CB$XDG_CONFIG_HOME\fB\fR defaults to \fB\f(CB$HOME\fB/.config\fR; .IP "3." 4 temporarily by the user with environment variables (see section \&\fB\s-1ENVIRONMENT\s0\fR); .IP "4." 4 dynamically by the package maintainer with environment variables set via \&\fBdebian/rules\fR (see section \fB\s-1ENVIRONMENT\s0\fR). .PP The configuration files can contain four types of directives: .IP "\fB\s-1SET\s0\fR \fIflag value\fR" 4 .IX Item "SET flag value" Override the flag named \fIflag\fR to have the value \fIvalue\fR. .IP "\fB\s-1STRIP\s0\fR \fIflag value\fR" 4 .IX Item "STRIP flag value" Strip from the flag named \fIflag\fR all the build flags listed in \fIvalue\fR. .IP "\fB\s-1APPEND\s0\fR \fIflag value\fR" 4 .IX Item "APPEND flag value" Extend the flag named \fIflag\fR by appending the options given in \fIvalue\fR. A space is prepended to the appended value if the flag's current value is non-empty. .IP "\fB\s-1PREPEND\s0\fR \fIflag value\fR" 4 .IX Item "PREPEND flag value" Extend the flag named \fIflag\fR by prepending the options given in \fIvalue\fR. A space is appended to the prepended value if the flag's current value is non-empty. .PP The configuration files can contain comments on lines starting with a hash (#). Empty lines are also ignored. .SH "COMMANDS" .IX Header "COMMANDS" .IP "\fB\-\-dump\fR" 4 .IX Item "--dump" Print to standard output all compilation flags and their values. It prints one flag per line separated from its value by an equal sign (\(lq\fIflag\fR=\fIvalue\fR\(rq). This is the default action. .IP "\fB\-\-list\fR" 4 .IX Item "--list" Print the list of flags supported by the current vendor (one per line). See the \fB\s-1SUPPORTED FLAGS\s0\fR section for more information about them. .IP "\fB\-\-status\fR" 4 .IX Item "--status" Display any information that can be useful to explain the behaviour of \&\fBdpkg-buildflags\fR (since dpkg 1.16.5): relevant environment variables, current vendor, state of all feature flags. Also print the resulting compiler flags with their origin. .Sp This is intended to be run from \fBdebian/rules\fR, so that the build log keeps a clear trace of the build flags used. This can be useful to diagnose problems related to them. .IP "\fB\-\-export=\fR\fIformat\fR" 4 .IX Item "--export=format" Print to standard output commands that can be used to export all the compilation flags for some particular tool. If the \fIformat\fR value is not given, \fBsh\fR is assumed. Only compilation flags starting with an upper case character are included, others are assumed to not be suitable for the environment. Supported formats: .RS 4 .IP "\fBsh\fR" 4 .IX Item "sh" Shell commands to set and export all the compilation flags in the environment. The flag values are quoted so the output is ready for evaluation by a shell. .IP "\fBcmdline\fR" 4 .IX Item "cmdline" Arguments to pass to a build program's command line to use all the compilation flags (since dpkg 1.17.0). The flag values are quoted in shell syntax. .IP "\fBconfigure\fR" 4 .IX Item "configure" This is a legacy alias for \fBcmdline\fR. .IP "\fBmake\fR" 4 .IX Item "make" Make directives to set and export all the compilation flags in the environment. Output can be written to a Makefile fragment and evaluated using an \fBinclude\fR directive. .RE .RS 4 .RE .IP "\fB\-\-get\fR \fIflag\fR" 4 .IX Item "--get flag" Print the value of the flag on standard output. Exits with 0 if the flag is known otherwise exits with 1. .IP "\fB\-\-origin\fR \fIflag\fR" 4 .IX Item "--origin flag" Print the origin of the value that is returned by \fB\-\-get\fR. Exits with 0 if the flag is known otherwise exits with 1. The origin can be one of the following values: .RS 4 .IP "\fBvendor\fR" 4 .IX Item "vendor" the original flag set by the vendor is returned; .IP "\fBsystem\fR" 4 .IX Item "system" the flag is set/modified by a system-wide configuration; .IP "\fBuser\fR" 4 .IX Item "user" the flag is set/modified by a user-specific configuration; .IP "\fBenv\fR" 4 .IX Item "env" the flag is set/modified by an environment-specific configuration. .RE .RS 4 .RE .IP "\fB\-\-query\fR" 4 .IX Item "--query" Print any information that can be useful to explain the behaviour of the program: current vendor, relevant environment variables, feature areas, state of all feature flags, and the compiler flags with their origin (since dpkg 1.19.0). .Sp For example: .Sp .Vb 3 \& Vendor: Debian \& Environment: \& DEB_CFLAGS_SET=\-O0 \-Wall \& \& Area: qa \& Features: \& bug=no \& canary=no \& \& Area: reproducible \& Features: \& timeless=no \& \& Flag: CFLAGS \& Value: \-O0 \-Wall \& Origin: env \& \& Flag: CPPFLAGS \& Value: \-D_FORTIFY_SOURCE=2 \& Origin: vendor .Ve .IP "\fB\-\-query\-features\fR \fIarea\fR" 4 .IX Item "--query-features area" Print the features enabled for a given area (since dpkg 1.16.2). The only currently recognized areas on Debian and derivatives are \fBfuture\fR, \fBqa\fR, \fBreproducible\fR, \&\fBsanitize\fR and \fBhardening\fR, see the \fB\s-1FEATURE AREAS\s0\fR section for more details. Exits with 0 if the area is known otherwise exits with 1. .Sp The output is in \s-1RFC822\s0 format, with one section per feature. For example: .Sp .Vb 2 \& Feature: pie \& Enabled: yes \& \& Feature: stackprotector \& Enabled: yes .Ve .IP "\fB\-\-help\fR" 4 .IX Item "--help" Show the usage message and exit. .IP "\fB\-\-version\fR" 4 .IX Item "--version" Show the version and exit. .SH "SUPPORTED FLAGS" .IX Header "SUPPORTED FLAGS" .IP "\fB\s-1CFLAGS\s0\fR" 4 .IX Item "CFLAGS" Options for the C compiler. The default value set by the vendor includes \fB\-g\fR and the default optimization level (\fB\-O2\fR usually, or \fB\-O0\fR if the \fB\s-1DEB_BUILD_OPTIONS\s0\fR environment variable defines \&\fInoopt\fR). .IP "\fB\s-1CPPFLAGS\s0\fR" 4 .IX Item "CPPFLAGS" Options for the C preprocessor. Default value: empty. .IP "\fB\s-1CXXFLAGS\s0\fR" 4 .IX Item "CXXFLAGS" Options for the \*(C+ compiler. Same as \fB\s-1CFLAGS\s0\fR. .IP "\fB\s-1OBJCFLAGS\s0\fR" 4 .IX Item "OBJCFLAGS" Options for the Objective C compiler. Same as \fB\s-1CFLAGS\s0\fR. .IP "\fB\s-1OBJCXXFLAGS\s0\fR" 4 .IX Item "OBJCXXFLAGS" Options for the Objective \*(C+ compiler. Same as \fB\s-1CXXFLAGS\s0\fR. .IP "\fB\s-1GCJFLAGS\s0\fR" 4 .IX Item "GCJFLAGS" Options for the \s-1GNU\s0 Java compiler (gcj). A subset of \fB\s-1CFLAGS\s0\fR. .IP "\fB\s-1DFLAGS\s0\fR" 4 .IX Item "DFLAGS" Options for the D compiler (ldc or gdc). Since dpkg 1.20.6. .IP "\fB\s-1FFLAGS\s0\fR" 4 .IX Item "FFLAGS" Options for the Fortran 77 compiler. A subset of \fB\s-1CFLAGS\s0\fR. .IP "\fB\s-1FCFLAGS\s0\fR" 4 .IX Item "FCFLAGS" Options for the Fortran 9x compiler. Same as \fB\s-1FFLAGS\s0\fR. .IP "\fB\s-1LDFLAGS\s0\fR" 4 .IX Item "LDFLAGS" Options passed to the compiler when linking executables or shared objects (if the linker is called directly, then \&\fB\-Wl\fR and \&\fB,\fR have to be stripped from these options). Default value: empty. .PP New flags might be added in the future if the need arises (for example to support other languages). .SH "FEATURE AREAS" .IX Header "FEATURE AREAS" Each area feature can be enabled and disabled in the \fB\s-1DEB_BUILD_OPTIONS\s0\fR and \fB\s-1DEB_BUILD_MAINT_OPTIONS\s0\fR environment variable's area value with the \(oq\fB+\fR\(cq and \(oq\fB\-\fR\(cq modifier. For example, to enable the \fBhardening\fR \(lqpie\(rq feature and disable the \(lqfortify\(rq feature you can do this in \fBdebian/rules\fR: .PP .Vb 1 \& export DEB_BUILD_MAINT_OPTIONS=hardening=+pie,\-fortify .Ve .PP The special feature \fBall\fR (valid in any area) can be used to enable or disable all area features at the same time. Thus disabling everything in the \fBhardening\fR area and enabling only \(lqformat\(rq and \(lqfortify\(rq can be achieved with: .PP .Vb 1 \& export DEB_BUILD_MAINT_OPTIONS=hardening=\-all,+format,+fortify .Ve .SS "future" .IX Subsection "future" Several compile-time options (detailed below) can be used to enable features that should be enabled by default, but cannot due to backwards compatibility reasons. .IP "\fBlfs\fR" 4 .IX Item "lfs" This setting (disabled by default) enables Large File Support on 32\-bit architectures where their \s-1ABI\s0 does not include \s-1LFS\s0 by default, by adding \&\fB\-D_LARGEFILE_SOURCE \-D_FILE_OFFSET_BITS=64\fR to \fB\s-1CPPFLAGS\s0\fR. .SS "qa" .IX Subsection "qa" Several compile-time options (detailed below) can be used to help detect problems in the source code or build system. .IP "\fBbug\fR" 4 .IX Item "bug" This setting (disabled by default) adds any warning option that reliably detects problematic source code. The warnings are fatal. The only currently supported flags are \fB\s-1CFLAGS\s0\fR and \fB\s-1CXXFLAGS\s0\fR with flags set to \fB\-Werror=array\-bounds\fR, \fB\-Werror=clobbered\fR, \&\fB\-Werror=implicit\-function\-declaration\fR and \&\fB\-Werror=volatile\-register\-var\fR. .IP "\fBcanary\fR" 4 .IX Item "canary" This setting (disabled by default) adds dummy canary options to the build flags, so that the build logs can be checked for how the build flags propagate and to allow finding any omission of normal build flag settings. The only currently supported flags are \fB\s-1CPPFLAGS\s0\fR, \fB\s-1CFLAGS\s0\fR, \&\fB\s-1OBJCFLAGS\s0\fR, \fB\s-1CXXFLAGS\s0\fR and \fB\s-1OBJCXXFLAGS\s0\fR with flags set to \fB\-D_\|_DEB_CANARY_\fR\fIflag\fR_\fIrandom-id\fR\fB_\|_\fR, and \&\fB\s-1LDFLAGS\s0\fR set to \fB\-Wl,\-z,deb\-canary\-\fR\fIrandom-id\fR. .SS "sanitize" .IX Subsection "sanitize" Several compile-time options (detailed below) can be used to help sanitize a resulting binary against memory corruptions, memory leaks, use after free, threading data races and undefined behavior bugs. \&\fBNote\fR: these options should \fBnot\fR be used for production builds as they can reduce reliability for conformant code, reduce security or even functionality. .IP "\fBaddress\fR" 4 .IX Item "address" This setting (disabled by default) adds \fB\-fsanitize=address\fR to \&\fB\s-1LDFLAGS\s0\fR and \fB\-fsanitize=address \-fno\-omit\-frame\-pointer\fR to \&\fB\s-1CFLAGS\s0\fR and \fB\s-1CXXFLAGS\s0\fR. .IP "\fBthread\fR" 4 .IX Item "thread" This setting (disabled by default) adds \fB\-fsanitize=thread\fR to \&\fB\s-1CFLAGS\s0\fR, \fB\s-1CXXFLAGS\s0\fR and \fB\s-1LDFLAGS\s0\fR. .IP "\fBleak\fR" 4 .IX Item "leak" This setting (disabled by default) adds \fB\-fsanitize=leak\fR to \&\fB\s-1LDFLAGS\s0\fR. It gets automatically disabled if either the \fBaddress\fR or the \fBthread\fR features are enabled, as they imply it. .IP "\fBundefined\fR" 4 .IX Item "undefined" This setting (disabled by default) adds \fB\-fsanitize=undefined\fR to \&\fB\s-1CFLAGS\s0\fR, \fB\s-1CXXFLAGS\s0\fR and \fB\s-1LDFLAGS\s0\fR. .SS "hardening" .IX Subsection "hardening" Several compile-time options (detailed below) can be used to help harden a resulting binary against memory corruption attacks, or provide additional warning messages during compilation. Except as noted below, these are enabled by default for architectures that support them. .IP "\fBformat\fR" 4 .IX Item "format" This setting (enabled by default) adds \&\fB\-Wformat \-Werror=format\-security\fR to \fB\s-1CFLAGS\s0\fR, \fB\s-1CXXFLAGS\s0\fR, \fB\s-1OBJCFLAGS\s0\fR and \fB\s-1OBJCXXFLAGS\s0\fR. This will warn about improper format string uses, and will fail when format functions are used in a way that represent possible security problems. At present, this warns about calls to \fBprintf\fR and \fBscanf\fR functions where the format string is not a string literal and there are no format arguments, as in \&\fBprintf(foo);\fR instead of \fBprintf(\*(L"%s\*(R", foo);\fR This may be a security hole if the format string came from untrusted input and contains \(oq%n\(cq. .IP "\fBfortify\fR" 4 .IX Item "fortify" This setting (enabled by default) adds \&\fB\-D_FORTIFY_SOURCE=2\fR to \fB\s-1CPPFLAGS\s0\fR. During code generation the compiler knows a great deal of information about buffer sizes (where possible), and attempts to replace insecure unlimited length buffer function calls with length-limited ones. This is especially useful for old, crufty code. Additionally, format strings in writable memory that contain \(oq%n\(cq are blocked. If an application depends on such a format string, it will need to be worked around. .Sp Note that for this option to have any effect, the source must also be compiled with \fB\-O1\fR or higher. If the environment variable \&\fB\s-1DEB_BUILD_OPTIONS\s0\fR contains \fInoopt\fR, then \fBfortify\fR support will be disabled, due to new warnings being issued by glibc 2.16 and later. .IP "\fBstackprotector\fR" 4 .IX Item "stackprotector" This setting (enabled by default if stackprotectorstrong is not in use) adds \&\fB\-fstack\-protector \-\-param=ssp\-buffer\-size=4\fR to \fB\s-1CFLAGS\s0\fR, \fB\s-1CXXFLAGS\s0\fR, \fB\s-1OBJCFLAGS\s0\fR, \fB\s-1OBJCXXFLAGS\s0\fR, \&\fB\s-1GCJFLAGS\s0\fR, \fB\s-1FFLAGS\s0\fR and \fB\s-1FCFLAGS\s0\fR. This adds safety checks against stack overwrites. This renders many potential code injection attacks into aborting situations. In the best case this turns code injection vulnerabilities into denial of service or into non-issues (depending on the application). .Sp This feature requires linking against glibc (or another provider of \&\fB_\|_stack_chk_fail\fR), so needs to be disabled when building with \&\fB\-nostdlib\fR or \fB\-ffreestanding\fR or similar. .IP "\fBstackprotectorstrong\fR" 4 .IX Item "stackprotectorstrong" This setting (enabled by default) adds \&\fB\-fstack\-protector\-strong\fR to \fB\s-1CFLAGS\s0\fR, \fB\s-1CXXFLAGS\s0\fR, \fB\s-1OBJCFLAGS\s0\fR, \fB\s-1OBJCXXFLAGS\s0\fR, \&\fB\s-1GCJFLAGS\s0\fR, \fB\s-1FFLAGS\s0\fR and \fB\s-1FCFLAGS\s0\fR. This is a stronger variant of \fBstackprotector\fR, but without significant performance penalties. .Sp Disabling \fBstackprotector\fR will also disable this setting. .Sp This feature has the same requirements as \fBstackprotector\fR, and in addition also requires gcc 4.9 and later. .IP "\fBrelro\fR" 4 .IX Item "relro" This setting (enabled by default) adds \&\fB\-Wl,\-z,relro\fR to \fB\s-1LDFLAGS\s0\fR. During program load, several \s-1ELF\s0 memory sections need to be written to by the linker. This flags the loader to turn these sections read-only before turning over control to the program. Most notably this prevents \s-1GOT\s0 overwrite attacks. If this option is disabled, \&\fBbindnow\fR will become disabled as well. .IP "\fBbindnow\fR" 4 .IX Item "bindnow" This setting (disabled by default) adds \&\fB\-Wl,\-z,now\fR to \fB\s-1LDFLAGS\s0\fR. During program load, all dynamic symbols are resolved, allowing for the entire \s-1PLT\s0 to be marked read-only (due to \fBrelro\fR above). The option cannot become enabled if \fBrelro\fR is not enabled. .IP "\fBpie\fR" 4 .IX Item "pie" This setting (with no global default since dpkg 1.18.23, as it is enabled by default now by gcc on the amd64, arm64, armel, armhf, hurd\-i386, i386, kfreebsd\-amd64, kfreebsd\-i386, mips, mipsel, mips64el, powerpc, ppc64, ppc64el, riscv64, s390x, sparc and sparc64 Debian architectures) adds the required options to enable or disable \s-1PIE\s0 via gcc specs files, if needed, depending on whether gcc injects on that architecture the flags by itself or not. When the setting is enabled and gcc injects the flags, it adds nothing. When the setting is enabled and gcc does not inject the flags, it adds \&\fB\-fPIE\fR (via \fI/usr/share/dpkg/pie\-compiler.specs\fR) to \fB\s-1CFLAGS\s0\fR, \&\fB\s-1CXXFLAGS\s0\fR, \fB\s-1OBJCFLAGS\s0\fR, \fB\s-1OBJCXXFLAGS\s0\fR, \fB\s-1GCJFLAGS\s0\fR, \&\fB\s-1FFLAGS\s0\fR and \fB\s-1FCFLAGS\s0\fR, and \&\fB\-fPIE \-pie\fR (via \fI/usr/share/dpkg/pie\-link.specs\fR) to \fB\s-1LDFLAGS\s0\fR. When the setting is disabled and gcc injects the flags, it adds \&\fB\-fno\-PIE\fR (via \fI/usr/share/dpkg/no\-pie\-compile.specs\fR) to \fB\s-1CFLAGS\s0\fR, \&\fB\s-1CXXFLAGS\s0\fR, \fB\s-1OBJCFLAGS\s0\fR, \fB\s-1OBJCXXFLAGS\s0\fR, \fB\s-1GCJFLAGS\s0\fR, \&\fB\s-1FFLAGS\s0\fR and \fB\s-1FCFLAGS\s0\fR, and \&\fB\-fno\-PIE \-no\-pie\fR (via \fI/usr/share/dpkg/no\-pie\-link.specs\fR) to \&\fB\s-1LDFLAGS\s0\fR. .Sp Position Independent Executable are needed to take advantage of Address Space Layout Randomization, supported by some kernel versions. While \s-1ASLR\s0 can already be enforced for data areas in the stack and heap (brk and mmap), the code areas must be compiled as position-independent. Shared libraries already do this (\fB\-fPIC\fR), so they gain \s-1ASLR\s0 automatically, but binary .text regions need to be build \s-1PIE\s0 to gain \s-1ASLR.\s0 When this happens, \s-1ROP\s0 (Return Oriented Programming) attacks are much harder since there are no static locations to bounce off of during a memory corruption attack. .Sp \&\s-1PIE\s0 is not compatible with \fB\-fPIC\fR, so in general care must be taken when building shared objects. But because the \s-1PIE\s0 flags emitted get injected via gcc specs files, it should always be safe to unconditionally set them regardless of the object type being compiled or linked. .Sp Static libraries can be used by programs or other shared libraries. Depending on the flags used to compile all the objects within a static library, these libraries will be usable by different sets of objects: .RS 4 .IP "none" 4 .IX Item "none" Cannot be linked into a \s-1PIE\s0 program, nor a shared library. .IP "\fB\-fPIE\fR" 4 .IX Item "-fPIE" Can be linked into any program, but not a shared library (recommended). .IP "\fB\-fPIC\fR" 4 .IX Item "-fPIC" Can be linked into any program and shared library. .RE .RS 4 .Sp If there is a need to set these flags manually, bypassing the gcc specs injection, there are several things to take into account. Unconditionally and explicitly passing \fB\-fPIE\fR, \fB\-fpie\fR or \fB\-pie\fR to a build-system using libtool is safe as these flags will get stripped when building shared libraries. Otherwise on projects that build both programs and shared libraries you might need to make sure that when building the shared libraries \fB\-fPIC\fR is always passed last (so that it overrides any previous \fB\-PIE\fR) to compilation flags such as \fB\s-1CFLAGS\s0\fR, and \fB\-shared\fR is passed last (so that it overrides any previous \fB\-pie\fR) to linking flags such as \&\fB\s-1LDFLAGS\s0\fR. \fBNote:\fR This should not be needed with the default gcc specs machinery. .Sp Additionally, since \s-1PIE\s0 is implemented via a general register, some register starved architectures (but not including i386 anymore since optimizations implemented in gcc >= 5) can see performance losses of up to 15% in very text-segment-heavy application workloads; most workloads see less than 1%. Architectures with more general registers (e.g. amd64) do not see as high a worst-case penalty. .RE .SS "reproducible" .IX Subsection "reproducible" The compile-time options detailed below can be used to help improve build reproducibility or provide additional warning messages during compilation. Except as noted below, these are enabled by default for architectures that support them. .IP "\fBtimeless\fR" 4 .IX Item "timeless" This setting (enabled by default) adds \&\fB\-Wdate\-time\fR to \fB\s-1CPPFLAGS\s0\fR. This will cause warnings when the \fB_\|_TIME_\|_\fR, \fB_\|_DATE_\|_\fR and \&\fB_\|_TIMESTAMP_\|_\fR macros are used. .IP "\fBfixfilepath\fR" 4 .IX Item "fixfilepath" This setting (enabled by default) adds \&\fB\-ffile\-prefix\-map=\fR\fI\s-1BUILDPATH\s0\fR\fB=.\fR to \fB\s-1CFLAGS\s0\fR, \fB\s-1CXXFLAGS\s0\fR, \fB\s-1OBJCFLAGS\s0\fR, \fB\s-1OBJCXXFLAGS\s0\fR, \&\fB\s-1GCJFLAGS\s0\fR, \fB\s-1FFLAGS\s0\fR and \fB\s-1FCFLAGS\s0\fR where \fB\s-1BUILDPATH\s0\fR is set to the top-level directory of the package being built. This has the effect of removing the build path from any generated file. .Sp If both \fBfixdebugpath\fR and \fBfixfilepath\fR are set, this option takes precedence, because it is a superset of the former. .IP "\fBfixdebugpath\fR" 4 .IX Item "fixdebugpath" This setting (enabled by default) adds \&\fB\-fdebug\-prefix\-map=\fR\fI\s-1BUILDPATH\s0\fR\fB=.\fR to \fB\s-1CFLAGS\s0\fR, \fB\s-1CXXFLAGS\s0\fR, \fB\s-1OBJCFLAGS\s0\fR, \fB\s-1OBJCXXFLAGS\s0\fR, \&\fB\s-1GCJFLAGS\s0\fR, \fB\s-1FFLAGS\s0\fR and \fB\s-1FCFLAGS\s0\fR where \fB\s-1BUILDPATH\s0\fR is set to the top-level directory of the package being built. This has the effect of removing the build path from any generated debug symbols. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" There are 2 sets of environment variables doing the same operations, the first one (\s-1DEB_\s0\fIflag\fR_\fIop\fR) should never be used within \&\fBdebian/rules\fR. It's meant for any user that wants to rebuild the source package with different build flags. The second set (\s-1DEB_\s0\fIflag\fR_MAINT_\fIop\fR) should only be used in \fBdebian/rules\fR by package maintainers to change the resulting build flags. .IP "\fB\s-1DEB_\s0\fR\fIflag\fR\fB_SET\fR" 4 .IX Item "DEB_flag_SET" .PD 0 .IP "\fB\s-1DEB_\s0\fR\fIflag\fR\fB_MAINT_SET\fR" 4 .IX Item "DEB_flag_MAINT_SET" .PD This variable can be used to force the value returned for the given \&\fIflag\fR. .IP "\fB\s-1DEB_\s0\fR\fIflag\fR\fB_STRIP\fR" 4 .IX Item "DEB_flag_STRIP" .PD 0 .IP "\fB\s-1DEB_\s0\fR\fIflag\fR\fB_MAINT_STRIP\fR" 4 .IX Item "DEB_flag_MAINT_STRIP" .PD This variable can be used to provide a space separated list of options that will be stripped from the set of flags returned for the given \&\fIflag\fR. .IP "\fB\s-1DEB_\s0\fR\fIflag\fR\fB_APPEND\fR" 4 .IX Item "DEB_flag_APPEND" .PD 0 .IP "\fB\s-1DEB_\s0\fR\fIflag\fR\fB_MAINT_APPEND\fR" 4 .IX Item "DEB_flag_MAINT_APPEND" .PD This variable can be used to append supplementary options to the value returned for the given \fIflag\fR. .IP "\fB\s-1DEB_\s0\fR\fIflag\fR\fB_PREPEND\fR" 4 .IX Item "DEB_flag_PREPEND" .PD 0 .IP "\fB\s-1DEB_\s0\fR\fIflag\fR\fB_MAINT_PREPEND\fR" 4 .IX Item "DEB_flag_MAINT_PREPEND" .PD This variable can be used to prepend supplementary options to the value returned for the given \fIflag\fR. .IP "\fB\s-1DEB_BUILD_OPTIONS\s0\fR" 4 .IX Item "DEB_BUILD_OPTIONS" .PD 0 .IP "\fB\s-1DEB_BUILD_MAINT_OPTIONS\s0\fR" 4 .IX Item "DEB_BUILD_MAINT_OPTIONS" .PD These variables can be used by a user or maintainer to disable/enable various area features that affect build flags. The \fB\s-1DEB_BUILD_MAINT_OPTIONS\s0\fR variable overrides any setting in the \&\fB\s-1DEB_BUILD_OPTIONS\s0\fR feature areas. See the \fB\s-1FEATURE AREAS\s0\fR section for details. .IP "\fB\s-1DEB_VENDOR\s0\fR" 4 .IX Item "DEB_VENDOR" This setting defines the current vendor. If not set, it will discover the current vendor by reading \&\fB/etc/dpkg/origins/default\fR. .IP "\fB\s-1DEB_BUILD_PATH\s0\fR" 4 .IX Item "DEB_BUILD_PATH" This variable sets the build path (since dpkg 1.18.8) to use in features such as \fBfixdebugpath\fR so that they can be controlled by the caller. This variable is currently Debian and derivatives-specific. .IP "\fB\s-1DPKG_COLORS\s0\fR" 4 .IX Item "DPKG_COLORS" Sets the color mode (since dpkg 1.18.5). The currently accepted values are: \fBauto\fR (default), \fBalways\fR and \&\fBnever\fR. .IP "\fB\s-1DPKG_NLS\s0\fR" 4 .IX Item "DPKG_NLS" If set, it will be used to decide whether to activate Native Language Support, also known as internationalization (or i18n) support (since dpkg 1.19.0). The accepted values are: \fB0\fR and \fB1\fR (default). .SH "FILES" .IX Header "FILES" .SS "Configuration files" .IX Subsection "Configuration files" .IP "\fB/etc/dpkg/buildflags.conf\fR" 4 .IX Item "/etc/dpkg/buildflags.conf" System wide configuration file. .IP "\fB\f(CB$XDG_CONFIG_HOME\fB/dpkg/buildflags.conf\fR or" 4 .IX Item "$XDG_CONFIG_HOME/dpkg/buildflags.conf or" .PD 0 .IP "\fB\f(CB$HOME\fB/.config/dpkg/buildflags.conf\fR" 4 .IX Item "$HOME/.config/dpkg/buildflags.conf" .PD User configuration file. .SS "Packaging support" .IX Subsection "Packaging support" .IP "\fB/usr/share/dpkg/buildflags.mk\fR" 4 .IX Item "/usr/share/dpkg/buildflags.mk" Makefile snippet that will load (and optionally export) all flags supported by \fBdpkg-buildflags\fR into variables (since dpkg 1.16.1). .SH "EXAMPLES" .IX Header "EXAMPLES" To pass build flags to a build command in a Makefile: .Sp .Vb 1 \& $(MAKE) $(shell dpkg\-buildflags \-\-export=cmdline) \& \& ./configure $(shell dpkg\-buildflags \-\-export=cmdline) .Ve .PP To set build flags in a shell script or shell fragment, \fBeval\fR can be used to interpret the output and to export the flags in the environment: .Sp .Vb 1 \& eval "$(dpkg\-buildflags \-\-export=sh)" && make .Ve .PP or to set the positional parameters to pass to a command: .Sp .Vb 2 \& eval "set \-\- $(dpkg\-buildflags \-\-export=cmdline)" \& for dir in a b c; do (cd $dir && ./configure "$@" && make); done .Ve .SS "Usage in debian/rules" .IX Subsection "Usage in debian/rules" You should call \fBdpkg-buildflags\fR or include \fBbuildflags.mk\fR from the \fBdebian/rules\fR file to obtain the needed build flags to pass to the build system. Note that older versions of \fBdpkg-buildpackage\fR (before dpkg 1.16.1) exported these flags automatically. However, you should not rely on this, since this breaks manual invocation of \fBdebian/rules\fR. .PP For packages with autoconf-like build systems, you can pass the relevant options to configure or \fBmake\fR(1) directly, as shown above. .PP For other build systems, or when you need more fine-grained control about which flags are passed where, you can use \fB\-\-get\fR. Or you can include \fBbuildflags.mk\fR instead, which takes care of calling \&\fBdpkg-buildflags\fR and storing the build flags in make variables. .PP If you want to export all buildflags into the environment (where they can be picked up by your build system): .Sp .Vb 2 \& DPKG_EXPORT_BUILDFLAGS = 1 \& include /usr/share/dpkg/buildflags.mk .Ve .PP For some extra control over what is exported, you can manually export the variables (as none are exported by default): .Sp .Vb 2 \& include /usr/share/dpkg/buildflags.mk \& export CPPFLAGS CFLAGS LDFLAGS .Ve .PP And you can of course pass the flags to commands manually: .Sp .Vb 3 \& include /usr/share/dpkg/buildflags.mk \& build\-arch: \& $(CC) \-o hello hello.c $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .Ve