[llvm-dev] Miscompilation while switching from clang-4 to clang-5

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
Hello everyone,

I observe a weird behavior switching from clang-4 to clang-5 (and any higher version).
I compile an executable that depends on LLVM. Everything works fine with clang-4, but when I run the executable compiled with clang-5 I see the following error:
: CommandLine Error: Option 'rewrite-map-file' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

I want to debug the problem, but don't even know where to start.
I am happy to provide more info if anyone wants to participate.

I would appreciate any hints.

Thank you.
Alex.
--
AlexDenisov
Software Engineer, https://lowlevelbits.org

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
An LLVM library (in this case:
https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Utils/SymbolRewriter.cpp#L91
from LLVMTransformUtils) is linked into the address space more than
once. For instance, a statically linked and a dynamically linked
version.

Michael


2018-05-30 16:39 GMT-05:00 Alex Denisov via llvm-dev <[hidden email]>:

> Hello everyone,
>
> I observe a weird behavior switching from clang-4 to clang-5 (and any higher version).
> I compile an executable that depends on LLVM. Everything works fine with clang-4, but when I run the executable compiled with clang-5 I see the following error:
> : CommandLine Error: Option 'rewrite-map-file' registered more than once!
> LLVM ERROR: inconsistency in registered CommandLine options
>
> I want to debug the problem, but don't even know where to start.
> I am happy to provide more info if anyone wants to participate.
>
> I would appreciate any hints.
>
> Thank you.
> Alex.
> --
> AlexDenisov
> Software Engineer, https://lowlevelbits.org
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
In reply to this post by Bruce Hoult via llvm-dev
On 05/30/2018 02:39 PM, Alex Denisov via llvm-dev wrote:
> Hello everyone,
>
> I observe a weird behavior switching from clang-4 to clang-5 (and any higher version).
> I compile an executable that depends on LLVM. Everything works fine with clang-4, but when I run the executable compiled with clang-5 I see the following error:
> : CommandLine Error: Option 'rewrite-map-file' registered more than once!
> LLVM ERROR: inconsistency in registered CommandLine options
>

This usually indicates an issue with how you link your application.
Two causes of this would be your application is linked against 2 different
versions of LLVM or your are linking against the llvm static libraries and
also libLLVM.so.

-Tom

> I want to debug the problem, but don't even know where to start.
> I am happy to provide more info if anyone wants to participate.
>
> I would appreciate any hints.
>
> Thank you.
> Alex.
> --
> AlexDenisov
> Software Engineer, https://lowlevelbits.org
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>



_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
Hi Tom, hi Michael,

Thank you for your help.
I understand the linking problem. What I do not understand is how to debug the difference between two versions of compilers.
This what I do (briefly):

clang++-4 foobar.cpp -lLLVM -l/opt/llvm-3.9/lib

clang++-5 foobar.cpp -lLLVM -l/opt/llvm-3.9/lib

The first command produces a working executable, while the other one does not.
I'm trying to understand whether I had this problem all the time but clang-4 could not see it, or there is no problem but clang-5 does something wrong.

> On 30. May 2018, at 23:59, Tom Stellard <[hidden email]> wrote:
>
> On 05/30/2018 02:39 PM, Alex Denisov via llvm-dev wrote:
>> Hello everyone,
>>
>> I observe a weird behavior switching from clang-4 to clang-5 (and any higher version).
>> I compile an executable that depends on LLVM. Everything works fine with clang-4, but when I run the executable compiled with clang-5 I see the following error:
>> : CommandLine Error: Option 'rewrite-map-file' registered more than once!
>> LLVM ERROR: inconsistency in registered CommandLine options
>>
>
> This usually indicates an issue with how you link your application.
> Two causes of this would be your application is linked against 2 different
> versions of LLVM or your are linking against the llvm static libraries and
> also libLLVM.so.
>
> -Tom
>
>> I want to debug the problem, but don't even know where to start.
>> I am happy to provide more info if anyone wants to participate.
>>
>> I would appreciate any hints.
>>
>> Thank you.
>> Alex.
>> --
>> AlexDenisov
>> Software Engineer, https://lowlevelbits.org
>>
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> [hidden email]
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>
>
>

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
On 31 May 2018 at 08:41, Alex Denisov via llvm-dev
<[hidden email]> wrote:
> I understand the linking problem. What I do not understand is how to debug the difference between two versions of compilers.
> This what I do (briefly):
>
> clang++-4 foobar.cpp -lLLVM -l/opt/llvm-3.9/lib
>
> clang++-5 foobar.cpp -lLLVM -l/opt/llvm-3.9/lib

If you add -v then Clang will output each individual command it runs
to do that compilation (I'd expect 2: one compile step and one link
step).

As Tom & Michael said, the link step is most likely to be wrong. You
could test that by mixing and matching the invocations (using the .o
file produced by one version of Clang in the other link command for
example). In the end though, I suspect you'll find it's linking
against a different set of libraries now.

Cheers.

Tim.
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
Hi Tim,

The verbose mode is a good idea, thank you.

I've gathered all compilation commands with -v flag for clang-4 and clang-5 and they are identical (excerpt of compiler version).
I will try to find what has changed in clang/llvm between the versions.

If there are any other hints: send them my way :)

> On 31. May 2018, at 09:54, Tim Northover <[hidden email]> wrote:
>
> On 31 May 2018 at 08:41, Alex Denisov via llvm-dev
> <[hidden email]> wrote:
>> I understand the linking problem. What I do not understand is how to debug the difference between two versions of compilers.
>> This what I do (briefly):
>>
>> clang++-4 foobar.cpp -lLLVM -l/opt/llvm-3.9/lib
>>
>> clang++-5 foobar.cpp -lLLVM -l/opt/llvm-3.9/lib
>
> If you add -v then Clang will output each individual command it runs
> to do that compilation (I'd expect 2: one compile step and one link
> step).
>
> As Tom & Michael said, the link step is most likely to be wrong. You
> could test that by mixing and matching the invocations (using the .o
> file produced by one version of Clang in the other link command for
> example). In the end though, I suspect you'll find it's linking
> against a different set of libraries now.
>
> Cheers.
>
> Tim.
--
AlexDenisov
Software Engineer, https://lowlevelbits.org

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
2018-06-01 2:06 GMT-05:00 Alex Denisov <[hidden email]>:
> If there are any other hints: send them my way :)

Debug with gdb, but a breakpoint at
https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Utils/SymbolRewriter.cpp#L91.
It should hit twice (which is the error reported). At each break you
can look at where the machine code is coming from (e.g. a shared
object), and which static analyzer calls it.

Michael
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
Thank you, everyone, for the help.

As a followup:
I tried to svn-bisect and find the place where the change was introduced, but I cannot find a good commit: whenever I use clang built from sources I see the same problem "CommandLine Error" as with clang-5.
I am sure that the very specific is in our build system setup, but I am still curious where the difference comes from.
I may do another debugging round, but not sure if I am ready to invest more time into it.

Cheers,
Alex.
--
AlexDenisov
Software Engineer, https://lowlevelbits.org

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (495 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Miscompilation while switching from clang-4 to clang-5

Bruce Hoult via llvm-dev
2018-06-04 4:42 GMT-05:00 Alex Denisov <[hidden email]>:
> Thank you, everyone, for the help.
>
> As a followup:
> I tried to svn-bisect and find the place where the change was introduced, but I cannot find a good commit: whenever I use clang built from sources I see the same problem "CommandLine Error" as with clang-5.
> I am sure that the very specific is in our build system setup, but I am still curious where the difference comes from.
> I may do another debugging round, but not sure if I am ready to invest more time into it.

I'd assume this has more to do with your system's configuration. Be
sure to have just a single compiled LLVM on your system (e.g. remove
your distribution's llvm package etc). Did you try on another system?

Michael
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev