Bug 271533 - x11/xorgproto: ensure Xos.h does not define index() as a macro
Summary: x11/xorgproto: ensure Xos.h does not define index() as a macro
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: freebsd-x11 (Nobody)
URL:
Keywords:
Depends on:
Blocks: 271047
  Show dependency treegraph
 
Reported: 2023-05-20 15:22 UTC by Dimitry Andric
Modified: 2023-05-21 09:14 UTC (History)
1 user (show)

See Also:
manu: maintainer-feedback+


Attachments
x11/xorgproto: ensure Xos.h does not define index() as a macro (3.13 KB, patch)
2023-05-20 15:22 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 2023-05-20 15:22:25 UTC
During the exp-run for clang 16, it turned out that Xos.h defines
index() and rindex() as preprocessor macros, and this causes many
problems with libc++ headers [1]:

  /usr/include/c++/v1/variant:532:39: error: too few arguments provided to function-like macro invocation
      return __at(__fmatrix, __vs.index()...)(
                                        ^
  /usr/local/include/X11/Xos.h:67:12: note: macro 'index' defined here
  #   define index(s,c) (strchr((s),(c)))
             ^
  /usr/include/c++/v1/variant:813:18: error: too few arguments provided to function-like macro invocation
      return index() == variant_npos;
                   ^
  /usr/local/include/X11/Xos.h:67:12: note: macro 'index' defined here
  #   define index(s,c) (strchr((s),(c)))
             ^
  /usr/include/c++/v1/variant:817:25: error: expected ';' at end of declaration list
    constexpr size_t index() const noexcept {
                          ^
  /usr/include/c++/v1/variant:802:9: error: member initializer '__data' does not name a non-static data member or base class
        : __data(__tag), __index(__variant_npos<__index_t>) {}
          ^~~~~~~~~~~~~
  /usr/include/c++/v1/variant:808:9: error: member initializer '__data' does not name a non-static data member or base class
          __data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...),
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/include/c++/v1/variant:920:23: error: too few arguments provided to function-like macro invocation
            __rhs.index(),
                        ^
  /usr/local/include/X11/Xos.h:67:12: note: macro 'index' defined here
  #   define index(s,c) (strchr((s),(c)))
             ^

Add defined(__FreeBSD__) to Xos.h's #if block to include <strings.h>
instead, so it will get our regular index() and rindex() declarations
instead. This has also been sent upstream [2].

[1] <https://pkg-status.freebsd.org/gohan05/data/mainamd64PR271047-default/2023-05-14_19h35m09s/logs/errors/scim-1.4.9_7.log>
[2] <https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/73>
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2023-05-20 15:22:50 UTC
Created attachment 242295 [details]
x11/xorgproto: ensure Xos.h does not define index() as a macro
Comment 2 Emmanuel Vadot freebsd_committer freebsd_triage 2023-05-21 04:31:01 UTC
You need to bump PORTREVISION as the content of the package will change, otherwise looks good.
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-05-21 09:14:02 UTC
A commit in branch main references this bug:

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

commit e5a0215417930a60ac8fbbc630fad6aa354446e5
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-05-20 15:15:41 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-05-21 09:12:30 +0000

    x11/xorgproto: ensure Xos.h does not define index() as a macro

    During the exp-run for clang 16, it turned out that Xos.h defines
    index() and rindex() as preprocessor macros, and this causes many
    problems with libc++ headers [1]:

      /usr/include/c++/v1/variant:532:39: error: too few arguments provided to function-like macro invocation
          return __at(__fmatrix, __vs.index()...)(
                                            ^
      /usr/local/include/X11/Xos.h:67:12: note: macro 'index' defined here
      #   define index(s,c) (strchr((s),(c)))
                 ^
      /usr/include/c++/v1/variant:813:18: error: too few arguments provided to function-like macro invocation
          return index() == variant_npos;
                       ^
      /usr/local/include/X11/Xos.h:67:12: note: macro 'index' defined here
      #   define index(s,c) (strchr((s),(c)))
                 ^
      /usr/include/c++/v1/variant:817:25: error: expected ';' at end of declaration list
        constexpr size_t index() const noexcept {
                              ^
      /usr/include/c++/v1/variant:802:9: error: member initializer '__data' does not name a non-static data member or base class
            : __data(__tag), __index(__variant_npos<__index_t>) {}
              ^~~~~~~~~~~~~
      /usr/include/c++/v1/variant:808:9: error: member initializer '__data' does not name a non-static data member or base class
              __data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...),
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/include/c++/v1/variant:920:23: error: too few arguments provided to function-like macro invocation
                __rhs.index(),
                            ^
      /usr/local/include/X11/Xos.h:67:12: note: macro 'index' defined here
      #   define index(s,c) (strchr((s),(c)))
                 ^

    Add defined(__FreeBSD__) to Xos.h's #if block to include <strings.h>
    instead, so it will get our regular index() and rindex() declarations
    instead. This has also been sent upstream [2].

    [1] <https://pkg-status.freebsd.org/gohan05/data/mainamd64PR271047-default/2023-05-14_19h35m09s/logs/errors/scim-1.4.9_7.log>
    [2] <https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/73>

    PR:             271533
    Approved by:    manu (maintainer)
    MFH:            2023Q2

 x11/xorgproto/Makefile                            |  1 +
 x11/xorgproto/files/patch-include_X11_Xos.h (new) | 11 +++++++++++
 2 files changed, 12 insertions(+)
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2023-05-21 09:14:03 UTC
Note that in the mean time, upstream has applied my merge request:
https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/commit/6c3a7302fcc7ecf05960ad1794c5effeda5d4945