[MacPorts] #68228: tree-sitter-cpp at 0.20.3: implicit declaration of function 'static_assert'

MacPorts noreply at macports.org
Sat Sep 23 04:59:35 UTC 2023


#68228: tree-sitter-cpp at 0.20.3: implicit declaration of function 'static_assert'
----------------------+-----------------------------
 Reporter:  acjones8  |      Owner:  (none)
     Type:  defect    |     Status:  new
 Priority:  Normal    |  Milestone:
Component:  ports     |    Version:
 Keywords:            |       Port:  tree-sitter-cpp
----------------------+-----------------------------
 When trying to build tree-sitter-cpp with GCC 12, the build fails and this
 error appears during the process:
 {{{
 --->  Building tree-sitter-cpp
 scanner.c: In function 'tree_sitter_cpp_external_scanner_serialize':
 scanner.c:128:5: warning: implicit declaration of function 'static_assert'
 [-Wimplicit-function-declaration]
   128 |     static_assert(RAW_STRING_DELIMITER_MAX * sizeof(wchar_t) <
       |     ^~~~~~~~~~~~~
 Undefined symbols:
   "_static_assert", referenced from:
       _tree_sitter_cpp_external_scanner_serialize in scanner.o
 ld: symbol(s) not found
 collect2: error: ld returned 1 exit status
 }}}

 As `static_assert` is a feature introduced in C11, it would seem that the
 problem comes from the compiler not being in C11 mode, but adding
 `compiler.cxx_standard 2011` or `compiler.c_standard 2011` doesn't help,
 and neither does `configure.cflags-append -std=c11`. However, if the
 `static_assert` is manually deleted from the source code, or `-std=c99` is
 passed in, the code compiles fine. Additionally, changing the
 `static_assert` to `_Static_assert` also allows it to build without issue.

 This bears a striking similarity to #64113, and in that ticket, it appears
 that upstream decided to change `static_assert` to `_Static_assert` for
 better compatibility. Assuming this bug also affects the same versions of
 Clang/GCC as the xxHash one does, it might be reasonable to add a patch
 that applies the same change to tree-sitter.

-- 
Ticket URL: <https://trac.macports.org/ticket/68228>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list