]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: use LDFLAGS in env variable when check for building env
authorKefu Chai <tchaikov@gmail.com>
Sun, 24 Mar 2024 12:23:00 +0000 (20:23 +0800)
committerKefu Chai <tchaikov@gmail.com>
Tue, 26 Mar 2024 23:35:28 +0000 (07:35 +0800)
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 <tchaikov@gmail.com>
src/pybind/cephfs/setup.py
src/pybind/rados/setup.py
src/pybind/rbd/setup.py
src/pybind/rgw/setup.py

index f6c2025f75d3575e7395c103c4bd0411b03f0f42..956a4e7008c6aa4ad38874d6d6185f57ea1c3a65 100755 (executable)
@@ -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,
         )
 
index 62b54d26b6c81336549511a427da0a6d2e06dd2c..000189b7da134f96eed49b240b468c58421f48da 100755 (executable)
@@ -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,
         )
 
index eeb33c73d49b3184de8ac79a03038442197263c6..b03d1c3fc9576ebeb50cd539702689805d4c8501 100755 (executable)
@@ -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,
         )
 
index ed45399d394695daac2c4f8322223d8d1c65b0aa..eb8fc554db6eea6b15d47b9338e9d59fad68493d 100755 (executable)
@@ -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,
         )