Since gcc 11 -gsplit-dwarf no longer implicitly enables -g and needs
a separate -g option. For some yet unknown reasons the default DWARF 5
format doesn't work, gdb doesn't show debug info, but DWARF 4 works fine
so use that.
Signed-off-by: Matthias Reichl <hias@horus.com>
Default linker can be set with DEFAULT_LINKER in options.
Packages can influence linker selection both by positive and/or
negative PKG_BUILD_FLAGS, eg +bfd or -gold.
Positive build flags take priority over the default linker so eg
DEFAULT_LINKER="gold" and PKG_BUILD_FLAGS="+bfd" will select bfd.
Negative flags mean a specific linker should not be used, eg -gold
prevents using gold.
If the default linker is disabled via a build flag then any other
available linker will be used.
Optional linkers like gold have to be enabled with eg GOLD_SUPPORT="yes"
in options. If an optional linker is not enabled it won't be a candidate
for linker selection. So eg "+mold" will have no effect if MOLD_SUPPORT
isn't set to "yes".
Signed-off-by: Matthias Reichl <hias@horus.com>
uname options -p and -i are non portable and return "unknown" on
Linux with GNU coreutils as there's no OS support for it.
Note: some distributions like Fedora or Ubunto patch coreutils so
that uname -p (more or less) returns the machine name (uname -m output).
But that should not be used and fails on distributions like Debian
that don't add that patch.
Signed-off-by: Matthias Reichl <hias@horus.com>
If we build with `-Os` some vars are missing in backtraces and will be listed as `<optimized out>`
- https://github.com/PCSX2/pcsx2/issues/5226#issuecomment-1036987320
```
Optimize debugging experience. -Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience. It is a better choice than -O0 for producing debuggable code because some compiler passes that collect debug information are disabled at -O0.
Like -O0, -Og completely disables a number of optimization passes so that individual options controlling them have no effect. Otherwise -Og enables all -O1 optimization flags except for those that may interfere with debugging:
```
- https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Add SPLIT_DEBUG_INFO option, when it's set to yes the debug info is
stored in separate .dwo files.
This is mainly useful for remote debugging and reduces image size a lot.
See also https://gcc.gnu.org/wiki/DebugFission
Signed-off-by: Matthias Reichl <hias@horus.com>
speed: use O3
size: use Os
default: use O2
The priority order is to use speed if set, then size, and fallback
to default when neither are set.
Signed-off-by: Ian Leonard <antonlacon@gmail.com>
Relies on the assumption that the machine that will build the toolchain will
also be the machine to use said toolchain.
Signed-off-by: Ian Leonard <antonlacon@gmail.com>
Builds use a mix of styles for the hash table in the ELF header. Only
one style of table is necessary, and the GNU one is more performant
for lookups. Eliminating the SysV style hash table trims ~450kb. This
is done via setting the default linker in gcc instead of LDFLAGS as
some packages ignore LDFLAGS.
Note that if MIPS is ever added as a supported architecture, it
does not support hash-style=gnu at this time.
Signed-off-by: Ian Leonard <antonlacon@gmail.com>
Split up the LTO flags in config/optimize and assemble
full C/CXX/LDFLAGS in config/functions.
Add flags for parallel/single-threaded lto and fat/non-fat
lto object creation.
Change the default lto build flag to use non-fat lto objects.
Signed-off-by: Matthias Reichl <hias@horus.com>
- replace strip_lto/strip_gold (only allowed to disable)
- add flag for PIC feature
- add flag to stop build parallel
- add support for hardening option (initial copy from debian 9)
All build parameters, are added in setup_toolchain.
`PKG_[FLAG]_[HOST/TARGET]_ENABLED` variable is introduced for checking the flag (yes/no) in the package.mk
Thanks to @MilhouseVH, for support and fixing