LLVM source compilation Error: CommandLine Error: Option 'mc-relax-all' registered more than once!

Dear All,

Recently, I wanted to reinstall a fresh copy of llvm for a new project
I am working on.
However I ran into the following issue when attempting to build a vanilla copy.

CommandLine Error: Option 'mc-relax-all' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
make[2]: *** [unittests/Support/DynamicLibrary/CMakeFiles/DynamicLibraryLib.dir/build.make:85:
lib/libDynamicLibraryLib.a] Error 1
make[2]: *** Deleting file 'lib/libDynamicLibraryLib.a'
make[1]: *** [CMakeFiles/Makefile2:137325:
Error 2
make[1]: *** Waiting for unfinished jobs....

I am working on the following platform:
Linux XXXX 5.0.16-100.fc28.x86_64 #1 SMP Tue May 14 18:22:28 UTC 2019
x86_64 x86_64 x86_64 GNU/Linux

My steps were:
$ git clone git@github.com:llvm/llvm-project.git
$ cd llvm-project/
$ git checkout llvmorg-9.0.0
(I later tried with releases llvmorg-8.0.0 AND llvm-10.0.0 but still
got the same error)
$ mkdir build && cd build
Makefiles" ../llvm
(No errors so far)
$ make -j40
(This is where error happens)

I have worked with llvm for over 6 years now and still never ran into
something so bizarre. Any help is appreciated. I have looked online
for a few hours now and found similar postings but no clear replies or
solutions for this.


Christopher Jelesnianski

This is usually a linkage error when the same library is being included in both a static library and a shared library. You can probably with around it by disabling build shared libs temporarily. I’ll see if I can track down the problem, but I doubt get to it right away.


Thanks for your quick reply. I have also tried disabling build shared
libs, specifying via
"-DBUILD_SHARED_LIBS=OFF" in my cmake config line
However I am getting the same exact error with this flag specified as well.

Just an idea, would removing all llvm/clang instances/libs on my
machine work? Do you know what the default location is of these
shared/static llvm libraries that are conflicting?

I'm not exactly sure how to do this via command line on linux though.
I definitely agree this is related to linkage error as you say. I'm
just not sure what I have to remove to get this server to go back to a
"clean slate" state such that I can build llvm-project. That is
information I have been looking for, but can't seem to find and this
error doesn't seem to be well documented.
I have already tried the following, but it didn't help either
$ sudo su
$ dnf remove llvm
$ dnf remove clang

and then performing
$ sudo dnf install llvm
$ sudo dnf install clang

To give more context, I can do a clean install of vanilla llvm-project
on other servers I have access to, but can't currently afford to move
my code base to these other servers.

I found a work around. I did some more poking around my system and
found where the default install location of all
libLLVM* libraries and
libclang* libraries were installed. Specifically
$ /usr/local/lib
I was hesitant but when I deleted all libclang* and libLLVM* files. I
was able to get past this error.

Thanks again.

Aha! Good guess. It definitely looks like it is confused with the clang installed in your system somehow.