[ovs-dev] [PATCH] Python: Build C JSON extension conditionally.

Tiago Lam tiago.lam at intel.com
Mon Oct 15 17:04:14 UTC 2018


Commit a7be68a ("Test the Python C JSON extension") enables the building
of the C JSON parser Python extension by default, which tries to link to
a shared library of libopenvswitch. On instalations where
"--enable-shared" is not specified, although the build ultimately
suceeds, it prints the following messages:

    /usr/bin/ld: ../ovs/ovs/lib/.libs/libopenvswitch.a(json.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    ../ovs/ovs/lib/.libs/libopenvswitch.a: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status

    ***************************************************************************

    WARNING: The C extension could not be compiled, speedups are not enabled.

    Failure information, if any, is above.

    Retrying the build without the C extension.

    ***************************************************************************

This pollutes the compilation logs and can cause some CIs to consider
the build as "FAILED", since words as "WARNING" and "error" will be
interpreted as such while parsing the logs.

Fixes: a7be68a ("Test the Python C JSON extension")
CC: Terry Wilson <twilson at redhat.com>
Signed-off-by: Tiago Lam <tiago.lam at intel.com>
---
 configure.ac       | 1 +
 m4/openvswitch.m4  | 3 +++
 python/automake.mk | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index 2b38003..5d52461 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,6 +136,7 @@ OVS_LIBTOOL_VERSIONS
 OVS_CHECK_CXX
 AX_FUNC_POSIX_MEMALIGN
 OVS_CHECK_UNBOUND
+OVS_CHECK_SHARED
 
 OVS_CHECK_INCLUDE_NEXT([stdio.h string.h])
 AC_CONFIG_FILES([
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 41042c9..989cbbb 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -698,3 +698,6 @@ AC_DEFUN([OVS_CHECK_UNBOUND],
    fi
    AM_CONDITIONAL([HAVE_UNBOUND], [test "$HAVE_UNBOUND" = yes])
    AC_SUBST([HAVE_UNBOUND])])
+
+AC_DEFUN([OVS_CHECK_SHARED],
+   AM_CONDITIONAL([SHARED_LIBRARY], [test "x$enable_shared" = xyes]))
diff --git a/python/automake.mk b/python/automake.mk
index 21547f7..149b2cd 100644
--- a/python/automake.mk
+++ b/python/automake.mk
@@ -93,6 +93,7 @@ python-sdist: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py
 pypi-upload: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py
 	(cd python/ && $(PYTHON) setup.py sdist upload)
 
+if SHARED_LIBRARY
 ALL_LOCAL += python-build
 python-build:$(lib_LTLIBRARIES)
 	(cd $(srcdir)/python/ && $(PYTHON) setup.py build_py -d $(abs_top_builddir)/python && $(PYTHON) setup.py build_ext -b $(abs_top_builddir)/python -I$(abs_top_srcdir)/include:$(abs_top_builddir)/include -L$(abs_top_builddir)/lib/.libs)
@@ -103,6 +104,7 @@ CLEAN_LOCAL += python-clean
 python-clean:
 	rm -rf $(abs_top_builddir)/python
 endif
+endif # SHARED_LIBRARY
 else
 ovs-install-data-local:
 	@:
-- 
2.7.4



More information about the dev mailing list