llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.79k stars 11.9k forks source link

clang: "-save-temps -g" option leads to "warning: inconsistent use of MD5 checksums" #56378

Open hurryman2212 opened 2 years ago

hurryman2212 commented 2 years ago

Clang version: 14.0.0-1ubuntu1 (target: x86_64-pc-linux-gnu)

How to reproduce the issue: Build any source with -save-temps -g, then warning: inconsistent use of MD5 checksums will be generated in assembly stage.

The root cause for this is probably that the output assembly for -save-temps -g holds two .file directives (with/without build directory", but only the above one holds MD5 sequence. Output assembly format:

foo:                                   # @foo
.Lfunc_begin0:
    .file   0 "/your/path/your/project" "FILE.c" md5 <MD5_SEQUENCE>
    .file   1 "FILE.c"
        ...
vollmilch64 commented 1 year ago

Is there any news on this? I'm having the same problem on Clang 15.0.6

EugeneZelenko commented 1 year ago

Could you please try 16 or main branch?

vollmilch64 commented 1 year ago

I just tried it with the current main branch (cf491a165f239abfa7ab9e707f5cbd1861a6cb20). Still the same.

On 25 Feb 2023, at 15:57, EugeneZelenko @.***> wrote:

Could you please try 16 or main branch?

— Reply to this email directly, view it on GitHub https://github.com/llvm/llvm-project/issues/56378#issuecomment-1445136595, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4WHHP3ZU64FMSFW474D4DWZIMXBANCNFSM52VLZBRQ. You are receiving this because you commented.

fangism commented 1 year ago

This happens to me too with (--save-temps -gdwarf-5):

The first few lines of vnode.s in my case:

        .text
        .file   "vnode.cc"
        .file   0 "." "vnode.cc" md5 0x42b9c8d9a2c30ce0affbd48a8c058c14
        .file   1 "../../src/storage/minfs" "vnode.cc"

clang diagnostic:

vnode.s:4:2: error: inconsistent use of MD5 checksums
        .file   1 "../../src/storage/minfs" "vnode.cc"
        ^

Version:

Fuchsia clang version 17.0.0 (https://llvm.googlesource.com/llvm-project ebd0b8a0472b865b7eb6e1a32af97ae31d829033)
iyernaveenr commented 12 months ago

Any update on this? I am also facing the same issue. Following is the version info:

$ clang --version
Ubuntu clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
llvmbot commented 12 months ago

@llvm/issue-subscribers-clang-driver

Author: Jihong Min (hurryman2212)

Clang version: 14.0.0-1ubuntu1 (target: x86_64-pc-linux-gnu) How to reproduce the issue: Build any source with ```-save-temps -g```, then ```warning: inconsistent use of MD5 checksums``` will be generated in assembly stage. The root cause for this is probably that the output assembly for ```-save-temps -g``` holds two ```.file``` directives (with/without build directory", but only the above one holds MD5 sequence. Output assembly format: ```asm foo: # @foo .Lfunc_begin0: .file 0 "/your/path/your/project" "FILE.c" md5 <MD5_SEQUENCE> .file 1 "FILE.c" ... ```
sprintersb commented 11 months ago

I am seeing this bug with:

Ubuntu clang version 17.0.0 (++20230416052825+70b182e0d3f7-1~exp1~20230416172957.603) Target: x86_64-pc-linux-gnu Thread model: posix

I am NOT USING -save-temps though, just -S -g3 to get intermediate assembly.

MaskRay commented 10 months ago

This is due to a duplicate DIFile(a.c).

% cat a.c
void f() {}
% clang -c -g a.c  # no warning
% clang -E a.c -o a.i && clang -g -S a.i && clang -g -c a.s
a.s:9:2: warning: inconsistent use of MD5 checksums
        .file   1 "a.c"
        ^
% grep DIFile a.ll
!1 = !DIFile(filename: "a.c", directory: "/tmp/c", checksumkind: CSK_MD5, checksum: "c5b2e246df7d5f53e176b097a0641c3d")
!11 = !DIFile(filename: "a.c", directory: "/tmp/c")
% grep 'file.*a.c' a.s
        .file   "a.c"
        .file   0 "/tmp/c" "a.c" md5 0x2d14ea70fee15102033eb8d899914cce
        .file   1 "a.c"

Patch #75022

llvmbot commented 10 months ago

@llvm/issue-subscribers-debuginfo

Author: Jihong Min (hurryman2212)

Clang version: 14.0.0-1ubuntu1 (target: x86_64-pc-linux-gnu) How to reproduce the issue: Build any source with ```-save-temps -g```, then ```warning: inconsistent use of MD5 checksums``` will be generated in assembly stage. The root cause for this is probably that the output assembly for ```-save-temps -g``` holds two ```.file``` directives (with/without build directory", but only the above one holds MD5 sequence. Output assembly format: ```asm foo: # @foo .Lfunc_begin0: .file 0 "/your/path/your/project" "FILE.c" md5 <MD5_SEQUENCE> .file 1 "FILE.c" ... ```
llvmbot commented 10 months ago

@llvm/issue-subscribers-clang-codegen

Author: Jihong Min (hurryman2212)

Clang version: 14.0.0-1ubuntu1 (target: x86_64-pc-linux-gnu) How to reproduce the issue: Build any source with ```-save-temps -g```, then ```warning: inconsistent use of MD5 checksums``` will be generated in assembly stage. The root cause for this is probably that the output assembly for ```-save-temps -g``` holds two ```.file``` directives (with/without build directory", but only the above one holds MD5 sequence. Output assembly format: ```asm foo: # @foo .Lfunc_begin0: .file 0 "/your/path/your/project" "FILE.c" md5 <MD5_SEQUENCE> .file 1 "FILE.c" ... ```
KJTsanaktsidis commented 8 months ago

Thanks for looking at this @MaskRay. Unfortunately I'm still getting this issue with --save-temps even with your patch:

% /opt/llvm-head/bin/clang -v
clang version 19.0.0git (https://github.com/llvm/llvm-project.git bec7181d5b9d1828129d78d440fd9e02d5cb63e8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/12
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/13
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/13
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

Your reproduction from the commit message in https://github.com/llvm/llvm-project/commit/831484efa06bee798e218813cb1890ef108ed519 does not print a warning:

% cat a.c
void f() {}
# None of these print a warning
% void f() {}
% vim a.c
% /opt/llvm-head/bin/clang -c -g a.c
% /opt/llvm-head/bin/clang -E a.c -o a.i
% /opt/llvm-head/bin/clang -g -S a.i
% /opt/llvm-head/bin/clang -g -c a.s

But passing --save-temps still does:

% /opt/llvm-head/bin/clang -g --save-temps -c a.c -o a.o
a.s:9:2: warning: inconsistent use of MD5 checksums
        .file   1 "a.c"
        ^

Anything I can do to help?

MaskRay commented 8 months ago

Thanks for the follow-up. #75022 fixed the spurious warning for

clang -c -g a.i -Xclang "-main-file-name" -Xclang "a.c"

and

clang -S -g a.i -o a.s && clang -c a.s

The last two steps of -save-temps -g looks like

clang -S -g a.i -Xclang "-main-file-name" -Xclang "a.c" -o a.s && clang -c a.s

The main file heuristic in CGDebugInfo::CreateCompileUnit does not handle the case. It's a bit unclear what we should do.

scienceplease commented 5 months ago

Still experiencing this issue on clang 18.1.1