I admit I haven't sent this upstream as upstream don't seem to be
merging many PRs at the moment and it's also in some ancient copy
of bundled LLVM.
Signed-off-by: Sam James <sam@gentoo.org>
The build system of perf checks the clang version in order to set
correct compilation flags. However, it defaults to the non-prefixed
clang invocation, which fails during cross-compilation.
Set CLANG to point to the fully qualified host clang.
The build system will only use it if it’s actually available.
Closes: https://bugs.gentoo.org/936558
Closes: https://github.com/gentoo/gentoo/pull/37688
Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
Signed-off-by: Guilherme Amadio <amadio@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>