crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Support `$LLVM_VERSION`, `$LLVM_TARGETS`, and `$LLVM_LDFLAGS`

Open HertzDevil opened this issue 1 year ago • 3 comments

Resolves part of #14376.

This may also address part of #15074 since we can now override LLVM_VERSION for the Makefiles as well.

HertzDevil avatar Oct 17 '24 11:10 HertzDevil

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.

straight-shoota avatar Oct 17 '24 11:10 straight-shoota

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).

HertzDevil avatar Oct 17 '24 12:10 HertzDevil

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.

HertzDevil avatar Oct 18 '24 07:10 HertzDevil

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 avatar Feb 13 '25 01:02 HertzDevil

@HertzDevil could the lazy class_getter(name, &) help?

ysbaddaden avatar Feb 20 '25 13:02 ysbaddaden