Ultimaker / cura-build-environment

CMake project to build dependencies for Cura
GNU Affero General Public License v3.0
24 stars 55 forks source link

build fails on aarch64/arm64 (zlib and OpenSSL) #86

Closed janrinze closed 4 years ago

janrinze commented 4 years ago

./projects/zlib.cmake contains a platform dependent setting '--64'.

if(BUILD_OS_OSX OR BUILD_OS_LINUX)
    ExternalProject_Add(zlib
        URL https://www.zlib.net/zlib-1.2.11.tar.gz
        URL_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
        CONFIGURE_COMMAND ./configure --64 --prefix=${CMAKE_INSTALL_PREFIX}
        BUILD_COMMAND make
        INSTALL_COMMAND make install
        BUILD_IN_SOURCE 1
    )
endif()

When doing a native 64 bit build on aarch64 (rpi4 8GB) the configure command fails. Removing '--64' allows the zlib build to continue.

OpenSSL : in the file projects/openssl.cmake we find

 elseif(BUILD_OS_LINUX)
    set(_openssl_os linux-x86_64 enable-ec_nistp_64_gcc_128)
    set(_openssl_args no-ssl2 no-ssl3 no-zlib shared enable-cms)

When changed to :

 elseif(BUILD_OS_LINUX)
    set(_openssl_os linux-aarch64 enable-ec_nistp_64_gcc_128)
    set(_openssl_args no-zlib shared enable-cms)

that can build too.

Looks like a small set of changes to be able to build it on the Raspberry Pi 4 64bit and possibly other Aarch64 platforms.

It's still building and i hope to be able to report back on the results.

Ghostkeeper commented 4 years ago

Hmm, the commit that introduced the zlib build doesn't mention why it specifies the --64 explicitly. Normally I would like to have such things documented. Obviously we need to have a 64-bit build though to be linked to the other things we build 64-bit versions of.

However according to the source code it translates to a variable called "build64", which I would interpret as "build a 64-bit version". That should work fine on your architecture as well. The actual result is that the compiler command gets the extra flag -m64. Why doesn't that work on that aarch64 architecture?

I have little experience with building for ARM, mind you.

Ghostkeeper commented 4 years ago

We will not change the OpenSSL build to ARM64 because that's simply not what we need to distribute. We target desktops, not mobile phones or embedded devices.

janrinze commented 4 years ago

I am compiling for ARM64 Desktop.

janrinze@rpi8G:~$ uname -a
Linux rpi8G.local 5.4.51-v8+ #2 SMP PREEMPT Fri Jul 31 11:54:47 CEST 2020 aarch64 GNU/Linux
janrinze@rpi8G:~$ cat /etc/issue
Debian GNU/Linux bullseye/sid \n \l
Ghostkeeper commented 4 years ago

So why doesn't the -m64 flag work then? I'd expect that to work fine. Would you suggest we use a different flag to build Zlib for 64-bit that works with both AMD64 and ARM64?

janrinze commented 4 years ago

https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

-m64 is a specific x86 compiler option.

Ghostkeeper commented 4 years ago

Right, so the actual bug is that these compiler flags in zlib are not platform-independent, and don't support ARM64. Maybe we need to report this issue to zlib instead?

You're not the first to have issues compiling zlib for ARM64. But I can't tell if your errors are the same as any of the existing open issues.

ARM64 is not something we'll support ourselves. If there is an elegant solution by which we can support your case we're willing to add it as long as it isn't in the way of our own distribution, but we'll not develop that from Ultimaker. Sorry!