CommandLineParser problems with llvm trunk?

Hi,

Recently I started getting some weird errors from multiple tools (on
Linux x86-64):

λ lld
lld: ../lib/Support/CommandLine.cpp:202: void (anonymous
namespace)::CommandLineParser::registerCategory(llvm::cl::OptionCategory
*): Assertion `std::count_if(RegisteredOptionCategories.begin(),
RegisteredOptionCategories.end(), [cat](const OptionCategory
*Category) { return cat->getName() == Category->getName(); }) == 0 &&
"Duplicate option categories"' failed.
[1] 25383 abort (core dumped) lld

λ lldb-server
: CommandLine Error: Option 'debug' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

llvm is built with:

cmake -G "Ninja" \
    -DLLVM_BUILD_LLVM_DYLIB=ON \
    -DLLVM_LINK_LLVM_DYLIB=ON \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DLLVM_LIBDIR_SUFFIX=64 \
    -DCMAKE_C_FLAGS="-fuse-ld=gold -fPIC" \
    -DCMAKE_CXX_FLAGS="-fuse-ld=gold -fPIC" \
    -DLLVM_REQUIRES_RTTI=ON \
    -DLLVM_ENABLE_TIMESTAMPS=OFF \
    -DLLVM_ENABLE_ASSERTIONS=ON \
    -DLLVM_ENABLE_PIC=ON \
    -DLLVM_BINUTILS_INCDIR=/usr/include \
    -DLLVM_TARGETS_TO_BUILD=all \
    -DCLANG_DEFAULT_CXX_STDLIB=libc++ \
    -DLLVM_ENABLE_LIBCXX=ON \
    ..

Wonder if anyone hit the same problem?

Thanks,
ismail

Hi,

Recently I started getting some weird errors from multiple tools (on
Linux x86-64):

λ lld
lld: …/lib/Support/CommandLine.cpp:202: void (anonymous
namespace)::CommandLineParser::registerCategory(llvm::cl::OptionCategory
*): Assertion `std::count_if(RegisteredOptionCategories.begin(),
RegisteredOptionCategories.end(), [cat](const OptionCategory
*Category) { return cat->getName() == Category->getName(); }) == 0 &&
“Duplicate option categories”’ failed.
[1] 25383 abort (core dumped) lld

λ lldb-server
: CommandLine Error: Option ‘debug’ registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

Seems related to llvm.org/pr22952 - the way cl::opt works fundamentally doesn’t play well with shared libs.

Wow, thats a big blocker for LLVM_BUILD_LLVM_DYLIB, thanks a lot!

ismail