Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure on FreeBSD 14 with clang 16 and python3.9 #149

Closed
n12i opened this issue Apr 24, 2024 · 11 comments
Closed

Build failure on FreeBSD 14 with clang 16 and python3.9 #149

n12i opened this issue Apr 24, 2024 · 11 comments

Comments

@n12i
Copy link

n12i commented Apr 24, 2024

BUG/PROBLEM REPORT / FEATURE REQUEST

What I did:

mkdir Plone6 && cd Plone6
virtuanenv-3.9 zinstance
cd zinstance
bin/pip install zc.buildout
cat >buildout.cfg <<EOF
[buildout]
extends =
https://dist.plone.org/release/6-latest/versions.cfg

parts =
instance

[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = 8080
eggs =
Plone
EOF
./bin/buildout

What I expect to happen:

Generated script '.../Plone6/zinstance/bin/instance'.
Generated interpreter '.../Plone6/zinstance/parts/instance/bin/interpreter'.

What actually happened:

[snip]
creating build/temp.freebsd-14.0-RELEASE-p6-amd64-cpython-39/src/AccessControl
cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -Iinclude -Isrc -I/usr/home/nakaji/Plone6/zinstance/include -I/usr/local/include/python3.9 -c src/AccessControl/cAccessControl.c -o build/temp.freebsd-14.0-RELEASE-p6-amd64-cpython-39/src/AccessControl/cAccessControl.o
src/AccessControl/cAccessControl.c:428:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void ' [-Wint-conversion]
NULL, /
tp_print */
^~~~
/usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
#define NULL ((void *)0)
^~~~~~~~~~~
src/AccessControl/cAccessControl.c:487:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void ' [-Wint-conversion]
NULL, /
tp_print */
^~~~
/usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
#define NULL ((void *)0)
^~~~~~~~~~~
src/AccessControl/cAccessControl.c:546:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void ' [-Wint-conversion]
NULL, /
tp_print */
^~~~
/usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
#define NULL ((void *)0)
^~~~~~~~~~~
src/AccessControl/cAccessControl.c:616:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void ' [-Wint-conversion]
NULL, /
tp_print */
^~~~
/usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
#define NULL ((void *)0)
^~~~~~~~~~~
/usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
#define NULL ((void *)0)
^~~~~~~~~~~
src/AccessControl/cAccessControl.c:546:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void ' [-Wint-conversion]
NULL, /
tp_print */
^~~~
/usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
#define NULL ((void *)0)
^~~~~~~~~~~
src/AccessControl/cAccessControl.c:616:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void ' [-Wint-conversion]
NULL, /
tp_print */
^~~~
/usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
#define NULL ((void *)0)
^~~~~~~~~~~
4 errors generated.
error: command '/usr/bin/cc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for AccessControl
ERROR: Could not build wheels for AccessControl, which is required to install pyproject.toml-based projects
An error occurred when trying to install /tmp/tmpzakznsmqget_dist/AccessControl-6.3.tar.gz. Look above this message for any errors that were output by pip install.

What version of Python and Zope/Addons I am using:

% freebsd-version
14.0-RELEASE-p6
% ./bin/python --version
Python 3.9.18
% cc -v
FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
Target: x86_64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin

@icemac
Copy link
Member

icemac commented Apr 24, 2024

I would have expected that one of our pre-built wheels gets installed.
What happens if you create a new virtual environment and install AccessControl there via pip?

@n12i
Copy link
Author

n12i commented Apr 24, 2024

(modified, sorry)
% virtualenv-3.9 accesscontrol
% cd accesscontrol
% ./bin/pip install -v --no-cache-dir AccessControl
got the same NULL error.

cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2
-pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -Iinclude -Isrc -I/usr
/home/nakaji/Plone6/accesscontrol/include -I/usr/local/include/python3.9 -c src/
AccessControl/cAccessControl.c -o build/temp.freebsd-13.3-RELEASE-p1-amd64-cpyth
on-39/src/AccessControl/cAccessControl.o
src/AccessControl/cAccessControl.c:428:2: error: incompatible pointer to integ
er conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type
'void ' [-Wint-conversion]
428 | NULL, /
tp_print */
| ^~~~
/usr/include/sys/_null.h:32:14: note: expanded from macro 'NULL'
32 | #define NULL ((void *)0)
| ^~~~~~~~~~~
(snip)

Clang 16 says it is an error, and gcc13 just warns.

@n12i
Copy link
Author

n12i commented Apr 25, 2024

According to the error/warn message, I changed NULL to 0 and the build was successful.
Patch: https://www.heimat.gr.jp/~nakaji/FreeBSD/AccessControl.diff

@icemac
Copy link
Member

icemac commented Apr 25, 2024

@n12i Nice finding!
Could you please create a pull request with your diff to see the result on the systems we automatically test?

@d-maurer
Copy link
Contributor

d-maurer commented Apr 25, 2024 via email

@n12i
Copy link
Author

n12i commented Apr 25, 2024

If I have understood your initial report correctly, then the problem has been associated with a line associated with tp_print (a function pointer field) but the compiler expected a size field. This would be something serious -- not really resolved by replacing "NULL" by "0".

Agree. My patch can compile cAccessControl.c but I'm not sure if it works correctly.

Similar to these pull requests?
tgalal/python-axolotl-curve25519#26
tgalal/python-axolotl-curve25519#28
python-postgres/fe#125

@icemac
Copy link
Member

icemac commented May 29, 2024

There is now #150 merged, could you please try whether this also fixes your problem?

@davisagli
Copy link
Member

I have a project where I can't use the fix in #150 because it's an old project that requires an older major version of AccessControl.

Aside from the problem of casting a pointer to an integer, which is what #150 fixed, I think the problem started happening because clang made a change to raise an error instead of a warning in this scenario: https://reviews.llvm.org/D129881

It might be possible to build an older version of AccessControl by setting CFLAGS="-Wno-error=int-conversion" but I'm waiting for feedback from my colleague on whether this works.

@jessesnyder
Copy link

I can confirm that setting CFLAGS="-Wno-error=int-conversion" allowed me to build AccessControl-4.3-py3.8-macosx-14.5-arm64.egg.

@n12i
Copy link
Author

n12i commented Jun 26, 2024

There is now #150 merged, could you please try whether this also fixes your problem?

Thanks. This fixes my problem with one waning generated.

src/AccessControl/cAccessControl.c:2202:7: warning: code will never be executed [-Wunreachable-code]
2202 | unauthErr(name, v);
| ^~~~~~~~~
1 warning generated.

@icemac
Copy link
Member

icemac commented Aug 2, 2024

@n12i I think this warning was already there before.

@icemac icemac closed this as completed Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants