Bug 265519 - devel/libunwind: fix build with clang 15
Summary: devel/libunwind: fix build with clang 15
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Po-Chuan Hsieh
URL:
Keywords:
Depends on:
Blocks: 265425
  Show dependency treegraph
 
Reported: 2022-07-30 13:56 UTC by Dimitry Andric
Modified: 2022-07-31 17:20 UTC (History)
0 users

See Also:
sunpoet: maintainer-feedback+


Attachments
devel/libunwind: fix build with clang 15 (3.13 KB, patch)
2022-07-30 13:57 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2022-07-30 13:56:27 UTC
During an exp-run for llvm 15 (see bug 265425), it turned out that devel/libunwind fails to build with clang and lld 15, with multiple errors:

    setjmp/siglongjmp.c:111:48: error: incompatible pointer to integer conversion passing 'unw_word_t *' (aka 'unsigned long *') to parameter of type 'unw_word_t' (aka 'unsigned long'); remove & [-Wint-conversion]
              if (unw_set_reg (&c, UNW_REG_EH + 2, &wp[JB_MASK]) < 0)
                                                   ^~~~~~~~~~~~
    ../include/libunwind-common.h:283:56: note: passing argument to parameter here
    extern int unw_set_reg (unw_cursor_t *, int, unw_word_t);
                                                           ^

    dwarf/Gparser.c:901:5: error: call to undeclared function '_Ux86_64_stash_frame'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        tdep_stash_frame (c, rs);
        ^
    ../include/tdep-x86_64/libunwind_i.h:246:41: note: expanded from macro 'tdep_stash_frame'
    #define tdep_stash_frame                UNW_OBJ(stash_frame)
                                            ^

The first error is because the syntax is indeed wrong, the '&' should be
removed.

The second error is because tdep_stash_frame() is only declared for
Linux in libunwind_i.h, but it is used in Gparser.c. Declare it
unconditionally to fix the problem.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2022-07-30 13:57:26 UTC
Created attachment 235558 [details]
devel/libunwind: fix build with clang 15
Comment 2 Po-Chuan Hsieh freebsd_committer freebsd_triage 2022-07-30 20:35:33 UTC
LGTM. Thanks.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-07-31 17:19:19 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3c10c44304608e72d2d23f6a35998b21b2e195ee

commit 3c10c44304608e72d2d23f6a35998b21b2e195ee
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-07-30 13:54:37 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-07-31 17:18:48 +0000

    devel/libunwind: fix build with clang 15

    Building libunwind with clang results in multiple errors:

        setjmp/siglongjmp.c:111:48: error: incompatible pointer to integer conversion passing 'unw_word_t *' (aka 'unsigned long *') to parameter of type 'unw_word_t' (aka 'unsigned long'); remove & [-Wint-conversion]
                  if (unw_set_reg (&c, UNW_REG_EH + 2, &wp[JB_MASK]) < 0)
                                                       ^~~~~~~~~~~~
        ../include/libunwind-common.h:283:56: note: passing argument to parameter here
        extern int unw_set_reg (unw_cursor_t *, int, unw_word_t);
                                                               ^

        dwarf/Gparser.c:901:5: error: call to undeclared function '_Ux86_64_stash_frame'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            tdep_stash_frame (c, rs);
            ^
        ../include/tdep-x86_64/libunwind_i.h:246:41: note: expanded from macro 'tdep_stash_frame'
        #define tdep_stash_frame                UNW_OBJ(stash_frame)
                                                ^

    The first error is because the syntax is indeed wrong, the '&' should be
    removed.

    The second error is because tdep_stash_frame() is only declared for
    Linux in libunwind_i.h, but it is used in Gparser.c. Declare it
    unconditionally to fix the problem.

    PR:             265519
    Approved by:    sunpoet (maintainer)
    MFH:            2022Q3

 .../files/patch-include_tdep-x86__64_libunwind__i.h (new)   | 13 +++++++++++++
 devel/libunwind/files/patch-src_setjmp_siglongjmp.c (new)   | 11 +++++++++++
 2 files changed, 24 insertions(+)