This is the command I ran and the error I got:
$ crystal build --static src/something.cr
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc "${@}" -o '/Users/sherjil/Desktop/something/something' -rdynamic -static -lpcre -lgc -lpthread /usr/local/Cellar/crystal-lang/0.24.2_1/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib`
I did a bit of googling, and it seems macos doesn't provide a static library for crt0.o, which is causing this problem.
Building static binaries is unsupported by macOS. There is nothing we can do :(
We can add the information that static linking is not supported when using --static on macOS. with a macro triggered by the darwin flag.
Smart suggestion from @j8r.
Most helpful comment
We can add the information that static linking is not supported when using
--staticon macOS. with a macro triggered by thedarwinflag.