libselinux: set CFLAGS for pip installation
PATCH 1/1 libselinux: set CFLAGS for pip installation
Explicitly set CFLAGS for the pip install command, similar to calling setup.py, to ignore known compiler warnings treated as errors, e.g.:
selinuxswig_python_wrap.c:3593:19: error: 'sidget' is deprecated [-Werror,-Wdeprecated-declarations]
result = (int)sidget(arg1);
^
selinuxswig_python_wrap.c:15024:1: error: no previous prototype for function 'PyInit__selinux' [-Werror,-Wmissing-prototypes]
SWIG_init(void) {
^---
fixes GitHub CI, see https://github.com/SELinuxProject/selinux/pull/388
--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/Makefile +1 -1
@@ -187,7 +187,7 @@ install: all ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET) install-pywrap: pywrap - $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . + CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
Signature · 1 line
2.40.0
Quoted 11 lines · Christian Göttsche
Explicitly set CFLAGS for the pip install command, similar to calling
setup.py, to ignore known compiler warnings treated as errors, e.g.:selinuxswig_python_wrap.c:3593:19: error: 'sidget' is deprecated [-Werror,-Wdeprecated-declarations] result = (int)sidget(arg1); ^ selinuxswig_python_wrap.c:15024:1: error: no previous prototype for function 'PyInit__selinux' [-Werror,-Wmissing-prototypes] SWIG_init(void) { ^Signed-off-by Christian Göttsche <[email protected]>
It looks like a problem in build system - selinuxswig_python_wrap.o is built twice, first time by
pywrap: all selinuxswig_python_exception.i
CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_ext
clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations -Wno-deprecated-declarations -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-3.9/selinuxswig_python_wrap.o
and second time by
install-pywrap: pywrap
$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-cpython-39/selinuxswig_python_wrap.o
I'd expect that it's built only in pywrap target and install-pywrap would just install it.
There's a difference in the output dir - build/temp.linux-x86_64-3.9 vs build/temp.linux-x86_64-cpython-39
Quoted 21 lines
---
fixes GitHub CI, see https://github.com/SELinuxProject/selinux/pull/388--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libselinux/src/Makefile +1
-1@@ -187,7 +187,7 @@ install: all ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET) install-pywrap: pywrap - $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . + CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)Signature · 1 line
2.40.0
Petr Lautrbach
Acked-byQuoted 27 lines · Petr Lautrbach
Quoted 11 lines · Christian Göttsche
Explicitly set CFLAGS for the pip install command, similar to calling
setup.py, to ignore known compiler warnings treated as errors, e.g.:selinuxswig_python_wrap.c:3593:19: error: 'sidget' is deprecated [-Werror,-Wdeprecated-declarations] result = (int)sidget(arg1); ^ selinuxswig_python_wrap.c:15024:1: error: no previous prototype for function 'PyInit__selinux' [-Werror,-Wmissing-prototypes] SWIG_init(void) { ^Signed-off-by Christian Göttsche <[email protected]>It looks like a problem in build system - selinuxswig_python_wrap.o is built twice, first time by
pywrap: all selinuxswig_python_exception.i
CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_extclang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations -Wno-deprecated-declarations -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c
selinuxswig_python_wrap.c-obuild/temp.linux-x86_64-3.9/selinuxswig_python_wrap.oand second time by
Quoted 8 lines
install-pywrap: pywrap
$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c
selinuxswig_python_wrap.c-obuild/temp.linux-x86_64-cpython-39/selinuxswig_python_wrap.oI'd expect that it's built only in pywrap target and install-pywrap would just install it.
So according to the internet, pip install does all setup.py operations [build_ext, build, install, ...] on it's own and therefore pywrap target with setup.py build seems to be useless.
But your change is necessary.
Quoted 23 lines
Quoted 23 lines
---
fixes GitHub CI, see https://github.com/SELinuxProject/selinux/pull/388--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libselinux/src/Makefile +1
-1@@ -187,7 +187,7 @@ install: all ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET) install-pywrap: pywrap - $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . + CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)Signature · 1 line
2.40.0
Quoted 39 lines · Petr Lautrbach
Quoted 27 lines · Petr Lautrbach
Quoted 11 lines · Christian Göttsche
Explicitly set CFLAGS for the pip install command, similar to calling
setup.py, to ignore known compiler warnings treated as errors, e.g.:selinuxswig_python_wrap.c:3593:19: error: 'sidget' is deprecated [-Werror,-Wdeprecated-declarations] result = (int)sidget(arg1); ^ selinuxswig_python_wrap.c:15024:1: error: no previous prototype for function 'PyInit__selinux' [-Werror,-Wmissing-prototypes] SWIG_init(void) { ^Signed-off-by Christian Göttsche <[email protected]>It looks like a problem in build system - selinuxswig_python_wrap.o is built twice, first time by
pywrap: all selinuxswig_python_exception.i
CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_extclang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations -Wno-deprecated-declarations -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c
selinuxswig_python_wrap.c-obuild/temp.linux-x86_64-3.9/selinuxswig_python_wrap.oand second time by
Quoted 8 lines
install-pywrap: pywrap
$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c
selinuxswig_python_wrap.c-obuild/temp.linux-x86_64-cpython-39/selinuxswig_python_wrap.oI'd expect that it's built only in pywrap target and install-pywrap would just install it.
Quoted 8 lines
So according to the internet, pip install does all
setup.pyoperations [build_ext, build, install, ...] on it's own and therefore pywrap target withsetup.py buildseems to be useless.But your change is necessary.
Acked-by Petr Lautrbach <[email protected]>
Merged.
Thanks,
Jim
Quoted 27 lines
Quoted 26 lines
Quoted 26 lines
---
fixes GitHub CI, see https://github.com/SELinuxProject/selinux/pull/388--- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libselinux/src/Makefile +1
-2@@ -187,7 +187,7 @@ install: all ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET) install-pywrap: pywrap - $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . + CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT) --2.40.0