Opened 14 months ago
Closed 14 months ago
#68228 closed defect (fixed)
tree-sitter-cpp @0.20.3: implicit declaration of function 'static_assert'
Reported by: | acjones8 (Alex Jones) | Owned by: | amake (Aaron Madlon-Kay) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | ||
Port: | tree-sitter-cpp |
Description
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.
Change History (4)
comment:1 Changed 14 months ago by kencu (Ken)
comment:2 Changed 14 months ago by acjones8 (Alex Jones)
Ah, I should've checked legacy-support. Indeed, if I add it to the Portfile, that also causes it to build correctly. I think that's by far the best solution out of these, so I'm going to create a pull request for it. Thanks for the tip!
comment:3 Changed 14 months ago by ryandesign (Ryan Carsten Schmidt)
Owner: | set to amake |
---|---|
Status: | new → assigned |
Summary: | tree-sitter-cpp@0.20.3: implicit declaration of function 'static_assert' → tree-sitter-cpp @0.20.3: implicit declaration of function 'static_assert' |
comment:4 Changed 14 months ago by Alex Jones <24862823+acjones8@…>
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I added this to legacy support last year… you might try that…
https://github.com/macports/macports-legacy-support/commit/34588ddd014e7d8cd535a1574727f3513babe250