[pacman-dev] [PATCH] makepkg: add rust support for *FLAGS and debug-prefix-map
The rust language supports $RUSTFLAGS to be used automatically in all rustc invocations. Allow setting this in makepkg.conf (e.g. for optimization or debuginfo support), and teach debug+strip to pass the rustc command line argument necessary to rewrite source file paths in the debugging symbols. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- doc/makepkg.conf.5.asciidoc | 9 +++++++++ etc/makepkg.conf.in | 2 ++ scripts/libmakepkg/buildenv.sh.in | 2 +- scripts/libmakepkg/buildenv/buildflags.sh.in | 2 +- scripts/libmakepkg/buildenv/debugflags.sh.in | 2 ++ scripts/libmakepkg/lint_config/variable.sh.in | 8 ++++---- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/doc/makepkg.conf.5.asciidoc b/doc/makepkg.conf.5.asciidoc index 9292b2a6..3f37190d 100644 --- a/doc/makepkg.conf.5.asciidoc +++ b/doc/makepkg.conf.5.asciidoc @@ -72,6 +72,10 @@ Options **CXXFLAGS=**"cxxflags":: Flags used for the C++ compiler; see CFLAGS for more info. +**RUSTFLAGS=**"rustflags":: + Flags used for the Rust compiler, similar in spirit to CFLAGS. Read + linkman:rustc[1] for more details on the available flags. + **LDFLAGS=**"ldflags":: Flags used for the linker. Several options may be specified with common usage resembling ``-Wl,--hash-style=gnu''. Read ld(1) for more details on @@ -89,6 +93,11 @@ Options **DEBUG_CXXFLAGS=**"debug_cxxflags":: Debug flags used for the C++ compiler; see DEBUG_CFLAGS for more info. +**DEBUG_RUSTFLAGS=**"debug_rustflags":: + Additional compiler flags appended to `RUSTFLAGS` for use in debugging. + Usually this would include: ``-C debuginfo=2''. Read linkman:rustc[1] for + more details on the available flags. + **BUILDENV=(**!distcc !color !ccache check !sign**)**:: This array contains options that affect the build environment; the defaults are shown here. All options should always be left in the array; to enable diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 7e5da993..caf5114b 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -40,11 +40,13 @@ CHOST="@CHOST@" #CFLAGS="-O2 -pipe" #CXXFLAGS="-O2 -pipe" #LDFLAGS="" +#RUSTFLAGS="-C opt-level=2" #-- Make Flags: change this for DistCC/SMP systems #MAKEFLAGS="-j2" #-- Debugging flags #DEBUG_CFLAGS="-g" #DEBUG_CXXFLAGS="-g" +#DEBUG_RUSTFLAGS="-C debuginfo=2" ######################################################################### # BUILD ENVIRONMENT diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index a8d416c8..2ecd741e 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -36,5 +36,5 @@ prepare_buildenv() { done # ensure all necessary build variables are exported - export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS RUSTFLAGS MAKEFLAGS CHOST } diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index daccc9cc..871d0d69 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -30,6 +30,6 @@ buildenv_functions+=('buildenv_buildflags') buildenv_buildflags() { if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS + unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS RUSTFLAGS fi } diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in index ce9c1556..19c96700 100644 --- a/scripts/libmakepkg/buildenv/debugflags.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -32,7 +32,9 @@ buildenv_debugflags() { if check_option "debug" "y"; then DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srdir=${DBGSRCDIR:-/usr/src/debug}" CFLAGS+=" $DEBUG_CFLAGS" CXXFLAGS+=" $DEBUG_CXXFLAGS" + RUSTFLAGS+=" $DEBUG_RUSTFLAGS" fi } diff --git a/scripts/libmakepkg/lint_config/variable.sh.in b/scripts/libmakepkg/lint_config/variable.sh.in index 55ed6d6d..e73e13de 100644 --- a/scripts/libmakepkg/lint_config/variable.sh.in +++ b/scripts/libmakepkg/lint_config/variable.sh.in @@ -32,10 +32,10 @@ lint_config_variables() { local array=(DLAGENTS VCSCLIENTS BUILDENV OPTIONS INTEGRITY_CHECK MAN_DIRS DOC_DIRS PURGE_TARGETS COMPRESSGZ COMPRESSBZ2 COMPRESSXZ COMPRESSLRZ COMPRESSLZO COMPRESSZ) - local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS LDFLAGS DEBUG_CFLAGS - DEBUG_CXXFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES STRIP_SHARED - STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER GPGKEY - PKGEXT SRCEXT) + local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS RUSTFLAGS LDFLAGS DEBUG_CFLAGS + DEBUG_CXXFLAGS DEBUG_RUSTFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES + STRIP_SHARED STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER + GPGKEY PKGEXT SRCEXT) local i keys ret=0 -- 2.22.0
On 4/7/19 7:40 am, Eli Schwartz wrote:
The rust language supports $RUSTFLAGS to be used automatically in all rustc invocations. Allow setting this in makepkg.conf (e.g. for optimization or debuginfo support), and teach debug+strip to pass the rustc command line argument necessary to rewrite source file paths in the debugging symbols.
I'm happy to include this. But it brings me back to the concern of an ever expanding makepkg.conf (no longer just compression variables!). What about adding a system like: /etc/makepkg.conf /etc/makepkg.conf.d/rust Still need to plug the logic to use them in, but should be possible with libmakepkg...
diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index daccc9cc..871d0d69 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -30,6 +30,6 @@ buildenv_functions+=('buildenv_buildflags')
buildenv_buildflags() { if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS + unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS RUSTFLAGS
DEBUG_RUSTFLAGS
fi }
The rust language supports $RUSTFLAGS to be used automatically in all rustc invocations. Allow setting this in makepkg.conf (e.g. for optimization or debuginfo support), and teach debug+strip to pass the rustc command line argument necessary to rewrite source file paths in the debugging symbols. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- v2: add forgotten DEBUG_ variant to be unset doc/makepkg.conf.5.asciidoc | 9 +++++++++ etc/makepkg.conf.in | 2 ++ scripts/libmakepkg/buildenv.sh.in | 2 +- scripts/libmakepkg/buildenv/buildflags.sh.in | 2 +- scripts/libmakepkg/buildenv/debugflags.sh.in | 2 ++ scripts/libmakepkg/lint_config/variable.sh.in | 8 ++++---- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/doc/makepkg.conf.5.asciidoc b/doc/makepkg.conf.5.asciidoc index 9292b2a6..3f37190d 100644 --- a/doc/makepkg.conf.5.asciidoc +++ b/doc/makepkg.conf.5.asciidoc @@ -72,6 +72,10 @@ Options **CXXFLAGS=**"cxxflags":: Flags used for the C++ compiler; see CFLAGS for more info. +**RUSTFLAGS=**"rustflags":: + Flags used for the Rust compiler, similar in spirit to CFLAGS. Read + linkman:rustc[1] for more details on the available flags. + **LDFLAGS=**"ldflags":: Flags used for the linker. Several options may be specified with common usage resembling ``-Wl,--hash-style=gnu''. Read ld(1) for more details on @@ -89,6 +93,11 @@ Options **DEBUG_CXXFLAGS=**"debug_cxxflags":: Debug flags used for the C++ compiler; see DEBUG_CFLAGS for more info. +**DEBUG_RUSTFLAGS=**"debug_rustflags":: + Additional compiler flags appended to `RUSTFLAGS` for use in debugging. + Usually this would include: ``-C debuginfo=2''. Read linkman:rustc[1] for + more details on the available flags. + **BUILDENV=(**!distcc !color !ccache check !sign**)**:: This array contains options that affect the build environment; the defaults are shown here. All options should always be left in the array; to enable diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 7e5da993..caf5114b 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -40,11 +40,13 @@ CHOST="@CHOST@" #CFLAGS="-O2 -pipe" #CXXFLAGS="-O2 -pipe" #LDFLAGS="" +#RUSTFLAGS="-C opt-level=2" #-- Make Flags: change this for DistCC/SMP systems #MAKEFLAGS="-j2" #-- Debugging flags #DEBUG_CFLAGS="-g" #DEBUG_CXXFLAGS="-g" +#DEBUG_RUSTFLAGS="-C debuginfo=2" ######################################################################### # BUILD ENVIRONMENT diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index a8d416c8..2ecd741e 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -36,5 +36,5 @@ prepare_buildenv() { done # ensure all necessary build variables are exported - export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS RUSTFLAGS MAKEFLAGS CHOST } diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index daccc9cc..85ee80fc 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -30,6 +30,6 @@ buildenv_functions+=('buildenv_buildflags') buildenv_buildflags() { if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS + unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS RUSTFLAGS DEBUG_RUSTFLAGS fi } diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in index ce9c1556..19c96700 100644 --- a/scripts/libmakepkg/buildenv/debugflags.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -32,7 +32,9 @@ buildenv_debugflags() { if check_option "debug" "y"; then DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srdir=${DBGSRCDIR:-/usr/src/debug}" CFLAGS+=" $DEBUG_CFLAGS" CXXFLAGS+=" $DEBUG_CXXFLAGS" + RUSTFLAGS+=" $DEBUG_RUSTFLAGS" fi } diff --git a/scripts/libmakepkg/lint_config/variable.sh.in b/scripts/libmakepkg/lint_config/variable.sh.in index 55ed6d6d..e73e13de 100644 --- a/scripts/libmakepkg/lint_config/variable.sh.in +++ b/scripts/libmakepkg/lint_config/variable.sh.in @@ -32,10 +32,10 @@ lint_config_variables() { local array=(DLAGENTS VCSCLIENTS BUILDENV OPTIONS INTEGRITY_CHECK MAN_DIRS DOC_DIRS PURGE_TARGETS COMPRESSGZ COMPRESSBZ2 COMPRESSXZ COMPRESSLRZ COMPRESSLZO COMPRESSZ) - local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS LDFLAGS DEBUG_CFLAGS - DEBUG_CXXFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES STRIP_SHARED - STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER GPGKEY - PKGEXT SRCEXT) + local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS RUSTFLAGS LDFLAGS DEBUG_CFLAGS + DEBUG_CXXFLAGS DEBUG_RUSTFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES + STRIP_SHARED STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER + GPGKEY PKGEXT SRCEXT) local i keys ret=0 -- 2.22.0
On Mon, Aug 12, 2019 at 12:07:59AM -0400, Eli Schwartz wrote:
index ce9c1556..19c96700 100644 --- a/scripts/libmakepkg/buildenv/debugflags.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -32,7 +32,9 @@ buildenv_debugflags() { if check_option "debug" "y"; then DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srdir=${DBGSRCDIR:-/usr/src/debug}"
$srdir should be $srcdir -- Morten Linderud PGP: 9C02FF419FECBE16
The rust language supports $RUSTFLAGS to be used automatically in all rustc invocations. Allow setting this in makepkg.conf (e.g. for optimization or debuginfo support), and teach debug+strip to pass the rustc command line argument necessary to rewrite source file paths in the debugging symbols. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- v3: fix typo, srdir -> srcdir doc/makepkg.conf.5.asciidoc | 9 +++++++++ etc/makepkg.conf.in | 2 ++ scripts/libmakepkg/buildenv.sh.in | 2 +- scripts/libmakepkg/buildenv/buildflags.sh.in | 2 +- scripts/libmakepkg/buildenv/debugflags.sh.in | 2 ++ scripts/libmakepkg/lint_config/variable.sh.in | 8 ++++---- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/doc/makepkg.conf.5.asciidoc b/doc/makepkg.conf.5.asciidoc index 9292b2a6..3f37190d 100644 --- a/doc/makepkg.conf.5.asciidoc +++ b/doc/makepkg.conf.5.asciidoc @@ -72,6 +72,10 @@ Options **CXXFLAGS=**"cxxflags":: Flags used for the C++ compiler; see CFLAGS for more info. +**RUSTFLAGS=**"rustflags":: + Flags used for the Rust compiler, similar in spirit to CFLAGS. Read + linkman:rustc[1] for more details on the available flags. + **LDFLAGS=**"ldflags":: Flags used for the linker. Several options may be specified with common usage resembling ``-Wl,--hash-style=gnu''. Read ld(1) for more details on @@ -89,6 +93,11 @@ Options **DEBUG_CXXFLAGS=**"debug_cxxflags":: Debug flags used for the C++ compiler; see DEBUG_CFLAGS for more info. +**DEBUG_RUSTFLAGS=**"debug_rustflags":: + Additional compiler flags appended to `RUSTFLAGS` for use in debugging. + Usually this would include: ``-C debuginfo=2''. Read linkman:rustc[1] for + more details on the available flags. + **BUILDENV=(**!distcc !color !ccache check !sign**)**:: This array contains options that affect the build environment; the defaults are shown here. All options should always be left in the array; to enable diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 7e5da993..caf5114b 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -40,11 +40,13 @@ CHOST="@CHOST@" #CFLAGS="-O2 -pipe" #CXXFLAGS="-O2 -pipe" #LDFLAGS="" +#RUSTFLAGS="-C opt-level=2" #-- Make Flags: change this for DistCC/SMP systems #MAKEFLAGS="-j2" #-- Debugging flags #DEBUG_CFLAGS="-g" #DEBUG_CXXFLAGS="-g" +#DEBUG_RUSTFLAGS="-C debuginfo=2" ######################################################################### # BUILD ENVIRONMENT diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index a8d416c8..2ecd741e 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -36,5 +36,5 @@ prepare_buildenv() { done # ensure all necessary build variables are exported - export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS RUSTFLAGS MAKEFLAGS CHOST } diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index daccc9cc..85ee80fc 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -30,6 +30,6 @@ buildenv_functions+=('buildenv_buildflags') buildenv_buildflags() { if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS + unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS RUSTFLAGS DEBUG_RUSTFLAGS fi } diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in index ce9c1556..4cd5d003 100644 --- a/scripts/libmakepkg/buildenv/debugflags.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -32,7 +32,9 @@ buildenv_debugflags() { if check_option "debug" "y"; then DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}" CFLAGS+=" $DEBUG_CFLAGS" CXXFLAGS+=" $DEBUG_CXXFLAGS" + RUSTFLAGS+=" $DEBUG_RUSTFLAGS" fi } diff --git a/scripts/libmakepkg/lint_config/variable.sh.in b/scripts/libmakepkg/lint_config/variable.sh.in index 55ed6d6d..e73e13de 100644 --- a/scripts/libmakepkg/lint_config/variable.sh.in +++ b/scripts/libmakepkg/lint_config/variable.sh.in @@ -32,10 +32,10 @@ lint_config_variables() { local array=(DLAGENTS VCSCLIENTS BUILDENV OPTIONS INTEGRITY_CHECK MAN_DIRS DOC_DIRS PURGE_TARGETS COMPRESSGZ COMPRESSBZ2 COMPRESSXZ COMPRESSLRZ COMPRESSLZO COMPRESSZ) - local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS LDFLAGS DEBUG_CFLAGS - DEBUG_CXXFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES STRIP_SHARED - STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER GPGKEY - PKGEXT SRCEXT) + local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS RUSTFLAGS LDFLAGS DEBUG_CFLAGS + DEBUG_CXXFLAGS DEBUG_RUSTFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES + STRIP_SHARED STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER + GPGKEY PKGEXT SRCEXT) local i keys ret=0 -- 2.23.0
On 7/10/19 11:33 am, Eli Schwartz wrote:
The rust language supports $RUSTFLAGS to be used automatically in all rustc invocations. Allow setting this in makepkg.conf (e.g. for optimization or debuginfo support), and teach debug+strip to pass the rustc command line argument necessary to rewrite source file paths in the debugging symbols.
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> ---
v3: fix typo, srdir -> srcdir
Ack - with my comment remaining that makepkg.conf is getting to long and we should investigate something like including /etc/makepkg.conf.d/rustflags in the future. This serves as notice that future additions may be delayed until this is implemented... Allan
participants (3)
-
Allan McRae
-
Eli Schwartz
-
Morten Linderud