This is obvious in hindsight. The flags we were passing *precisely because*
we wanted e.g. -Wno-format to be passed to every test also included
-O2 or whatever from the user's flags which breaks tests that may require
no optimisation and so on.
Instead of trying to filter out options in a whack-a-mole game, let's
introduce special GCC_TESTS_* *FLAGS variables which we append
the needed -Wno-* to (etc.) which users can also specify if they really want
or need to.
Note that this isn't as scary or as weird as it sounds. We were only
trying to jam these flags in **purely** to counteract some defaults
we set, these tests really aren't supposed to be run with arbitrary
flags stuck in, but a workaround we added started to introduce way
more than intended.
The torture tests are fine with being run with various optimisation flags
but the rest of the testesuite isn't.
This fixes 361c375864 and some of the
attempts afterwards, although not everything in those commits was bad.
Fixes: 361c375864
Signed-off-by: Sam James <sam@gentoo.org>
Make clear it's not a typo as it comes from gcc's testsuite (could
look like an accidental 'TEST' instead of 'TESTS' like the eclassvars
we use for tests.)
Signed-off-by: Sam James <sam@gentoo.org>
... until validate_failures.py can handle them properly, to avoid
trashing our test manifests.
Bug: https://gcc.gnu.org/PR116260
Signed-off-by: Sam James <sam@gentoo.org>
(de)compressing modules changes the path of the module files so we need to
run depmod to ensure that tools such as modprobe/modinfo work.
Note that depmod is often, but *not* always, run by sys-kernel/installkernel.
Systemd installs a hook to do this, but there is no equivalent on openrc
systems. So instead just ensure that the tree of modules we install is
consistent here in the eclass.
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
* Disable -fno-semantic-interposition for tests as ASAN + contract violation
checks rely on it
* Consolidate the appends vs. filters
Signed-off-by: Sam James <sam@gentoo.org>
* Drop diagnostic flags (colour, URLs) which may break tests
* Drop QA flags to check if *FLAGS are respected; not necessary for tests
and may confuse e.g. export checks (as with mesa).
Signed-off-by: Sam James <sam@gentoo.org>
We used to only set the Rust target when cross-compiling, but now we do
it unconditionally, which changes the target directory.
Closes: https://bugs.gentoo.org/937574
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
We ended up not running many tests because it got interpreted as '--Werror'
with the braces/splitting (e.g. rust and such got skipped entirely).
With this change, we seem to be nearly there although we have issues
with Fortran tests that have C for interop because we get the unsupported
arg warnings...
Fixes: 5ca076594a
Signed-off-by: Sam James <sam@gentoo.org>
Cargo turned out to be even worse at handling flags than I thought.
Target-specific flags set by projects were overriding our own, and Cargo
was bailing out when faced with merging a string of flags with an array
of flags.
After weighing up the poor set of options, I've found that it is better
to always set flags via a target-specific environment variable for
reasons set out in comments added here. This approach was previously
just used for cross-compiling, but now we do it unconditionally.
It has the downside of overriding generic [build] flags set by projects,
but these were already being overridden by users and ebuilds setting
RUSTFLAGS themselves.
Closes: https://bugs.gentoo.org/937453
Closes: https://bugs.gentoo.org/937470
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Adjusts kernel-install_compress_modules to use the new function
dist-kernel_get_module_suffix. This makes no functional difference
at the moment since gentoo-kernel-bin is the only consumer and it has
XZ compression in the config. Still this makes it possible to compile
alternate prebuilt kernels with alternate module compression support, and may
in the future help to support gzip and zstd module compression in
gentoo-kernel-bin.
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
When installing a binpkg -nt is not a good check because the modules in the
binpkg we are installing may actually be older then what we have in root.
Instead introduce a new function dist-kernel_get_module_suffix to find the
desired compression based on USE=modules-sign and the kernel config. Then,
remove only those files that do not match our desired compression.
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
This is just like python_get_sitedir, but it returns the stdlib
directory such as /usr/lib/python3.12. This is useful for locating the
sysconfigdata file.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
cargo_env handles linker flags and enables cross-compiling. It also
handles LTO filtering, so we can remove that from this eclass.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This is currently done for Cargo by distutils-r1.eclass. The next commit
will remove that code, leaving cargo_env responsible for it.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Most projects don't strip binaries in release mode by default, but there
are exceptions like app-misc/broot.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
LDFLAGS are not currently honoured by Cargo builds at all. It would be
particularly advantageous to honour -fuse-ld because alternative linkers
like mold are known to be significantly faster at handling Rust.
As things stand, the eclass sets the linker to CC when cross-compiling,
but it does so erroneously due to a shell quoting issue. If CC includes
arguments, an error occurs when setting the CARGO_TARGET_*_LINKER
variable. Even with the right quoting, Cargo still fails because this
variable is not allowed to include arguments. They have to be specified
via RUSTFLAGS instead.
The build host linker is frequently invoked due to the use of build
scripts by some crates. We would therefore also like to configure the
build host linker properly when cross-compiling, but unfortunately there
is currently no way to do this without using a Rust nightly feature.
The build host linker is now configured in the cargo_gen_config function
because this configuration is static. Conversely, the target host linker
is configured with environment variables in the cargo_env function
because the target may change.
Some ebuilds already set RUSTFLAGS, so some consideration was given to
how to handle these. When set, Cargo prioritises RUSTFLAGS and similar
over specific configuration for the build and target hosts, so these
must be unset. We can still include their contents in that configuration
for convenience though. BUILD_RUSTFLAGS can be used by ebuilds to
set flags only for the build host.
It should not be necessary for ebuilds to figure out which Rust ABI is
applicable in order to set flags only for the target host, so the helper
reads from a simple TARGET_RUSTFLAGS variable without the triple for
convenience.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Rust packages have a tendency to rebuild parts during test and install.
It is not clear whether this can be addressed. We were therefore relying
on some environment variables set during the compile phase for
cross-compiling to work in the later phases. This is not ideal,
especially if you need to build for multiple targets.
These environment variables can also be useful in other contexts, such
as the build runner in app-misc/anki.
This change moves the setting of these variables into a separate helper
that is now used in all these phases and can be used by ebuilds too. The
variables are now kept local to each invocation of this helper,
preventing leakage.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
"config" is deprecated and "config.toml" has been valid for ages.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Add a sanity check that ensures that PYTHONPATH does not contain any
relative paths. While at it, also explicitly warn about PYTHONPATH
being set, so we know about it in build logs.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Fix the declaration of DISTUTILS_ALLOW_WHEEL_REUSE to allow disabling it
via setting the variable to an empty value in the environment.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Add a helper function to check whether time_t is 64-bit. This could
be used e.g. to deselect tests that rely on timestamps exceeding Y2k38.
It is meant to be more future-proof than hardcoding a list of 32-bit
architectures, given the necessity of switching to 64-bit time_t
in the future.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Fix tc-is-lto function to remove the temporary file after testing.
Besides being cleaner, this fixes a permission problem when using
Paludis and tc-is-lto is used both in pkg_setup() (which creates
the temporary file owned by root) and src_*() phase (which attempts
to rewrite it as a regular user).
Thanks to negril for the report!
Signed-off-by: Michał Górny <mgorny@gentoo.org>
For tests, we need to put some effort in to counteract our defaults
like -Wformat-security and -Wtrampolines (which we may want to revisit
at some point, but it is what it is for now).
Use a subshell so we can mangle the values within without affecting
the rest of the build.
I still get some failures with this (including some related to e.g.
-Wformat-security still) but far fewer, the flags don't get passed
everywhere so needs more poking or maybe just patching those tests
within the patch we use to change defaults.
See also the discussion on gcc-patches recently [0].
[0] https://inbox.sourceware.org/gcc-patches/ee9a8a6b11438f158933a21d7965b486987be5a8.1721454759.git.sam@gentoo.org/
Signed-off-by: Sam James <sam@gentoo.org>
This confuses things if e.g. using GDC from older GCC. Not worth it given
I'd only added it for a personal experiment.
Signed-off-by: Sam James <sam@gentoo.org>