Hi all,
As a disclaimer, I have very little experience with cross-compiling
(across platforms and architectures) outside of Go. If I am mistaken
about something, please let me know! I am aware that Hare is capable of
cross-compiling software, both native Hare software and those linking
against libc as long as the necessary tools for doing so are available.
I'm in the process of trying to package Hare for Fedora^ (qbe and harec
just need updating), and I had a question about the toolchain config.
When building Hare itself there is the option of defining the
cross-architecture toolchains for Hare to use. In order to make sure I'm
supporting this capability correctly, I am defining a subpackage that
will pull in the required dependencies for cross-compilation
(binutils-<arch>..., gcc-<arch>..., etc). What I want to be sure about
is whether or not Hare will select the toolchain dynamically, or if the
initial build config is static. I see in cmd/hare/build.ha Hare appears
to read in which tools to use from environment variables, but I'm not
sure if these are also read at runtime as an environment override. The
only thing I know for sure is the tools defined at build-time are baked
in the hare binary after running it through strings.
$ strings -a hare | grep -i -e x86_64 -e aarch64 -e riscv64
rt/+linux/+x86_64.ha
-aarch64-riscv64-x86_64
aarch64
aarch64-linux-gnu-as
aarch64-linux-gnu-gcc
aarch64-linux-gnu-ld
riscv64
riscv64-linux-gnu-as
riscv64-linux-gnu-gcc
riscv64-linux-gnu-ld
x86_64
As Fedora provides the GNU and LLVM toolchains, I would like to be able
to support both for developers to use with Hare out of the box. Is this
possible today, or would an RFC be required?
Cheers
^ https://bugzilla.redhat.com/show_bug.cgi?id=2154514
Hi,
On 11/24/23 04:24, Mike Rochefort wrote:
> What I want to be sure about > is whether or not Hare will select the toolchain dynamically, or if the > initial build config is static.
you need to add it to config.mk of the hare project before the build
step. Here's an example of the config in the Arch-Linux AUR package:
https://aur.archlinux.org/cgit/aur.git/tree/config.x86_64.mk?h=hare-git
On 11/24/23 2:03 AM, Armin Preiml wrote:
> you need to add it to config.mk of the hare project before the build step.
Yes, I'm already doing that for the builds. I just wanted to cross check
if there is a way, today, to override that configuration at runtime. As
an example use case:
I currently specify the GNU tools in the config, and make that build of
Hare available for users. A developer installs my Hare package, but
would rather use the LLVM stack for cross-compilation of their own
project written in Hare. Is it possible for this user to execute
something like the following and have it work as intended (e.g. use the
LLVM/Clang stack instead GCC/binutils)?
<ARCH>_AS=llvm-as \
<ARCH>_LD=lld \
<ARCH>_CC=clang \
hare build ...
Cheers
On Sat Nov 25, 2023 at 10:13 PM UTC, Mike Rochefort wrote:
> I currently specify the GNU tools in the config, and make that build of > Hare available for users. A developer installs my Hare package, but > would rather use the LLVM stack for cross-compilation of their own > project written in Hare. Is it possible for this user to execute > something like the following and have it work as intended (e.g. use the > LLVM/Clang stack instead GCC/binutils)?>> <ARCH>_AS=llvm-as \> <ARCH>_LD=lld \> <ARCH>_CC=clang \> hare build ...
$AS/$LD/$CC should override the build configuration, even with -a
specified