<div dir="ltr"><div>Hi all, <br><br></div><div>I am experiencing a problem managing the command line option of a set of passes in my LLVM project.<br><br></div><div>Attached you find a toy project the triggers the problem.<br>
</div><div>The project is made up of two passes: "AnalysisPass" and "TransformPass". <br>"TransformPass" requires "AnalysisPass" and they both share a common integer command line option called "-command-line-option"<br>
<br>According to:<br><a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-January/037722.html">http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-January/037722.html</a><br></div><div>the proper way of sharing a cl::opt variable among multiple passes is to define the variable once and declare it as "explicit" in all the<br>
</div><div>files of the passes that need it.<br><br></div><div>To keep the project tidy the  two "AnalysisPass" and "TransformPass" are compiled into two different .so libraries.<br></div><div>The only way I can think of to share the cl::opt variable is to define is to define it in a separate "Support" static library which is then <br>
linked by both "AnalysisPass" and "TransformPass".<br><br>When running "AnalysisPass" loading it with opt all works fine, while running "TransformPass" opt never returns stuck in an infinite loop.<br>
</div><div>GDB tells me that opt is trapped somewhere into llvm::cl::ParseCommandLineOptions, but I am not confident with command line option management.<br><br>Notice that if the cl::opt variable is not used at all in "TransformPass" everithing runs fine.<br>
</div><div><br></div><div>Does anybody have an idea on what is going on here ?<br></div><div>Is there a better way of sharing command line options among passes belonging to different libraries ?<br></div><div><br></div><div>
Thank you in advance.<br><br></div><div>Cheers, <br></div>Alberto<br></div>