Open melonchucker opened 10 months ago
I'm afraid any docs under legacy
aren't really true. They are docs for Buck1. Someone is working on removing them right now, in response to your entirely reasonable misunderstanding.
The right path for making a GCC binary would be to produce a toolchain, like https://github.com/facebook/buck2/blob/4b508d80f92852431a0cf24da554d39e245315db/prelude/toolchains/cxx.bzl#L175C1-L192C1. So you would create a system_cxx_toolchain
for normal GCC, a separate one for arm-linux-gcc (changing the compiler/linker fields). I'd get that working, name your system_cxx_toolchain
for ARM as toolchains//:cxx
.
Once you have that building I imagine you want to use select
on a toolchain alias to select which one based on constraints//arch:arm64
. I suggest getting cross compilation only working first, then second trying to make it able to both normal and cross compile.
toolchain_alias
is not in prelude. I think it should be. I've needed it too.
Currently there's only an example in https://github.com/facebook/buck2/blob/main/examples/bootstrap/toolchains/toolchain.bzl
I've put up an internal patch moving toolchain_alias
into the prelude. Should land open source on Tuesday after everyone is back from Thanksgiving.
Awesome! I'll give toolchain_alias
a shot when I get back from Thanksgiving.
I'm afraid any docs under
legacy
aren't really true. They are docs for Buck1. Someone is working on removing them right now, in response to your entirely reasonable misunderstanding.The right path for making a GCC binary would be to produce a toolchain, like https://github.com/facebook/buck2/blob/4b508d80f92852431a0cf24da554d39e245315db/prelude/toolchains/cxx.bzl#L175C1-L192C1. So you would create a
system_cxx_toolchain
for normal GCC, a separate one for arm-linux-gcc (changing the compiler/linker fields). I'd get that working, name yoursystem_cxx_toolchain
for ARM astoolchains//:cxx
.Once you have that building I imagine you want to use
select
on a toolchain alias to select which one based onconstraints//arch:arm64
. I suggest getting cross compilation only working first, then second trying to make it able to both normal and cross compile.
Is there a open ticket for the Buck1->Buck2 doc changes? I didn't see one when I searched.
I can link to that and close this one out, since it looks like toolchains are the right way to use a different compiler and not flavors
We have an internal ticket for it but not a GitHub one. I'll let @lmvasquezg decide whether it's nearly done or needs an external ticket too.
Trying to cross compile with GCC, but making changes in
.buckconfig
don't seem to get picked up. I followed the examples provided on the buck2 docs here.buckconfig
:BUCK
:When I run
buck2 build :main#xcompile
I get:Cannot handle flavor `xcompile` on target `root//:main#xcompile`. Most flavors are unsupported in Buck2.