~sircmpwn/hare-users

3 3

Native and cross-compiling toolchain configuration

Details
Message ID
<72c7169b-d8ca-43c4-ae32-b7056d72e31d@omenos.dev>
DKIM signature
missing
Download raw message
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
Details
Message ID
<7dff1cdc-8995-415d-ba65-0d937977316e@strohwolke.at>
In-Reply-To
<72c7169b-d8ca-43c4-ae32-b7056d72e31d@omenos.dev> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<16723752-e775-42f7-b6bc-0cb10acdb040@omenos.dev>
In-Reply-To
<7dff1cdc-8995-415d-ba65-0d937977316e@strohwolke.at> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<CX88SNKPG8N3.2FLKF816LUD9G@d2evs.net>
In-Reply-To
<16723752-e775-42f7-b6bc-0cb10acdb040@omenos.dev> (view parent)
DKIM signature
missing
Download raw message
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
Reply to thread Export thread (mbox)