Bug 291233 - llvm-cov complains about registered duplicated options and segfaults
Summary: llvm-cov complains about registered duplicated options and segfaults
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-26 08:00 UTC by Roger Pau Monné
Modified: 2025-12-01 12:05 UTC (History)
0 users

See Also:
dim: mfc-stable15+
dim: mfc-stable14+
dim: mfc-stable13+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Pau Monné freebsd_committer freebsd_triage 2025-11-26 08:00:35 UTC
llvm-cov segfaults, just executing `llvm-cov show` gives the following trace:

# llvm-cov show
: CommandLine Error: Option 'o' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace.
Stack dump:
0.	Program arguments: llvm-cov "llvm-cov show"
 #0 0x00002b6b9178c0e9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/src/contrib/llvm-p3
 #1 0x00002b6b91789e55 llvm::sys::RunSignalHandlers() /usr/src/contrib/llvm-project/llvm/lib/Suppo8
 #2 0x00002b6b9178c7f7 SignalHandler /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.i3
 #3 0x00002b6b95de681c handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
 #4 0x00002b6b95de5e2b thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:262:1
 #5 0x00002b6b8c3af2d3 ([vdso]+0x2d3)
 #6 0x00002b6b98a6da9a __sys_thr_kill /usr/obj/usr/src/amd64.amd64/lib/libsys/thr_kill.S:4:0
 #7 0x00002b6b977544c4 _raise /usr/src/lib/libc/gen/raise.c:0:10
 #8 0x00002b6b97805889 abort /usr/src/lib/libc/stdlib/abort.c:67:17
 #9 0x00002b6b9174303e llvm::report_fatal_error(llvm::Twine const&, bool) /usr/src/contrib/llvm-pr5
#10 0x00002b6b91742e79 (/usr/lib/libprivatellvm.so.19+0x4142e79)
#11 0x00002b6b9172b39b (/usr/lib/libprivatellvm.so.19+0x412b39b)
#12 0x00002b6b9171b374 addOption /usr/src/contrib/llvm-project/llvm/lib/Support/CommandLine.cpp:0:5
#13 0x00002b6b9171b374 llvm::cl::Option::addArgument() /usr/src/contrib/llvm-project/llvm/lib/Supp7
#14 0x00002b636b6adefb llvm::cl::alias::done() /usr/src/contrib/llvm-project/llvm/include/llvm/Sup5
#15 0x00002b636b6a8af4 llvm::cl::alias::alias<char [2], llvm::cl::desc, llvm::cl::aliasopt>(char c5
#16 0x00002b636b6a9372 doShow /usr/src/contrib/llvm-project/llvm/tools/llvm-cov/CodeCoverage.cpp:03
#17 0x00002b636b6a70a9 run /usr/src/contrib/llvm-project/llvm/tools/llvm-cov/CodeCoverage.cpp:960:2
#18 0x00002b636b6a53c9 showMain /usr/src/contrib/llvm-project/llvm/tools/llvm-cov/CodeCoverage.cpp5
#19 0x00002b636b6f129e main /usr/src/contrib/llvm-project/llvm/tools/llvm-cov/llvm-cov.cpp:81:14
#20 0x00002b6b97728eff __libc_start1 /usr/src/lib/libc/csu/libc_start1.c:180:2
Abort trap (core dumped)

This is on FreeBSD 16.0, but I was using 15.0 and got the same kind of error.
Comment 1 Roger Pau Monné freebsd_committer freebsd_triage 2025-11-26 08:03:42 UTC
FWIW, the llvm-cov19 from pkg llvm19 works fine:

# llvm-cov19 show
llvm-cov show: for the --instr-profile option: must be specified at least once!

So it's something that only affects the llvm-cov build from base.
Comment 2 commit-hook freebsd_committer freebsd_triage 2025-11-28 18:14:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9978553d0199e7ec0bdd1c44fc7f6c7b0c11e43b

commit 9978553d0199e7ec0bdd1c44fc7f6c7b0c11e43b
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-11-28 18:12:01 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-11-28 18:14:15 +0000

    Remove TableGen objects from libllvm, fixing bad option registrations

    In 986e05bc2a18 I revamped the build for all the llvm subprojects. Among
    others I added objects under contrib/llvm-project/llvm/lib/TableGen, but
    I missed that upstream explicitly removes these when building the shared
    llvm library:

    https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/llvm/tools/llvm-shlib/CMakeLists.txt#L23

    In 2e47f35be5dc I converted libllvm to a shared library. From that point
    onwards, some of the global command line option objects registered in
    llvm/lib/TableGen/Main.cpp conflict with similar objects in tools like
    llvm-cov, llvm-as, etc.

    This results in an error when running these tools: "CommandLine Error:
    Option 'o' registered more than once!", followed by a fatal exit.

    Fix this by removing the TableGen objects from libllvm. Note that we no
    longer install any of the tblgen binaries, these are only used during
    buildworld, and then in a statically linked form.

    PR:             291233
    MFC after:      3 days

 lib/clang/libllvm/Makefile | 10 ----------
 1 file changed, 10 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-12-01 11:57:50 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9636482dd8afcb426a658a98760bccf882196b4e

commit 9636482dd8afcb426a658a98760bccf882196b4e
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-11-28 18:12:01 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-12-01 11:57:06 +0000

    Remove TableGen objects from libllvm, fixing bad option registrations

    In 986e05bc2a18 I revamped the build for all the llvm subprojects. Among
    others I added objects under contrib/llvm-project/llvm/lib/TableGen, but
    I missed that upstream explicitly removes these when building the shared
    llvm library:

    https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/llvm/tools/llvm-shlib/CMakeLists.txt#L23

    In 2e47f35be5dc I converted libllvm to a shared library. From that point
    onwards, some of the global command line option objects registered in
    llvm/lib/TableGen/Main.cpp conflict with similar objects in tools like
    llvm-cov, llvm-as, etc.

    This results in an error when running these tools: "CommandLine Error:
    Option 'o' registered more than once!", followed by a fatal exit.

    Fix this by removing the TableGen objects from libllvm. Note that we no
    longer install any of the tblgen binaries, these are only used during
    buildworld, and then in a statically linked form.

    PR:             291233
    MFC after:      3 days

    (cherry picked from commit 9978553d0199e7ec0bdd1c44fc7f6c7b0c11e43b)

 lib/clang/libllvm/Makefile | 10 ----------
 1 file changed, 10 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-12-01 11:58:51 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1fbba4fbf0f88e551ca8d3bf759d29b0867ce03e

commit 1fbba4fbf0f88e551ca8d3bf759d29b0867ce03e
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-11-28 18:12:01 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-12-01 11:57:11 +0000

    Remove TableGen objects from libllvm, fixing bad option registrations

    In 986e05bc2a18 I revamped the build for all the llvm subprojects. Among
    others I added objects under contrib/llvm-project/llvm/lib/TableGen, but
    I missed that upstream explicitly removes these when building the shared
    llvm library:

    https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/llvm/tools/llvm-shlib/CMakeLists.txt#L23

    In 2e47f35be5dc I converted libllvm to a shared library. From that point
    onwards, some of the global command line option objects registered in
    llvm/lib/TableGen/Main.cpp conflict with similar objects in tools like
    llvm-cov, llvm-as, etc.

    This results in an error when running these tools: "CommandLine Error:
    Option 'o' registered more than once!", followed by a fatal exit.

    Fix this by removing the TableGen objects from libllvm. Note that we no
    longer install any of the tblgen binaries, these are only used during
    buildworld, and then in a statically linked form.

    PR:             291233
    MFC after:      3 days

    (cherry picked from commit 9978553d0199e7ec0bdd1c44fc7f6c7b0c11e43b)

 lib/clang/libllvm/Makefile | 10 ----------
 1 file changed, 10 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-12-01 11:58:51 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f4ff747cb709efeed3c1867060a81ae3ee72d474

commit f4ff747cb709efeed3c1867060a81ae3ee72d474
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-11-28 18:12:01 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-12-01 11:57:17 +0000

    Remove TableGen objects from libllvm, fixing bad option registrations

    In 986e05bc2a18 I revamped the build for all the llvm subprojects. Among
    others I added objects under contrib/llvm-project/llvm/lib/TableGen, but
    I missed that upstream explicitly removes these when building the shared
    llvm library:

    https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/llvm/tools/llvm-shlib/CMakeLists.txt#L23

    In 2e47f35be5dc I converted libllvm to a shared library. From that point
    onwards, some of the global command line option objects registered in
    llvm/lib/TableGen/Main.cpp conflict with similar objects in tools like
    llvm-cov, llvm-as, etc.

    This results in an error when running these tools: "CommandLine Error:
    Option 'o' registered more than once!", followed by a fatal exit.

    Fix this by removing the TableGen objects from libllvm. Note that we no
    longer install any of the tblgen binaries, these are only used during
    buildworld, and then in a statically linked form.

    PR:             291233
    MFC after:      3 days

    (cherry picked from commit 9978553d0199e7ec0bdd1c44fc7f6c7b0c11e43b)

 lib/clang/libllvm/Makefile | 10 ----------
 1 file changed, 10 deletions(-)