Set -g when building Vala applications
This requires the build system support VALAFLAGS. At least Meson and Automake do. Using -g is desired because it allows us to see Vala source files and line numbers in backtraces when possible, falling back to generated C code otherwise. Line numbers for generated C are almost always less useful when debugging crashes.
This commit is contained in:
parent
6024b1e611
commit
d0970582ad
@ -6,7 +6,7 @@ and how to use them.
|
||||
# Using RPM build flags
|
||||
|
||||
The %set_build_flags macro sets the environment variables `CFLAGS`,
|
||||
`CXXFLAGS`, `FFLAGS`, `FCFLAGS`, `LDFLAGS` and `LT_SYS_LIBRARY_PATH` to
|
||||
`CXXFLAGS`, `FFLAGS`, `FCFLAGS`, `VALAFLAGS`, `LDFLAGS` and `LT_SYS_LIBRARY_PATH` to
|
||||
the value of their corresponding rpm macros. `%set_build_flags` is automatically
|
||||
called prior to the `%build`, `%check`, and `%install` phases so these flags can be
|
||||
used by makefiles and other build tools.
|
||||
@ -43,6 +43,7 @@ Individual build flags are also available through RPM macros:
|
||||
the `CXXFLAGS` shell variable).
|
||||
* `%{build_fflags}` for `FFLAGS` (the Fortran compiler flags, also
|
||||
known as the `FCFLAGS` variable).
|
||||
* `%{build_valaflags}` for `VALAFLAGS` (the Vala compiler flags)
|
||||
* `%{build_ldflags}` for the linker (`ld`) flags, usually known as
|
||||
`LDFLAGS`. Note that the contents quote linker arguments using
|
||||
`-Wl`, so this variable is intended for use with the `gcc` compiler
|
||||
@ -493,6 +494,13 @@ tuning in the `gcc` package. These settings are:
|
||||
beneficial for a broad range of current CPUs.
|
||||
* **aarch64** does not have any architecture-specific tuning.
|
||||
|
||||
### Vala-specific compiler flags
|
||||
|
||||
* `-g`: causes valac to emit `#line` directives in the generated C
|
||||
source code. This improves backtrace generation by causing gdb to
|
||||
point to Vala source file and line number instead of the generated C
|
||||
source when possible.
|
||||
|
||||
# Individual linker flags
|
||||
|
||||
Linker flags end up in the environment variable `LDFLAGS`.
|
||||
|
8
macros
8
macros
@ -64,6 +64,9 @@
|
||||
# the corresponding variable names.
|
||||
%build_fflags %{optflags} -I%{_fmoddir}
|
||||
|
||||
# Vala compiler flags. This is used to set VALAFLAGS.
|
||||
%build_valaflags -g
|
||||
|
||||
# When clang is used as a linker driver, it does not auto-detect the LTO
|
||||
# bytecode and neither does bfd, so we need to explicitly pass the -flto
|
||||
# flag when linking.
|
||||
@ -77,8 +80,8 @@
|
||||
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_clang_extra_ldflags}" : "" ] %{_build_id_flags} %{?_package_note_flags}
|
||||
|
||||
# Expands to shell code to set the compiler/linker environment
|
||||
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have
|
||||
# not been set already. RPM_OPT_FLAGS and RPM_LD_FLAGS have already
|
||||
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, VALAFLAGS, LDFLAGS if they
|
||||
# have not been set already. RPM_OPT_FLAGS and RPM_LD_FLAGS have already
|
||||
# been set implicitly at the start of the %%build section.
|
||||
# LT_SYS_LIBRARY_PATH is used by libtool script.
|
||||
%set_build_flags \
|
||||
@ -86,6 +89,7 @@
|
||||
CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
|
||||
FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
|
||||
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
|
||||
VALAFLAGS="${VALAFLAGS:-%{build_valaflags}}" ; export VALAFLAGS ; \
|
||||
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS ; \
|
||||
LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH ; \
|
||||
CC="${CC:-%{__cc}}" ; export CC ; \
|
||||
|
Loading…
Reference in New Issue
Block a user