I am lead developer of a project that is using LLVM to implement an ahead-of-time compiled functional language. We use llc -tailcallopt to ensure that functions that end in a tail call are compiled to a tail call at the machine level, because we have a number of cases in our interpreter where functions with different function signatures call one another in deeply nested recursive calls. We can’t use
musttail because the callee and caller often have different signatures.
We would like to support link time optimization in our programming language, because performance is important to us. However, there is no clang flag to enable the GuaranteedTailCallOpt flag, and the only way to pass target options to the lto plugin currently is via an unsupported API that parses those flags to static variables. This works on Linux, but the Mac OS linker does not actually initialize the TargetOptions that it passes as an llvm::lto::Config based on the parsed static variables, and Apple is uninterested in spending time supporting an unsupported LLVM API like -mllvm (understandably).
Is there a change to the LLVM project that you might be willing to accept that we might be able to create a patch for that would allow us to get link time optimization enabled in our programming language on Mac OS, at least in the future? And if so, is it possible that someone could give me pointers on how to proceed? I’m a relative novice studying this code and I’m not really sure how all the components fit together at a high level and thus what the correct design for something like this would be.
Or am I going to have to resign myself to waiting until lld is well supported at linking mach-o files?