Duncan Sands
2012-Nov-22 09:55 UTC
[LLVMdev] llvm-config --cxxflags is not consistent when building by cmake.
Hi Óscar, On 22/11/12 09:41, Óscar Fuentes wrote:> Luba Tang <lubatang at gmail.com> writes: > >> We found `llvm-config --cxxflags' does not have -fno-exceptions -fno-rtti >> when using cmake to build LLVM. >> Does anyone know how to fix it? > > Using -fno-rtti and -fno-exceptions is an internal LLVM policy. There is > no reason to impose it on client code.actually it does impact external code. For example dragonegg does #include "llvm/Support/PluginLoader.h" This file contains // This causes operator= above to be invoked for every -load option. static cl::opt<PluginLoader, false, cl::parser<std::string> > LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"), cl::desc("Load the specified plugin")); If dragonegg is compiled with RTTI then linking fails because there is no RTTI for the cl::opt class. Thus dragonegg is forced to compile with -fno-rtti if it wants to work with this part of LLVM. There is also the question of what `llvm-config --cxxflags` is supposed to mean. Is it supposed to give the flags that LLVM was compiled with? Or is it supposed to give the flags that users of LLVM must compile themselves with? If it's the second why does it have optimization levels (-O2), debug info (-g) and so on, which are not at all required for code using LLVM? To my mind the only thing that really makes sense if that `llvm-config --cxxflags` gives the flags that LLVM was compiled with, in which case it should contain -fno-rtti and -fno-exceptions because LLVM was compiled with those. Ciao, Duncan.
Óscar Fuentes
2012-Nov-23 00:06 UTC
[LLVMdev] llvm-config --cxxflags is not consistent when building by cmake.
Duncan Sands <baldrick at free.fr> writes:>> Using -fno-rtti and -fno-exceptions is an internal LLVM policy. There is >> no reason to impose it on client code. > > actually it does impact external code. For example dragonegg does > > #include "llvm/Support/PluginLoader.h" > > This file contains > > // This causes operator= above to be invoked for every -load option. > static cl::opt<PluginLoader, false, cl::parser<std::string> > > LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"), > cl::desc("Load the specified plugin")); > > If dragonegg is compiled with RTTI then linking fails because there is no RTTI > for the cl::opt class. Thus dragonegg is forced to compile with -fno-rtti if > it wants to work with this part of LLVM. > > There is also the question of what `llvm-config --cxxflags` is supposed to mean. > Is it supposed to give the flags that LLVM was compiled with? Or is it supposed > to give the flags that users of LLVM must compile themselves with? If it's the > second why does it have optimization levels (-O2), debug info (-g) and so on, > which are not at all required for code using LLVM? To my mind the only thing > that really makes sense if that `llvm-config --cxxflags` gives the flags that > LLVM was compiled with, in which case it should contain -fno-rtti and > -fno-exceptions because LLVM was compiled with those.>From http://llvm.org/docs/CommandGuide/llvm-config.html :DESCRIPTION llvm-config makes it easier to build applications that use LLVM. It can print the compiler flags, linker flags and object libraries needed to link against LLVM. –cxxflags Print the C++ compiler flags needed to use LLVM headers. I think the above clears the question about the purpose of llvm-config. And I think you are right about -O2, -g etc. IMO -fno-exceptions and -fno-rtti are on almost the same category, because although the may be required for some uses, listing them on the output of --cxxflags may confuse the user by giving the idea that they are strictly required for using LLVM libraries, which is mostly false. It would be a bad thing if some user ends redesigning his compiler's implementation because he thinks that RTTI and exceptions are not allowed. Please note that LLVM uses RTTI and (IRC) exceptions on certain files, so the output of llvm-config --cxxflags wouldn't be valid for building LLVM itself!
Duncan Sands
2012-Dec-09 08:59 UTC
[LLVMdev] llvm-config --cxxflags is not consistent when building by cmake.
Hi Óscar, I've opened PR14539 for this. Ciao, Duncan. On 23/11/12 01:06, Óscar Fuentes wrote:> Duncan Sands <baldrick at free.fr> writes: > >>> Using -fno-rtti and -fno-exceptions is an internal LLVM policy. There is >>> no reason to impose it on client code. >> >> actually it does impact external code. For example dragonegg does >> >> #include "llvm/Support/PluginLoader.h" >> >> This file contains >> >> // This causes operator= above to be invoked for every -load option. >> static cl::opt<PluginLoader, false, cl::parser<std::string> > >> LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"), >> cl::desc("Load the specified plugin")); >> >> If dragonegg is compiled with RTTI then linking fails because there is no RTTI >> for the cl::opt class. Thus dragonegg is forced to compile with -fno-rtti if >> it wants to work with this part of LLVM. >> >> There is also the question of what `llvm-config --cxxflags` is supposed to mean. >> Is it supposed to give the flags that LLVM was compiled with? Or is it supposed >> to give the flags that users of LLVM must compile themselves with? If it's the >> second why does it have optimization levels (-O2), debug info (-g) and so on, >> which are not at all required for code using LLVM? To my mind the only thing >> that really makes sense if that `llvm-config --cxxflags` gives the flags that >> LLVM was compiled with, in which case it should contain -fno-rtti and >> -fno-exceptions because LLVM was compiled with those. > > From http://llvm.org/docs/CommandGuide/llvm-config.html : > > DESCRIPTION > > llvm-config makes it easier to build applications that use LLVM. It can > print the compiler flags, linker flags and object libraries needed to > link against LLVM. > > –cxxflags > Print the C++ compiler flags needed to use LLVM headers. > > > > I think the above clears the question about the purpose of > llvm-config. And I think you are right about -O2, -g etc. IMO > -fno-exceptions and -fno-rtti are on almost the same category, because > although the may be required for some uses, listing them on the output > of --cxxflags may confuse the user by giving the idea that they are > strictly required for using LLVM libraries, which is mostly false. It > would be a bad thing if some user ends redesigning his compiler's > implementation because he thinks that RTTI and exceptions are not > allowed. > > Please note that LLVM uses RTTI and (IRC) exceptions on certain files, > so the output of llvm-config --cxxflags wouldn't be valid for building > LLVM itself! > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Reasonably Related Threads
- [LLVMdev] llvm-config --cxxflags is not consistent when building by cmake.
- [LLVMdev] llvm-config --cxxflags is not consistent when building by cmake.
- [LLVMdev] llvm-config --cxxflags is not consistent when building by cmake.
- [LLVMdev] llvm-config --cxxflags is not consistent when building by cmake.
- [LLVMdev] Why does `llvm-config --cxxflags` now include -fno-rtti ?