Opened 2 years ago

Last modified 6 weeks 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
  1. S. The port also fails on 10.6 PPC in a same manner.

Attachments (1)

main.log (81.2 KB) - added by barracuda156 2 years ago.

Download all attachments as: .zip

Change History (16)

Changed 2 years ago by barracuda156

Attachment: main.log added

comment:1 Changed 2 years ago by kencu (Ken)

As step 1 I would:

  1. add legacysupport
  2. add configure.cflags-append -std=c99

comment:2 in reply to:  1 Changed 2 years ago by barracuda156

Replying to kencu:

As step 1 I would:

  1. add legacysupport
  2. 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 2 years 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 2 years 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 2 years 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 Changed 2 years 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.

Last edited 2 years ago by kencu (Ken) (previous) (diff)

comment:7 in reply to:  6 Changed 22 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

OK

that 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 in reply to:  6 Changed 22 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 in reply to:  6 Changed 18 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/

comment:10 Changed 2 months ago by metallizer-br

I'm having the same problem trying to build py312-pycrytodome in OSX Tiger for smtube.

comment:11 in reply to:  10 Changed 7 weeks ago by garoffoli (garoffoli)

Replying to metallizer-br:

I'm having the same problem trying to build py312-pycrytodome in OSX Tiger for smtube.

I'm having the same issue as metallizer-br with py311-cryptodome in Tiger. It seems that all py3xx-cryptodome packages are broken on PowerPC

comment:12 in reply to:  3 Changed 7 weeks ago by ryandesign (Ryan Carsten Schmidt)

Replying to catap:

I'm wondering isn't it enough to setup compiler.c_standard and compiler.cxx_standard?

Setting compiler.c_standard or compiler.cxx_standard tells MacPorts what compiler to use. It doesn't add any flags like -std=…; that's for the build system to do, or the portfile if the build system doesn't do it.

comment:13 in reply to:  10 Changed 7 weeks ago by barracuda156

Replying to metallizer-br:

I'm having the same problem trying to build py312-pycrytodome in OSX Tiger for smtube.

Why smtube needs that at all? I certainly do not have py312-pycrytodome installed now, but I have smtube installed and working.

Version 0, edited 7 weeks ago by barracuda156 (next)

comment:14 in reply to:  6 Changed 6 weeks ago by garoffoli (garoffoli)

Replying to kencu:

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.

I tried this workaround with gcc7 on 10.4.11. It still didn't work at all. I need pycryptodome to try out LibreSpot-Python

comment:15 Changed 6 weeks ago by barracuda156

Well, I can’t test anything on 10.5. Given that I have the port installed from source, it should build for ppc at least with the current gcc. I can try reproducing that a bit later.

Note: See TracTickets for help on using tickets.