Bug 269253

Summary: devel/cmake-core: undefined symbol: nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation
Product: Ports & Packages Reporter: Christos Chatzaras <chris>
Component: Individual Port(s)Assignee: freebsd-kde (group) <kde>
Status: Closed FIXED    
Severity: Affects Some People CC: diizzy, edgeman, fluffy, grahamperrin, michael.osipov, omatsuda000, rhurlin, tijl
Priority: --- Flags: bugzilla: maintainer-feedback? (kde)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch none

Description Christos Chatzaras 2023-01-30 17:25:49 UTC
During a portupgrade I get this:


[ 31%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vssh/libssh.c.o
[ 32%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vssh/libssh2.c.o
[ 32%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vssh/wolfssh.c.o
[ 32%] Linking C static library libcmcurl.a
[ 32%] Built target cmcurl
[ 32%] Building C object Utilities/cmcurl/CMakeFiles/curltest.dir/curltest.c.o
[ 33%] Linking C executable curltest
ld: error: undefined symbol: nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation
>>> referenced by http2.c
>>>               http2.c.o:(Curl_http2_setup) in archive lib/libcmcurl.a
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
make[4]: stopped in /usr/ports/devel/cmake-core/work/cmake-3.25.1
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/devel/cmake-core/work/cmake-3.25.1
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/devel/cmake-core/work/cmake-3.25.1
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/devel/cmake-core
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/cmake-core

===>>> make build failed for devel/cmake-core
===>>> Aborting update

===>>> Update for devel/cmake-core failed
===>>> Aborting update

===>>> Update for devel/libcbor failed
===>>> Aborting update


===>>> You can restart from the point of failure with this command line:
       portmaster <flags> devel/libcbor devel/cmake-core graphics/webp dns/bind916 textproc/py-sphinx_rtd_theme@py39 www/nginx mail/postfix@default

This command has been saved to ~/portmasterfail.txt
Comment 1 Osamu Matsuda 2023-01-31 15:36:42 UTC
I had the same issue with my 13.1-RELEASE-p3 boxes.
During the bootstrap phase, cmake-core makes lib/libcmcurl.a with its own nghttp2 in /usr/ports/devel/cmake-core/work/cmake-3.25.1/Utilities.  Its version is 1.4.0.  But when libnghttp2-1.51.0 is installed through www/libnghttp2, cmake-core try to use its header files in the actual building phase.
nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation is defined in /usr/local/include/nghttp2/nghttp2.h but not included in libcmcurl.a.  This imcompatibility causes the said error.

A work around is to tell cmake-core to use libnghttp2 installed by ports instead of its own by changing 
  --no-system-nghttp2
of CONFIGURE_ARGS in /usr/ports/devel/cmake-core/Makefile to
  --system-nghttp2

or by applying the following patch to /usr/ports/devel/cmake-core/Makefile 

*** Makefile.orig       Sat Dec 24 07:42:16 2022
--- Makefile    Wed Jan 25 11:54:05 2023
***************
*** 34,40 ****
                --system-librhash \
                --system-libuv \
                --no-system-curl \
!               --no-system-nghttp2 \
                --parallel=${MAKE_JOBS_NUMBER} \
                --init="${WRKSRC}/InitialCache.cmake"

--- 34,40 ----
                --system-librhash \
                --system-libuv \
                --no-system-curl \
!               --system-nghttp2 \
                --parallel=${MAKE_JOBS_NUMBER} \
                --init="${WRKSRC}/InitialCache.cmake"

Strangely, this confusion does not always happen.  Among almost simiar 3 hosts of my possesion, two show this error, whereas the remaining one doesn't.  I couldn't find why.
Comment 2 Christos Chatzaras 2023-02-01 18:03:21 UTC
(In reply to Osamu Matsuda from comment #1)


I changed --no-system-nghttp2 with --system-nghttp2 but I get this:


-- Installing: /usr/ports/devel/cmake-core/work/stage/usr/local/share/emacs/site-lisp/cmake-mode.el
-- Installing: /usr/ports/devel/cmake-core/work/stage/usr/local/share/aclocal/cmake.m4
-- Installing: /usr/ports/devel/cmake-core/work/stage/usr/local/share/bash-completion/completions/cmake
-- Installing: /usr/ports/devel/cmake-core/work/stage/usr/local/share/bash-completion/completions/cpack
-- Installing: /usr/ports/devel/cmake-core/work/stage/usr/local/share/bash-completion/completions/ctest
install  -m 0644 /usr/ports/devel/cmake-core/work/cmake-3.25.1/Auxiliary/cmake-mode.el /usr/ports/devel/cmake-core/work/stage/usr/local/share/emacs/site-lisp
====> Compressing man pages (compress-man)
===>>> Starting check for runtime dependencies
===>>> Gathering dependency list for devel/cmake-core from ports
===>>> Dependency check complete for devel/cmake-core

===>>> All >> libcbor-0.9.0 >> devel/cmake-core (2/7)

===>  Installing for cmake-core-3.25.1
===>  Checking if cmake-core is already installed
===>   Registering installation for cmake-core-3.25.1 as automatic
pkg-static: Unable to access file /usr/ports/devel/cmake-core/work/stage/usr/local/share/doc/cmake/cmnghttp2/COPYING:No such file or directory
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/devel/cmake-core
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/cmake-core

===>>> Installation of cmake-core-3.25.1 (devel/cmake-core) failed
===>>> Aborting update
Comment 3 Osamu Matsuda 2023-02-02 06:25:47 UTC
Sorry.  I forgot to mention another dirty trick I used.

Please delete 
%%PORTDOCS%%%%DOCSDIR%%/cmnghttp2/COPYING
from /usr/ports/devel/cmake-core/pkg-plist

*** pkg-plist.orig      Sat Dec 24 07:42:16 2022
--- pkg-plist   Wed Jan 25 12:36:18 2023
***************
*** 3147,3153 ****
  %%DATADIR%%/include/cmCPluginAPI.h
  %%PORTDOCS%%%%DOCSDIR%%/Copyright.txt
  %%PORTDOCS%%%%DOCSDIR%%/cmcurl/COPYING
- %%PORTDOCS%%%%DOCSDIR%%/cmnghttp2/COPYING
  %%PORTDOCS%%%%DOCSDIR%%/cmsys/Copyright.txt
  share/aclocal/cmake.m4
  share/bash-completion/completions/cmake
--- 3147,3152 ----

Since we don't compile nghttp2 involved in cmake-core, there is no cmnghttp2/COPYING in the working directory of cmake-core build.
Comment 4 Christos Chatzaras 2023-02-02 10:34:28 UTC
Thank you. It works.

If I understood the issue correctly:

1) If you don't have libnghttp2 separately installed then cmake-core builds with an older version of libnghttp2 and the build is successful.

2) If you have libnghttp2 v1.5 then some header is not compatible and cmake-core doesn't build successfully.

So to get this resolved there are 3 options:

1) Add cmake-core a build dependency to libnghttp2 and use --system-nghttp2

2) Patch cmake-core to use libnghttp2 v1.5 header.

3) Wait for cmake-core to update their files to be compatible with libnghttp2 v1.5
Comment 5 Michael Osipov 2023-02-02 11:09:35 UTC
(In reply to Christos Chatzaras from comment #4)

I think the general approach is not to use bundled libs for many reasons. See also bash port which by default uses readline from ports, but you can select the bundled one. Should be here as well.
Comment 6 edgeman 2023-02-03 14:12:38 UTC
Thank you, making these two changes to the files resolves the issue for me as well. Also on 13.1-RELEASE-p3
Comment 7 Tijl Coosemans freebsd_committer freebsd_triage 2023-02-03 17:20:26 UTC
Created attachment 239888 [details]
patch

It can be solved by adding USES=localbase.
Comment 8 Osamu Matsuda 2023-02-04 00:44:37 UTC
(In reply to Tijl Coosemans from comment #7)
That also works and is simpler: pkg-plist is not necessary to be modified.
Thank you.
Comment 9 commit-hook freebsd_committer freebsd_triage 2023-02-04 09:09:38 UTC
A commit in branch main references this bug:

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

commit 1e149b25f57d04feeb5dc05ef33bed2f251e12bf
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2023-02-03 16:35:16 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2023-02-04 09:09:02 +0000

    devel/cmake-core: Fix build with libnghttp2 installed

    While building the bundled curl, -I/usr/local/include appears too early
    on the compiler command line causing the compiler to use headers from
    an installed libnghttp2 instead of the bundled libnghttp2.  Add
    USES=localbase so CFLAGS contains -isystem /usr/local/include making
    the compiler search the directory after all the -I flags.

    PR:             269253

 devel/cmake-core/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)