Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGHTTP2_NO_SSIZE_T doesn't distinguish the needed to avoid building APIs #2219

Closed
cosmo0920 opened this issue Jul 5, 2024 · 4 comments · Fixed by #2224
Closed

NGHTTP2_NO_SSIZE_T doesn't distinguish the needed to avoid building APIs #2219

cosmo0920 opened this issue Jul 5, 2024 · 4 comments · Fixed by #2224

Comments

@cosmo0920
Copy link

cosmo0920 commented Jul 5, 2024

We bundled nghttp2 library as a bundled library.
When we tried to upgrade nghttp2 to v1.62.1, NGHTTP2_NO_SSIZE_T macro didn't take any effects for disabling APIs which were newly introduced nghttp2_ssize API.

When I was specified the NGHTTP2_NO_SSIZE_T macro in CMakeLists.txt like as:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d7b0a132..0a2e79ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,6 +35,8 @@ set(LT_AGE      28)
 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
 include(Version)

+add_definitions(-DNGHTTP2_NO_SSIZE_T=1)
+
 math(EXPR LT_SOVERSION "${LT_CURRENT} - ${LT_AGE}")
 set(LT_VERSION "${LT_SOVERSION}.${LT_AGE}.${LT_REVISION}")
 set(PACKAGE_VERSION     "${PROJECT_VERSION}")

Then, configure with:

PS> cmake .. -DBUILD_STATIC_LIBS=On -DBUILD_SHARED_LIBS=On -DBUILD_TESTING=Off -DNGHTTP2_NO_SSIZE_T=1 -G "NMake Makefiles"

and building with cmake:

PS> cmake --build .

Then, 💥

<snip>
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(46): error C2061: 構文エラー: 識別子 'nghttp2_data_provider'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(48): error C2059: 構文エラー: '}'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(49): error C2059: 構文エラー: '}'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(51): error C2143: 構文エラー: '{' が '*' の前にあり ません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(52): error C2143: 構文エラー: ')' が '*' の前にあり ません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(52): error C2143: 構文エラー: '{' が '*' の前にあり ません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(53): warning C4228: 非標準の拡張機能が使用されています: 宣言子リストにあるコンマの後の修飾子は無視されます。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(53): error C2143: 構文エラー: ';' が '*' の前にあり ません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(53): error C2059: 構文エラー: ')'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(55): error C2143: 構文エラー: '{' が '*' の前にあり ません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(56): error C2143: 構文エラー: ')' が '*' の前にあり ません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(56): error C2143: 構文エラー: '{' が '*' の前にあり ません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(57): error C2371: 'nghttp2_data_provider2': 再定義されています。異なる基本型です。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\includes\nghttp2/nghttp2.h(1087): note: 'nghttp2_data_provider2' の宣言を確 認してください
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(57): warning C4228: 非標準の拡張機能が使用されています: 宣言子リストにあるコンマの後の修飾子は無視されます。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(57): error C2143: 構文エラー: ';' が '*' の前にあり ません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(57): error C2059: 構文エラー: ')'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(61): error C2061: 構文エラー: 識別子 'nghttp2_data_provider_wrap'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(69): error C2059: 構文エラー: '}'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(76): error C2061: 構文エラー: 識別子 'nghttp2_data_provider_wrap'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(94): error C2059: 構文エラー: '}'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(122): error C2061: 構文エラー: 識別子 'nghttp2_data_aux_data'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(123): error C2061: 構文エラー: 識別子 'headers'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(123): error C2059: 構文エラー: ';'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(126): error C2059: 構文エラー: '}'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(136): error C2061: 構文エラー: 識別子 'nghttp2_aux_data'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_outbound_item.h(149): error C2059: 構文エラー: '}'
・<・ インクルード ファイル:  C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\assert.h
・<・ インクルード ファイル:  C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\stdio.h
・<・ インクルード ファイル:   C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\corecrt_wstdio.h
・<・ インクルード ファイル:    C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\corecrt_stdio_config.h
・<・ インクルード ファイル:  C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_session.h
・<・ インクルード ファイル:   C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(44): error C2061: 構文エラー: 識別子 'nghttp2_send_callback'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(58): error C2061: 構文エラー: 識別子 'recv_callback'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(58): error C2059: 構文エラー: ';'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(122): error C2061: 構文エラー: 識別子 'select_padding_callback'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(122): error C2059: 構文エラー: ';'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(134): error C2061: 構文エラー: 識別子 'read_length_callback'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(134): error C2059: 構文エラー: ';'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(148): error C2061: 構文エラー: 識別子 'pack_extension_callback'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(148): error C2059: 構文エラー: ';'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_callbacks.h(154): error C2059: 構文エラー: '}'
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_session.h(228): error C2079: 'callbacks' が 未定義の struct 'nghttp2_session_callbacks' で使用しています。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_session.h(875): error C2143: 構文エラー: ')' が '*' の前にありません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_session.h(875): error C2081: 'nghttp2_data_aux_data': 仮パラメーター リスト内の名前が正しくありません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_session.h(875): error C2143: 構文エラー: '{' が '*' の前にありません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_session.h(876): error C2371: 'nghttp2_stream': 再定義されています。 異なる基本型です。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\includes\nghttp2/nghttp2.h(6791): note: 'nghttp2_stream' の宣言を確認してく ださい
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_session.h(876): error C2143: 構文エラー: ';' が '*' の前にありません。
C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_session.h(876): error C2059: 構文エラー: ')'
・<・ インクルード ファイル:    C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\corecrt_memory.h
・<・ インクルード ファイル:      C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\vcruntime_string.h
・<・ インクルード ファイル:    C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\corecrt_wstring.h
・<・ インクルード ファイル:  C:\Users\cosmo\Documents\GitHub\nghttp2\lib\nghttp2_debug.h
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\nghttp2.dir\nghttp2_stream.c.obj.d --working-dir=C:\Users\cosmo\Documents\GitHub\nghttp2\build\lib --filter-prefix="メモ:  インクルード ファイル:  " -- C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1438~1.331\bin\Hostx64\x64\cl.exe @C:\Users\cosmo\AppData\Local\Temp\nm31C2.tmp' : リターン コード '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\nmake.exe" -s -f lib\CMakeFiles\nghttp2.dir\build.make /nologo -SL                 lib\CMakeFiles\nghttp2.dir\build' : リターン コード '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\nmake.exe" -s -f CMakeFiles\Makefile2 /nologo -LS                 all' : リターン コード '0x2'
Stop.
@tatsuhiro-t
Copy link
Member

NGHTTP2_NO_SSIZE_T should not be used when building libnghttp2 itself.

@tatsuhiro-t
Copy link
Member

When we tried to upgrade nghttp2 to v1.62.1, NGHTTP2_NO_SSIZE_T macro didn't take any effects for disabling APIs which were newly introduced nghttp2_ssize API.

You also misunderstand how NGHTTP2_NO_SSIZE_T works. It hides APIs which use ssize_t, not nghttp2_ssize.

@edsiper
Copy link

edsiper commented Jul 6, 2024

@tatsuhiro-t what would be the workaround for this compilation problem ?

https://github.com/fluent/fluent-bit/actions/runs/9801313179/job/27064460050?pr=9046#step:11:1731

@tatsuhiro-t
Copy link
Member

If you are upgrading nghttp2 from an older version which does only support ssize_t API, I think you can remove NGHTTP2_NO_SSIZE_T. If that is not possible, do not define NGHTTP2_NO_SSIZE_T when building libnghttp2. I do not know how to to this in cmake.
Meanwhile, I have a plan to ignore NGHTTP2_NO_SSIZE_T when BUILDING_NGHTTP2 is defined like we do for NGHTTP2_EXTERN, which workarounds this kind of issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants