From: | Nikolay Shaplov <dhyan(at)nataraj(dot)su> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Coverage with clang will now works |
Date: | 2025-02-07 08:00:24 |
Message-ID: | 3398811.KgjxqYA5nG@thinkpad-pgpro |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi!
You most probably know, that you can't build coverage for check-world test
with clang. Postgreses tests are heavy, clang profile writer uses weak hash to
generate profile file names, and you will get hash collision if you try run
postgres tests, profile files will be broken and everything fails.
I asked colleagues that helps us with compilers to fix that problem, and they
offered a patch that allow to add binary ID to profile file name (do not even ask
me what is it) and that resolves that collision problem.
That patch have been just merged into llvm main branch
https://github.com/llvm/llvm-project/pull/123963, and it would be available at
next, 21th (or may be 20th) release.
We can test it now. Build llvm main branch
cmake -S llvm -B build -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;clang-
tools-extra" -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_RUNTIMES="compiler-rt" -
DLLVM_RUNTIME_TARGETS="x86_64-unknown-linux-gnu" -
DLLVM_BUILTIN_TARGETS="x86_64-unknown-linux-gnu"
worked for me. You will need a lot of disk space like 400Gb and some memory
(64Gb bill be best)
then build postgres with
CFLAGS="-fprofile-instr-generate -fcoverage-mapping -Wl,--build-id"
-Wl,--build-id is important part of it,
and then run check-world with LLVM_PROFILE_FILE evn-var having both %m and %b
in the name (But do not even try to add %p there, it breaks everything)
The rest can be done according usual clang coverage manual. And you will get
normal coverage.
May be somebody will add this clang coverage to postgres build system, and we
will have it via usual --enable-coverage. But that will not be me, I am no
expert in build system and I already have not commited commitfest patches to
take care about.
--
Nikolay Shaplov aka Nataraj
Fuzzing Engineer at Postgres Professional
Matrix IM: @dhyan:nataraj.su
From | Date | Subject | |
---|---|---|---|
Next Message | Bertrand Drouvot | 2025-02-07 08:05:41 | Re: Fix assert failure when decoding XLOG_PARAMETER_CHANGE on primary |
Previous Message | Japin Li | 2025-02-07 07:54:20 | Re: Trigger more frequent autovacuums of heavy insert tables |