Oh, yeah that could be a great idea. I just checked this:
$ CC=$(brew --prefix)/bin/gcc-13 crystal build hello.cr
$ readelf -a empty | grep -i linuxbrew/lib/
[Requesting program interpreter: /home/linuxbrew/.linuxbrew/lib/ld.so]
0x000000000000001d (RUNPATH) Library runpath: [/home/linuxbrew/.linuxbrew/lib/gcc/current:/home/linuxbrew/.linuxbrew/lib]
So this has exactly the same result as the C binary. No need for explicit runpath configuration.
However, there is currently no way to configure the compiler’s default linker. I suppose it should be pretty straightforward to introduce CRYSTAL_CONFIG_CC, though.
This would require adding gcc as a dependency of the Crystal formula. Currently it is not a dependency. Crystal just uses the default cc, which may come from a system package.