[llvm] [SPIR-V] Fix parsing of command line options for the SPIR-V Backend API call (PR #124653)

Vyacheslav Levytskyy via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 03:08:21 PST 2025


VyacheslavLevytskyy wrote:

> I don't think this really fixes the issue. If I'm reading this correctly, you still have:
> 
> * A potential thread-safety issue, because only the option parsing is behind a lock, but not the use of those options, so they may be written and accessed concurrently.
> * Clobbering of global options, which is likely to break things if the process does anything else with LLVM other than calling this function.
> 
> I think to fix this you need to switch to using a different option parsing implementation that does not use the (global) cl::opt mechanism. For example, using OptTable might work. Though ideally, the API would not require option parsing at all.

You are right about thread-safety issue with read/write, however, this PR fixes LLVM's building errors for sure, so please think about this PR as a quick fix, not a permanent solution. The solution is to avoid using cl::opt & globals as a source of user facing options indeed (https://github.com/llvm/llvm-project/issues/124703). I'd expect that I may create a solution for this during next couple of days, so probably there is no need for more radical solutions, if you agree with that.

https://github.com/llvm/llvm-project/pull/124653


More information about the llvm-commits mailing list