From: Kefu Chai Date: Sun, 24 Mar 2024 12:23:00 +0000 (+0800) Subject: pybind: use LDFLAGS in env variable when check for building env X-Git-Tag: v20.0.0~2279^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f68248944815acbf5fb08ef66f36da6d5baef824;p=ceph.git pybind: use LDFLAGS in env variable when check for building env when building python bindings extensions using Cython, we first perform sanity checks by building an executable and linking it against the shared library of the C language binding. if the executable builds, we consider the sanity test passes. before this change, we don't add `LDFLAGS` specified in environmental variable to the ldflags when building the executable. but we need to link against libasan, so that the symbols used by, for instance, librados.so, can be found by the executable. in this change, we always check `LDFLAGS`, and add it to the ldflags when building the executable for testing, if it's set. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/cephfs/setup.py b/src/pybind/cephfs/setup.py index f6c2025f75d35..956a4e7008c6a 100755 --- a/src/pybind/cephfs/setup.py +++ b/src/pybind/cephfs/setup.py @@ -117,10 +117,15 @@ def check_sanity(): extra_preargs=['-iquote{path}'.format(path=os.path.join(CEPH_SRC_DIR, 'include'))] ) + if ldflags := os.environ.get('LDFLAGS'): + extra_postargs = ldflags.split() + else: + extra_postargs = None compiler.link_executable( objects=link_objects, output_progname=os.path.join(tmp_dir, 'cephfs_dummy'), libraries=['cephfs'], + extra_postargs=extra_postargs, output_dir=tmp_dir, ) diff --git a/src/pybind/rados/setup.py b/src/pybind/rados/setup.py index 62b54d26b6c81..000189b7da134 100755 --- a/src/pybind/rados/setup.py +++ b/src/pybind/rados/setup.py @@ -112,10 +112,15 @@ def check_sanity(): sources=[tmp_file], output_dir=tmp_dir ) + if ldflags := os.environ.get('LDFLAGS'): + extra_postargs = ldflags.split() + else: + extra_postargs = None compiler.link_executable( objects=link_objects, output_progname=os.path.join(tmp_dir, 'rados_dummy'), libraries=['rados'], + extra_postargs=extra_postargs, output_dir=tmp_dir, ) diff --git a/src/pybind/rbd/setup.py b/src/pybind/rbd/setup.py index eeb33c73d49b3..b03d1c3fc9576 100755 --- a/src/pybind/rbd/setup.py +++ b/src/pybind/rbd/setup.py @@ -116,10 +116,15 @@ def check_sanity(): output_dir=tmp_dir ) + if ldflags := os.environ.get('LDFLAGS'): + extra_postargs = ldflags.split() + else: + extra_postargs = None compiler.link_executable( objects=link_objects, output_progname=os.path.join(tmp_dir, 'rbd_dummy'), libraries=['rbd', 'rados'], + extra_postargs=extra_postargs, output_dir=tmp_dir, ) diff --git a/src/pybind/rgw/setup.py b/src/pybind/rgw/setup.py index ed45399d39469..eb8fc554db6ee 100755 --- a/src/pybind/rgw/setup.py +++ b/src/pybind/rgw/setup.py @@ -116,10 +116,15 @@ def check_sanity(): output_dir=tmp_dir, ) + if ldflags := os.environ.get('LDFLAGS'): + extra_postargs = ldflags.split() + else: + extra_postargs = None compiler.link_executable( objects=link_objects, output_progname=os.path.join(tmp_dir, 'rgw_dummy'), libraries=['rgw', 'rados'], + extra_postargs=extra_postargs, output_dir=tmp_dir, )