summaryrefslogtreecommitdiff
path: root/.ci
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@ovn.org>2022-07-25 14:19:39 +0200
committerIlya Maximets <i.maximets@ovn.org>2022-07-29 17:08:35 +0200
commit593b26e525040fbef407998e4f7331e502f3290d (patch)
tree327fa43368ac764662f1db9fde9b911a1ef2ba78 /.ci
parent791c47273983b830dbc840ae7bf18a23bc9e72e4 (diff)
downloadopenvswitch-593b26e525040fbef407998e4f7331e502f3290d.tar.gz
debian: Fix incorrect linkage of the python C extension.
Current version of debian/rules simply passes the libopenvswitch.a as a command line argument via LDFLAGS, but that doesn't actually lead to this library being statically linked into python extension, which is a shared library. Instead, the build "succeeds", but the resulted extension is not usable, because most of the symbols are missing: from ovs import _json ImportError: /usr/lib/python3/dist-packages/ovs/_json.cpython-310-x86_64-linux-gnu.so: undefined symbol: json_parser_finish '-lopenvswitch' with a path to a static library should be passed instead to make it actually statically linked. But even that is not enough as all the libraries that libopenvswitch.a was built with also has to be passed. Otherwise, we'll have unresolved symbols like ssl, cap-ng, etc. The most convenient way to get all the required libraries and cflags seems to be by using pkg-config. Setting several environment variables for pkg-config, so it can find the libopenvswitch.pc in non-standard directory, not skip default locations and also report them with the right base directory. Extra '-Wl,-Bstatic -lopenvswitch -Wl,-Bdynamic' is added before all the libs to ensure static linking of libopenvswitch even if the dynamic library is available in a system. One more problem here is that it is not possible to link static library into dynamic library if the static one is not position independent. So, we have to build everything with -fPIC, otherwise it's not possible to build C extensions. Also added a simple CI script to check that we're able to use python C extension after installing a package. Fixes: 6ad3be9749ab ("debian: Fix build of python json C extension.") Acked-by: Frode Nordahl <frode.nordahl@canonical.com> Reviewed-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to '.ci')
-rwxr-xr-x.ci/linux-build.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
index c396ec1e8..9746a8239 100755
--- a/.ci/linux-build.sh
+++ b/.ci/linux-build.sh
@@ -212,6 +212,13 @@ if [ "$DEB_PACKAGE" ]; then
echo $deps | xargs sudo apt -y install
# install the locally built openvswitch packages
sudo dpkg -i $packages
+
+ # Check that python C extension is built correctly.
+ python3 -c "
+from ovs import _json
+import ovs.json
+assert ovs.json.from_string('{\"a\": 42}') == {'a': 42}"
+
exit 0
fi