Opened 19 months ago
Last modified 13 months ago
#65992 assigned defect
py310-pycryptodome fails to build on 10.5.8: error: #error No routines for aligned memory; error: ‘for’ loop initial declaration used outside C99 mode
Reported by: | barracuda156 | Owned by: | catap (Kirill A. Korinsky) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.7.2 |
Keywords: | powerpc, leopard, snowleopard | Cc: | |
Port: | py310-pycryptodome, py-pycryptodome |
Description
There are numerous errors of the following kind:
In file included from src/MD2.c:28: src/common.h:179:2: error: #error No routines for aligned memory
And also:
In file included from src/ed25519.c:46: src/common.h:179:2: error: #error No routines for aligned memory src/ed25519.c: In function ‘ed25519_cmp’: src/ed25519.c:267: error: ‘for’ loop initial declaration used outside C99 mode src/ed25519.c:275: error: redefinition of ‘i’ src/ed25519.c:267: error: previous definition of ‘i’ was here src/ed25519.c:275: error: ‘for’ loop initial declaration used outside C99 mode
- S. The port also fails on 10.6 PPC in a same manner.
Attachments (1)
Change History (10)
Changed 19 months ago by barracuda156
comment:1 follow-up: 2 Changed 19 months ago by kencu (Ken)
comment:2 Changed 19 months ago by barracuda156
Replying to kencu:
As step 1 I would:
- add legacysupport
- add
configure.cflags-append -std=c99
For some reason it does not want to pass the flag. Weird. I will return to this.
comment:3 Changed 19 months ago by catap (Kirill A. Korinsky)
I'm wondering isn't it enough to setup compiler.c_standard
and compiler.cxx_standard
? Also, keep in mind that MacPorts contains two ports form near the same codebase: pycryptodome and pycryptodomex
comment:4 Changed 19 months ago by kencu (Ken)
the aligned memory functions I added to legacysupport…using a newer gcc would be unexpected to find them without it.
the usual fix for this:
error: ‘for’ loop initial declaration used outside C99 mode
is simply to enable C99 mode…the gcc-4.2 compiler defaults to c89, but gcc7 defaults to C11 so you could use that to get c99 mode if you can’t figure out how to get std=c99 onto the build line. MacPorts dislikes that kind of fix, as you know.
but have to actually try it to see what happens, of course.
comment:5 Changed 19 months ago by kencu (Ken)
Oh, these python ports are hard to manipulate.
Adding legacysupport does nothing, as it is not used even if added:
usr/bin/gcc-4.2 -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -pipe -Os -arch i386 -isysroot/ -DHAVE_STDINT_H -DPYCRYPTO_LITTLE_ENDIAN -DSYS_BITS=32 -DLTC_NO_ASM -DHAVE_EMMINTRIN_H -DUSE_SSE2 -DGCC_REALIGN -I/opt/local/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c src/raw_ocb.c -o build/temp.macosx-10.5-i386-cpython-310/src/raw_ocb.o -msse2
forcing gcc7 does fix the c99 errors, but the aligned memory issues still happen.
Perhaps we have to use the compiler wrapper PortGroup to get these python ports to obey the extra CFLAGS and LDFLAGS? Let me see...
comment:6 follow-ups: 7 8 9 Changed 19 months ago by kencu (Ken)
I personally find that making python ports do your bidding is hard.
I had trouble getting the compiler_wrapper PortGroup to make this work. I suspect the needed linker flags were not available during the testing phase for posix_memalign test file.
In the end, I added PortGroup legacysupport 1.0
and hacked this workaround into the Portfile
livecheck.type none + configure.cc ${configure.cc} -std=c99 -Wl,-lMacportsLegacySupport test.run yes
and it worked, building with the default gcc-4.2:
$ port -v installed py310-pycryptodome The following ports are currently installed: py310-pycryptodome @3.15.0_0 (active) requested_variants='' platform='darwin 9' archs='i386' date='2022-10-15T11:37:45-0700'
and it seemed to do OK on the test suite:
.................................................................................................................................................................................... ---------------------------------------------------------------------- Ran 2707 tests in 134.797s OK
that at least proves that this port can be built. What the elegant fix might be remains to be determined.
comment:7 Changed 17 months ago by barracuda156
Replying to kencu:
I personally find that making python ports do your bidding is hard.
and it seemed to do OK on the test suite:
.................................................................................................................................................................................... ---------------------------------------------------------------------- Ran 2707 tests in 134.797s OKthat at least proves that this port can be built. What the elegant fix might be remains to be determined.
Confirm that it builds with your fix on PPC and tests pass:
Ran 2707 tests in 258.449s OK
comment:8 Changed 17 months ago by barracuda156
Replying to kencu:
Could you/we make a PR with your fix? Or you aren’t yet sure about it?
comment:9 Changed 13 months ago by barracuda156
Replying to kencu:
Let’s merge it, otherwise people are unable to build it: https://forums.macrumors.com/threads/pycryptodomex-leopard-install-yewtube-former-mps-youtube.2386617/
As step 1 I would:
configure.cflags-append -std=c99