Is it possible to use external out-of-tree GCC toolchain?

I'm working on an experimental project, and need to use patched cross-compiling toolchain(for new rv64ilp32 abi) stored in a Github Repository, how can I change toolchain/gcc's configuration file to automatically download and build it?