Hello,
I am working on an ARM9 based embedded product which runs software that
has OpenVSwitch integrated into it. The software has a few daemons written
in Python that perform JSON parsing to build the OVSDB IDL cache. These
operations are resulting in high CPU usage for prolonged intervals. This is
found to be due to the Python JSON parser that is being invoked. I learnt
that the OpenVSwitch already provides for a C based JSON parser as C-Python
extension which enables speed-ups. I checked that ovs._json module is not
present on the target which is resulting in Python parser to be
loaded/executed leading to the issue. Eventually I found it’s not even
being compiled. I have tried to enable it for compilation but am facing
issues which is where I need help.
Our product uses yocto to build/compile the codebase. We have a recipe
for openVSwitch to which I have added a compile_append() routine with the
following content to enable the _json.c compilation:
*do_compile_append() {*
* cd
${S}/python
*
* export BUILD_SYS=${BUILD_SYS}*
* export
HOST_SYS="${HOST_SYS}"
*
* export STAGING_LIBDIR="${STAGING_LIBDIR}"*
* export
STAGING_INCDIR="${STAGING_INCDIR}"
*
* ${STAGING_BINDIR_NATIVE}/python-native/python2.7 setup.py build
${DISTUTILS_BUILD_ARGS}
*
*}*
I have attached the “automake.mk” & “setup.py” scripts (python/
directory)too for reference here (as they may not be in sync with the
latest upstream OVS). With this, I see the build system tries to build the
extension however it fails with the following error:
*| running build*
*| running build_py*
*| copying ovs/json.py -> build/lib.linux-x86_64-2.7/ovs*
*| copying ovs/version.py -> build/lib.linux-x86_64-2.7/ovs*
*| running build_ext*
*| building 'ovs._json' extension*
| arm-cnos-linux-gnueabi-gcc -march=armv7-a
--sysroot=/build/tmp/sysroots/switch -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -O2 -pipe -ggdb3 -feliminate-unused-debug-types
-fdebug-prefix-map=/build/tmp/work/armv7a-cnos-linux-gnueabi/ops-openvswitch/1.0-r0_switch=/usr/src/debug/ops-openvswitch/1.0-r0_switch
-fdebug-prefix-map=/build/tmp/sysroots/x86_64-linux=
-fdebug-prefix-map=/build/tmp/sysroots/switch= -DOPS -fPIC -INone -I
/build/tmp/sysroots/dover/usr/include/python2.7 -c ovs/_json.c -o
build/temp.linux-x86_64-2.7/ovs/_json.o
| ovs/_json.c:2:30: fatal error: openvswitch/json.h: No such file or
directory
I tried several option, to the best of my knowledge, to pass he include
path to the build system (using include_dirs in setup.py, through
automake.mk etc). But I can’t seem to get my head around this. I am a
novice to yocto & autotools. I am starting to doubt if the approach I am
following is even correct?
Any guidance on how I can resolve this is really appreciated. Also let
me know if the details provided are insufficient.
Thanks in advance,
automake.mk
Description: Binary data
from __future__ import print_function
import sys
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsExecError, \
DistutilsPlatformError
import setuptools
import os
VERSION = "unknown"
try:
# Try to set the version from the generated ovs/version.py
execfile("ovs/version.py")
except IOError:
print("Ensure version.py is created by running make python/ovs/version.py",
file=sys.stderr)
sys.exit(-1)
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
if sys.platform == 'win32':
ext_errors += (IOError, ValueError)
class BuildFailed(Exception):
pass
class try_build_ext(build_ext):
# This class allows C extension building to fail
# NOTE: build_ext is not a new-style class
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError:
raise BuildFailed()
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except ext_errors:
raise BuildFailed()
include_dirs = os.environ.get('OVS_INCLUDE_DIR')
#library_dirs = os.environ.get('OVS_LIB_DIR', '.')
#include_dirs = os.environ.get('includedir')
#library_dirs = os.environ.get('libdir')
print(os.environ.keys())
setup_args = dict(
name='ovs',
description='Open vSwitch library',
version=VERSION,
url='http://www.openvswitch.org/',
author='Open vSwitch',
author_email='[email protected]',
packages=['ovs', 'ovs.db', 'ovs.unixctl'],
keywords=['openvswitch', 'ovs', 'OVSDB'],
license='Apache 2.0',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Topic :: Database :: Front-Ends',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Networking',
'License :: OSI Approved :: Apache Software License'
],
ext_modules=[setuptools.Extension("ovs._json", sources=["ovs/_json.c"],
libraries=['openvswitch'],
#include_dirs=[includedir, includedir + '/ovs' ],
#library_dirs=[libdir]
include_dirs=[include_dirs],
#library_dirs=[library_dirs]
)],
cmdclass={'build_ext': try_build_ext},
)
try:
setuptools.setup(**setup_args)
except BuildFailed:
BUILD_EXT_WARNING = ("WARNING: The C extension could not be compiled, "
"speedups are not enabled.")
print("*" * 75)
print(BUILD_EXT_WARNING)
print("Failure information, if any, is above.")
print("Retrying the build without the C extension.")
print("*" * 75)
del(setup_args['cmdclass'])
del(setup_args['ext_modules'])
setuptools.setup(**setup_args)
_______________________________________________ discuss mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-discuss
