[CDRIVER-3022] mongo-c-driver-1.14.0: wrong version in pkg-config files Created: 18/Mar/19  Updated: 27/Oct/23  Resolved: 20/May/19

Status: Closed
Project: C Driver
Component/s: libbson
Affects Version/s: 1.14.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: hydrapolic Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux Gentoo


Issue Links:
Depends
depends on CDRIVER-2968 Remove GitPython from calc_release_ve... Closed
Related
related to CDRIVER-3034 Reorganize installation documentation Closed
related to CDRIVER-3137 Error if unable to calculate BUILD_VE... Closed
related to CXX-1781 Error if unable to calculate BUILD_VE... Closed

 Description   

PHP's pecl-mongodb fails to build with libbson 1.14.0:
checking for pkg-config... /usr/bin/pkg-config
checking for libbson... configure: error: system libbson must be upgraded to version >= 1.13.0

 

It's because the pkg-config files of libbson report version 0.0.0 being installed.

 

— mongo-c-driver-1.13.1/src/libbson/libbson-1.0-config.cmake 2019-03-18 08:13:11.245695549 +0100
+++ mongo-c-driver-1.14.0/src/libbson/libbson-1.0-config.cmake 2019-03-18 08:35:53.204418839 +0100
-set (BSON_MAJOR_VERSION 1)
-set (BSON_MINOR_VERSION 13)
-set (BSON_MICRO_VERSION 1)
-set (BSON_VERSION 1.13.1)
+set (BSON_MAJOR_VERSION 0)
+set (BSON_MINOR_VERSION 0)
+set (BSON_MICRO_VERSION 0)
+set (BSON_VERSION 0.0.0)

 

Also tried the master branch, same version 0.0.0.



 Comments   
Comment by Kevin Albertson [ 20/May/19 ]

roberto.sanchez I'm closing this ticket and will make a new one for the TODO item mentioned in your last comment.

Comment by Roberto Sanchez [ 21/Mar/19 ]

The issue identified here is that even if the build version is not specified in one of the three available ways (from the VERSION_CURRENT file, as is shipped with a release tarball, from the GIt history, as is done when building from a fresh clone of the repository, or by setting the BUILD_VERSION variable on the CMake command line), the build sets the version to 0.0.0 and continues. This is sometimes OK (like when developing on the C driver itself without any intent of using the build output for anything), but causes problems.

The solution is to abort the build if the version is not set by one of the three available mechanisms. However, before that change can made CDRIVER-2968 must be fixed so that GItPython is no longer a dependency of the version calculation script used when building from Git.

Comment by hydrapolic [ 21/Mar/19 ]

Ok, that works. Thanks, will adjust the link.

Comment by Kevin Albertson [ 19/Mar/19 ]

hydrapolic Use the tarball attached to the GitHub release (instead of the one GitHub produces):
https://github.com/mongodb/mongo-c-driver/releases/download/1.14.0/mongo-c-driver-1.14.0.tar.gz

The tarball that GitHub produces does not contain the version information needed to build the repository. That should produce the correct version in the pkg-config file.

Comment by hydrapolic [ 19/Mar/19 ]

Seems like the 1.13.1 tarball contains VERSION_CURRENT and VERSION_RELEASED - both statically contain the string 1.13.1. Version 1.14.0 does not contain those files and the python script build/calc_release_version.py fails to run.

 

mongo-c-driver-1.13.1 $ cmake .
– The C compiler identification is ;GNU 8.3.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– No CMAKE_BUILD_TYPE selected, defaulting to RelWithDebInfo
– Using bundled libbson
libbson version (from VERSION_CURRENT file): 1.13.1

mongo-c-driver-1.14.0 $ cmake .
– The C compiler identification is ;GNU 8.3.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– No CMAKE_BUILD_TYPE selected, defaulting to RelWithDebInfo
– Found PythonInterp: /usr/bin/python (found version "2.7.16")
Traceback (most recent call last):
File "build/calc_release_version.py", line 182, in <module>
RELEASE_VER = previous(main()) if PREVIOUS else main()
File "build/calc_release_version.py", line 91, in main
repo = Repo('.')
File "/usr/lib64/python2.7/site-packages/git/repo/base.py", line 168, in _init_
raise InvalidGitRepositoryError(epath)
git.exc.InvalidGitRepositoryError: mongo-c-driver-1.14.0
CMake Warning at CMakeLists.txt:10 (_message):
BUILD_VERSION not specified and could not be calculated (script invocation
failed); setting library version to 0.0.0
Call Stack (most recent call first):
CMakeLists.txt:97 (message)

storing BUILD_VERSION 0.0.0 in file VERSION_CURRENT for later use
– Using bundled libbson
libbson version (from VERSION_CURRENT file): 0.0.0

Comment by hydrapolic [ 19/Mar/19 ]

It was all compiled from source by using Gentoo ebuilds. The diff posted above can be obtained by:

wget https://github.com/mongodb/mongo-c-driver/archive/1.13.1.tar.gz
tar xvf 1.13.1.tar.gz
cd mongo-c-driver-1.13.1
cmake . && make -j4

wget https://github.com/mongodb/mongo-c-driver/archive/1.14.0.tar.gz
tar xvf 1.14.0.tar.gz
cd mongo-c-driver-1.14.0
cmake . && make -j4

diff -u mongo-c-driver-1.13.1/src/libbson/libbson-1.0-config.cmake mongo-c-driver-1.14.0/src/libbson/libbson-1.0-config.cmake

We try to unbundle dependencies and we compile pecl-mongodb from source using system libraries. That's when it tries
to read pkgconfig of libbson and reads version 0.0.0 and fails.

Libbson and mongo-c-driver are kept as shared libraries in the system and other consumers like pecl-mongodb use them when
we compile/install them.

Comment by Jeremy Mikola [ 18/Mar/19 ]

hydrapolic: Can you clarify how you're installing both the PHP driver and libmongoc/libbson libraries? You refer to the PECL package, but the the PECL install process for the driver uses bundled versions of libmongoc/libbson. Do I assume correctly that you're downloading the PECL package simply as a means of obtaining the driver's source?

I also want to confirm where you're getting the sources for libmongoc and libbson. The bundled versions included in the PECL package are merely git submodules. Your issue refers to "mongo-c-driver-1.13.1" and "mongo-c-driver-1.14.0" directories, which don't exist in the PECL package, so I assume you've downloaded those separately. Note that libmongoc/libbson have separate installation processes for installing from a release tarball or building from git. The release tarballs should already have their version files in order, so I believe you may have manually compiled libmongoc from a git checkout without running the calc_release_version.py script to generate VERSION_CURRENT.

If you're using the PHP driver and do not need libmongoc/libbson system libraries installed for other applications, I think your best option is to install the PHP driver through pecl install mongodb and use the bundled verisons of libbmongoc/libbson. Otherwise, if you're set on compiling the PHP driver manually and using libmongoc/libbson system libraries, please double check that you're following one of the documented install procedures for those libraries to ensure that the version information is properly generated.

Generated at Wed Feb 07 21:16:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.