Support `$LLVM_VERSION`, `$LLVM_TARGETS`, and `$LLVM_LDFLAGS`
Resolves part of #14376.
This may also address part of #15074 since we can now override LLVM_VERSION for the Makefiles as well.
I'm wondering about the usefulness of LLVM_LDFLAGS. Effectively, you can just pass extra linker flags via --link-flags. I suppose the only purpose would be to suppress flags from llvm_VERSION and llvm-config --libs. But at that point it might just be reasonable to use neither of them and provide version (and targets) explicitly via env var and specify --link-flags.
This is just an observation, asking if it resonates with aynone. I'm not entirely sure about covering all use cases.
On POSIX environments you can probably pass LLVM_CONFIG=true to suppress all the default configuration too (the Makefiles can be easily adjusted for this).
Maybe we could drop all those linker flags whenever cross-compiling, but I found that there is no way to tell in Crystal code whether we are also doing the cross-linking on the same host (i.e. --target without --cross-compile), since --cross-compile doesn't add any flags.
LLVM_LDFLAGS would differ from --link-flags if require "llvm" alone doesn't call any LLVM functions. But it turns out the class variable initializer for LLVM::Attribute.@@kind_ids will call LLVMGetEnumAttributeKindForName
@HertzDevil could the lazy class_getter(name, &) help?