rougier / freetype-py

Python binding for the freetype library
Other
298 stars 88 forks source link

support for ARM builds #134

Closed mammo0 closed 3 years ago

mammo0 commented 3 years ago

Hello,

during the build process on a Raspberry Pi I got an error from cmake, that the -m32 or -m64 flag is not supported on this platform.

So I reworked the code to detect not only if the system is 32/64bit but also if it's an ARM system. There's also support for aarch64.

HinTak commented 3 years ago

You are going about it the wrong way - multi-arch build is only ever useful when the cpu is x86_64 (Linux /windows /mac os...) so you should conditioned on if x86_64. I heard that there are multi-arch raspberry pi distro/systems out there with armhf+aarch64 too though - not sure if they are switchable by -m32/m64.

Anyway, why do you want to build freetype on pi when it is available system-wide (and "./configure && make" works?)

HinTak commented 3 years ago

I'd suggest you change it to conditioning on x86_64 / x64 (for windows too) instead ; but mixed-arch raspberrypi system exists (64-bit kernel with 32-bit userland, etc), though not yet common, so I am not sure what purpose this change serve.

mammo0 commented 3 years ago

First thanks for the quick response. But I don't really get your point...

My purpose is not a multiarch build on a x86_64 machine. I had just the issue, that if I manually build the freetype library with FREETYPEPY_BUNDLE_FT on my Pi, cmake complained about the -m32/-m64 flag. And it seems that those flags are not supported on arm. So I added a new case, that checks if the build system is on running on ARM. If so, it simply doesn't add those flags.

Anyway, why do you want to build freetype on pi when it is available system-wide (and "./configure && make" works?)

I stumbled about this issue because for my project I needed a freetype library, that was compiled with libpng support (see my PR #133). After successfully building the library with libpng on my x86_64 PC, I tried it on my Pi. There I got the above mentioned error.

HinTak commented 3 years ago

You tested on platform != aarch64. But aarch64 is not the one that needs special treatment. x86_64 / x64 is.

mammo0 commented 3 years ago

I test on platform != arm and platform != aarch64 to check if it's ARM or not... Otherwise the the old behavior is used.

HinTak commented 3 years ago

You should test on platform == x86_64 instead. I wrote at the very beginning. That said, biarch armhf/aarch64 systems, although much rarer than x86_64 biarch systems, are around.

mammo0 commented 3 years ago

Ok, then I will switch the if-statement.

Edit: Will do it after the Christmas holidays ;)

mammo0 commented 3 years ago

Hello @HinTak, please check my latest commit (f0c6bd8) in this PR. Is that how you meant it?

HinTak commented 3 years ago

The change, as is, is okay now, I think, but I just spotted a "problem" in the surrounding code: as I said, the special case is x86_64, not linux. People routinely use both 32-bit and 64-bit freetype on 64-bit (intel) windows too, and both 32-bit and 64-bit freetype on 64-bit Mac OS too, until OS X 15 (when they officially dropped 32-bit support, I think). So special-case'ing on linux seems wrong.

Anyway, I would say merge this as is now. If somebody care enough about bi-arch on 64-bit windows and mac os x, they can add some more code later.

HinTak commented 3 years ago

gcc on Mingw and Mac OS X takes -m32/-m64 too, like their linux siblings.

mammo0 commented 3 years ago

Anyway, I would say merge this as is now. If somebody care enough about bi-arch on 64-bit windows and mac os x, they can add some more code later.

Thank you for approving this.