Page MenuHome

support linux/arm64, including embree-fork
Needs ReviewPublic

Authored by Tzachi Zidenberg (tsahee) on Nov 8 2020, 3:31 PM.

Details

Summary

This set adds linux/arm64 support to blender. Very little work was needed in blender
itself. Most work was done on building dependencies.

Notable changes for linux-arm64:

  • use embree-aarch64 fork (should also work for MAC, but I couldn't test it)
  • disable by default usd, ispc, openimagedenoise

changes that affect other architectures:

  • update sqlite, tbb, ssl, config.guess in theora
  • clear-out pugixml configuration in openimageio
  • harvest tbbmalloc_static

Patch was tested on: Linux/arm64, Linux/x86_64 (without UI)

Event Timeline

Tzachi Zidenberg (tsahee) requested review of this revision.Nov 8 2020, 3:31 PM
Tzachi Zidenberg (tsahee) created this revision.

@Stefan Werner (swerner) - I added you as reviewer here because I saw your work enabling MAC/arm builds. I hope that's O.K.

These patches enable both "make deps" and install_deps.sh script support for linux/arm64 architecture, and allow building linux/arm64 with embree-aarch64 support.
They were tested on ubuntu 20.10, for both x86 and arm64 architectures (install_deps.sh requires a small workaround in both arm64 and x86 to use clang-9 for OSL, but that seemed out-of-scope)

Please let me know if any clarification is needed.

Thank you!
Tsahi.

adding ARCH_ARM64 constant to cmake files

Bastien Montagne (mont29) requested changes to this revision.Nov 20 2020, 12:48 PM

Am not especially thrilled to have to deal with two code paths in install_deps for a single lib... main question here for me is, if arm64 need Embree 3.12, can't we switch whole Blender deps to that version of Embree?

build_files/build_environment/install_deps.sh
81

Would add a check then, that arch is actually supported (we'd only support x86_64 and aarch64? and maybe i386 for 32bits, not sure...

472

This change has nothing to do with the purpose of this patch?

2219–2223

Why not comparing with string here too?

This revision now requires changes to proceed.Nov 20 2020, 12:48 PM
Ray Molenkamp (LazyDodo) requested changes to this revision.Nov 20 2020, 3:29 PM

Overall there seems to be very little consideration for other platforms and various arbitrary changes.

Also i have to admit, I'm not entirely convinced that burdening this build script with platforms we our selves have no intention of shipping in the near future is a direction i'm particularly fond of

build_files/build_environment/cmake/embree.cmake
45

Arbitrary change, why did this move?

build_files/build_environment/cmake/openimageio.cmake
127

There is no touch and no rm on windows. Also what are you trying to archive here?

build_files/build_environment/cmake/sqlite.cmake
54

This patch is no longer needed?

build_files/build_environment/cmake/tbb.cmake
45–46

This will break windows

46

Why the change of buildtype?

build_files/build_environment/cmake/theora.cmake
25

there is no wget on windows

build_files/build_environment/cmake/versions.cmake
144–146

Is this an arbitrary update just "cause you could" or is there a justifiable reason for it?

build_files/build_environment/install_deps.sh
472

1.5.0 was deliberately chosen for compatibility reasons

build_files/build_environment/patches/cmakelists_tbb.txt
1–29

This whole file seems to have gotten a whole lot of changes inc mingw support , why? is this your work? if not where does it come from?

Sybren A. Stüvel (sybren) requested changes to this revision.EditedNov 20 2020, 4:37 PM

I've added myself as reviewer, as Linux platform maintainer.

disable by default usd, ispc, openimagedenoise

Why were these disabled?

build_files/build_environment/CMakeLists.txt
93–95

Why is USD disabled on UNIX ARM but not on Windows ARM?

build_files/build_environment/cmake/check_software.cmake
26 ↗(On Diff #31170)

This looks like APPLE + x86_64 leads to ARCH_ARM = TRUE. How can something be a x86_64 architecture and ARM at the same time?

build_files/build_environment/cmake/embree.cmake
38

Why does Embree on ARM take TBB_ROOT but on non-ARM EMBREE_TBB_ROOT? Is this caused by the difference in version?

64–68

I'm guessing Embree on ARM doesn't need patching. Since every variable is "chosen" some way, I think ARCH_SPECIFIC_PATCH_COMMAND would be a better name.

build_files/build_environment/cmake/theora.cmake
35

I don't like the approach of downloading a patch every time this library is built. Why not download it once into the Git repository, like other patches?

build_files/build_environment/cmake/x264.cmake
37–41

Why was this removed?

build_files/build_environment/CMakeLists.txt
93–95

I kinda feel like I'm walking into a trap here, but why are we worrying about "Windows ARM" ? perhaps you meant mac-arm?

build_files/build_environment/CMakeLists.txt
93–95

Basically my question is: why have a UNIX clause in there anyway? If USD is not available for ARM, why does it need a check for UNIX-ness?

Thanks everyone for the responses!

disable by default usd, ispc, openimagedenoise

Why were these disabled?

All these libraries are intel-only, with specific intel-SSE usage that does not compile for arm64.
ispc and openimagedenoise are also disabled for MAC/arm64. USD only depends on intel for linux.. I'm hoping to change that soon.

Am not especially thrilled to have to deal with two code paths in install_deps for a single lib... main question here for me is, if arm64 need Embree 3.12, can't we switch whole Blender deps to that version of Embree?

The embree-fork actualy builds from a different repository, not just a different version. I'll try to converge the build, as I did in the cmake-path.

Overall there seems to be very little consideration for other platforms and various arbitrary changes.

Also i have to admit, I'm not entirely convinced that burdening this build script with platforms we our selves have no intention of shipping in the near future is a direction i'm particularly fond of

There are some arbitrary changes I'll remove, but package version changes were generally not arbitrary. quoting an in-code response:
I have upgraded any package which didn't support linux/aarch64 out of the box, when the new version does support it out-of-the-box (or close to it).
I realize this might seem arbitrary and messy. I did try to separate packages to their own commits, but I don't see a way to even browse the change by commit. Is there a better way to upload such a bunch of commits, that are mostly indipendant though all are working towards the same goal?

I hope arm64/linux will become important with the rise of arm/MAC on personal PCs and Graviton2 in AWS instances.
There is already work being done in blender for arm64/MAC, and my first goal in this patchset is to remove the underlying assumption that arm64 is MAC-only.

build_files/build_environment/CMakeLists.txt
93–95

Currently, USD uses a few x86-instructions only in Linux, so MAC/arm64 is supported but linux/arm64 is not. I am working on a contribution to USD which will fix that, but I don't want to add a patch here before it's approved for USD.

Finally, the condition here is wrong. The right test for including USD is: (APPLE OR (NOT ARCH_ARM64)). will fix that.

build_files/build_environment/cmake/check_software.cmake
26 ↗(On Diff #31170)

typo. sorry. I don't currently have an arm64/MAC to play with.

build_files/build_environment/cmake/embree.cmake
38

you're right. will be fixed. thanks.

45

I'll move it back.

64–68

agreed. will change that. thanks!

build_files/build_environment/cmake/openimageio.cmake
127

pugiconfig has some configurations for pugixml that are not supported by other components (specifically: header_only).
A simple fix would be to remove the unsupported options in openimageio.diff, but that might require a lot of maintenance on each openimageio version change. Instead of modifying the file, I wanted to remove it and use empty pugiconfig file / default configuration, which should hold better for future versions as well.
Of course, I wouldn't want to break windows. I'll upload a version that handles configuration in openimageio.diff. Is there a good, cross-platform way to rm & touch in cmake?

Thank you!

build_files/build_environment/cmake/sqlite.cmake
54

That's right. The patch is not needed since I upgraded sqlite version.

build_files/build_environment/cmake/tbb.cmake
45–46

I only changed the filename here.. copy is also used in the original version.
What would be a better way to do so?

46

will remove

build_files/build_environment/cmake/theora.cmake
25

will remove. also, see next reply.

35

updating config.guess/sub is not exactly "download a patch". In fact, when you run configure you'll get a message suggesting you might want to try and update these files, pointing new to the newest version. This should be the most forward-compatible way.
I wouldn't want to break windows, though.. so I'll just update theora.diff instead.

build_files/build_environment/cmake/versions.cmake
144–146

Package upgrades were only added when necessary for clean linux/aarch64 support. It is done in a separate patch, though I realize specific patches are not easily visible here.

build_files/build_environment/cmake/x264.cmake
37–41

this clause is merged into the above conditional. UNIX AND NOT APPLE here assumed Intel processor, which would result in hitting line 29.

build_files/build_environment/install_deps.sh
81

will do. thanks!

472

version 1.5.0 doesn't support linux/aarch64 out of the box, 1.20.1 does.
I'll upload a version only changing BLOSC version for aarch64.

I went straight to 1.20.1 thinking if I'm upgrading - might as well take latest. Would a different/older version be better?

2219–2223

right. will fix.

build_files/build_environment/patches/cmakelists_tbb.txt
1–29

according to tbb.cmake, the original file was taken from: https://github.com/wjakob/tbb/blob/master/CMakeLists.txt
I took an up-to-date version from the same place.

build_files/build_environment/cmake/openimageio.cmake
127

There is a good way, cmake can do it for you, see the output of cmake -E for help, grep the build csript for ${CMAKE_COMMAND} to get some examples where it is used.

build_files/build_environment/cmake/check_software.cmake
26 ↗(On Diff #31170)

In that case please update the patch description, and make it explicit:

  • which OS/hardware combinations this patch adds support for, and
  • which of those were actually tested.

Updates according to comments:

  • embree arm64 build merged into normal embree build in build_script
  • removed windows-breaking commands
  • few typos / small fixes
Tzachi Zidenberg (tsahee) retitled this revision from support arm64, including embree-fork to support linux/arm64, including embree-fork.Nov 30 2020, 3:40 PM
Tzachi Zidenberg (tsahee) edited the summary of this revision. (Show Details)
Tzachi Zidenberg (tsahee) marked 19 inline comments as done.Nov 30 2020, 3:57 PM
Tzachi Zidenberg (tsahee) added inline comments.
build_files/build_environment/cmake/check_software.cmake
26 ↗(On Diff #31170)

updated description. Let me know if any more details are needed.

This patch adds linux/arm64 support. I did test it doesn't hart linux/x86_64 build. It shouldn't hurt MAC/arm64 support, but I don't have the HW to actually test it. This is also why I didn't add embree-aarch64 support for MAC builds, though it should work with minimal changes (see https://developer.blender.org/D9527).

embree.diff is not included in the patch? If this is not too complicated, I'm still hoping we can contribute this upstream rather than maintain it ourselves.

As a general comment on this patch, I think it's up to platform maintainers to decide if they want to accept arm64 support here. Personally I think it's realistic that we will need to officially support arm64 on Linux/Windows at some point in the next few years, and making the code a bit more generic does not hurt, so it makes sense to have this working. But I also think that we are not in a rush, and can wait for upstream to get fixes rather than doing patching on our side, to keep the maintenance easier.

build_files/build_environment/cmake/harvest.cmake
172

Why was this added?

Using tbbmalloc may or may not be a good idea, but it seems unrelated to arm vs. x86.

build_files/build_environment/install_deps.sh
472

OpenVDB + Blosc 1.20.1 may build but does not function correctly, so an older version is needed currently.
https://lists.aswf.io/g/openvdb-dev/message/1140?p=,,,20,0,0,0::Created,,blosc,20,2,0,78180944

As a general comment on this patch, I think it's up to platform maintainers to decide if they want to accept arm64 support here. Personally I think it's realistic that we will need to officially support arm64 on Linux/Windows at some point in the next few years, and making the code a bit more generic does not hurt, so it makes sense to have this working. But I also think that we are not in a rush, and can wait for upstream to get fixes rather than doing patching on our side, to keep the maintenance easier.

👍 That sounds very reasonable to me.

As a general comment on this patch, I think it's up to platform maintainers to decide if they want to accept arm64 support here. Personally I think it's realistic that we will need to officially support arm64 on Linux/Windows at some point in the next few years, and making the code a bit more generic does not hurt, so it makes sense to have this working. But I also think that we are not in a rush, and can wait for upstream to get fixes rather than doing patching on our side, to keep the maintenance easier.

👍 That sounds very reasonable to me.

Seems reasonable to me as well. There was actually very little patching external dependencies other than just pulling up-to date versions.
As I said, my first goal is to remove the underlying assumption that only MACs can be ARM64, or that embree can only be in intel systems. I'd be happy to agree on what should go to such a patch.

I think these could be done to prepare for a future arm64/linux, without adding any maintenance burden:

  • fixes in util_defines.h and bvh_embree.h
  • the new ARCH_ARM64 cmake constant in dependencies (switching some APPLE AND ..)
  • theora patch - theora does not seem like it will ever be updated. It curretly has a patch fixing config.guess/config.sub for arm64/MAC, I think it stands to reason to add arm64/linux support in the same place
  • boost - removing architecture=x86 flag on arm
  • install_deps scrupt - checking ARCH, fixing flags for LLVM and OSL
  • sqlite update - just updates a version, and actually removes a now-unnecessary patch

These are less trivial, but the gain might justify the cost:

  • ssl update - it does include patching a version for arm64 compatibility. However, the patch does come from upstream ssl and will be included in the next ssl version. Also, ssl.conf changes will be needed and I'd be happy to get them in early.
  • embree-aarch64 fork - I should have an available M1 system finally, so I think I could deliver a patch for both linux and MAC.

I can leave out other fixes I did:

  • pugixml on openimageio fixes
  • tbb updates (inc. tbb harvest)

A partial patch will not be enough to add support for arm64, but it. will get us in the right direction. Which parts would you like to see on a partial patch? The entire first group? Anything else?

Thank you!
Tsahi.

Hi. I have jetson nano and made a self build with v283, v292.
I had not used this build, but you would build easier with xavier too that disabling embree (WITH_CYCLES_EMBREE OFF in CMakeLists.txt) and usd-1.9.11 (install_deps.sh --skip-usd) (with blender-v2.83-release tag), disabling SSE2 of OIIO, OCIO and OSL in install_deps.sh,
and if when blender-v2.83-release tag, modify blender-deps/c-blosc-1.5.0/blosc/shuffule.h with below,

#about c-blosc, add in install_deps.sh
	sed -i "s/unsigned char\*/uint8_t*/g" $_src/blosc/shuffle.h
	sed -i "s/const uint8_t\*/uint8_t*/g" $_src/blosc/shuffle.h
	sed -i "s/\(\/\* Shuffle\/unshuffle routines \*\/\)/#include <stdint.h>\n#include <inttypes.h>\n\n\1/g" $_src/blosc/shuffle.h

and, after did install_deps.sh -t 4 --no-confirm --with-opencollada --skip-usd,

# with blender-v2.83-release tag
touch ./blender/release/datafiles/locale/languages # This is a skip. I don't know why I faced this.

before build bin/blender.
and do make following BUILD_NOTES.txt.

build result (in jetson nano):

takahiro@jetson:~/document/source/blender/blender-283-build-20210412/build_linux/bin$ uname -a
Linux jetson 4.9.140-tegra #1 SMP PREEMPT Tue Nov 5 13:43:53 PST 2019 aarch64 aarch64 aarch64 GNU/Linux

takahiro@jetson:~/document/source/blender/blender-283-build-20210412/build_linux/bin$ pwd
/home/takahiro/document/source/blender/blender-283-build-20210412/build_linux/bin

takahiro@jetson:~/document/source/blender/blender-283-build-20210412/build_linux/bin$ ls -l blender
-rwxrwxr-x 1 takahiro takahiro 79945304  4月 16 19:51 blender

takahiro@jetson:~/document/source/blender/blender-283-build-20210412/build_linux/bin$ file blender
blender: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=d727475416a34b3e3c714b4391eb552464d569cd, not stripped

note: cmake v3.18 later built from source.