Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build for M1 Mac #1736

Closed
sreeneel opened this issue Jan 9, 2022 · 11 comments
Closed

Unable to build for M1 Mac #1736

sreeneel opened this issue Jan 9, 2022 · 11 comments

Comments

@sreeneel
Copy link

sreeneel commented Jan 9, 2022

Description of Issue

I cloned the latest version of USD project and checked out release branch which is at following commit:
commit faed18ce62c8736b02413635b584a2f637156bad (HEAD -> release, tag: v21.11, origin/release, origin/HEAD)
When I tried to build I get the following error:

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C "./build/macos_ia32_clang_cc_os11.6.2_debug"  -r -f ../../build/Makefile.tbb cfg=debug
../../build/Makefile.tbb:32: CONFIG: cfg=debug arch=ia32 compiler=clang target=macos runtime=cc_os11.6.2
clang++ -fPIC -o libtbb_debug.dylib concurrent_hash_map.o concurrent_queue.o concurrent_vector.o dynamic_link.o itt_notify.o cache_aligned_allocator.o pipeline.o queuing_mutex.o queuing_rw_mutex.o reader_writer_lock.o spin_rw_mutex.o x86_rtm_rw_mutex.o spin_mutex.o critical_section.o mutex.o recursive_mutex.o condition_variable.o tbb_thread.o concurrent_monitor.o semaphore.o private_server.o rml_tbb.o tbb_misc.o tbb_misc_ex.o task.o task_group_context.o governor.o market.o arena.o scheduler.o observer_proxy.o tbb_statistics.o tbb_main.o concurrent_vector_v2.o concurrent_queue_v2.o spin_rw_mutex_v2.o task_v2.o   -ldl -lpthread -dynamiclib -install_name @rpath/libtbb_debug.dylib -stdlib=libc++ -m32  -Wl,-exported_symbols_list,tbb.def
ld: unknown/unsupported architecture name for: -arch armv4t
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libtbb_debug.dylib] Error 1
make: *** [tbb] Error 2

Looks like its failing when linking TBB library. While my Mac has arch of type: arm64, it seems to build for armv4t.
Any suggestions on how to fix this or how to force build system to build just for arm64

Steps to Reproduce

  1. Check out USD repo
  2. Build using : python USD/build_scripts/build_usd.py /opt/local/USD

System Information (OS, Hardware)

  1. MacBook Pro (13-inch, M1, 2020) with "Apple M1" Chip
  2. OS: macOS Big Sur, V 11.6.2
  3. Python version: Python 3.8.11
  4. I have manually build PySide6 and installed locally into my virtual-env

Package Versions

Build Flags

@Bersaelor
Copy link

Whenever I use the USD tools, I have to set the terminal to Rosetta mode, haven't managed to build it on arm64 either.

@sreeneel
Copy link
Author

Thanks Bersalor..Thats what I ended up doing as I couldn't get the project to build for m1 Mac..
for those interested, here's a quick way to launch your shell in rosetta mode
arch -x86_64 zsh #replace zsh with your favorite shell

@Bersaelor
Copy link

Bersaelor commented Jan 12, 2022

You got me interested, so I just tried compiling it on MacOs too, i usually run it with --no-usdview so it doesn't need PySide.
But also couldn't compile it, always failed trying to compile TBB and I couldn't determine the actual cause in the really large /usr/local/USD/src/oneTBB-2018_U1/log.txt.

When trying to compile in Rosetta-Terminal, I got all the way to the last step but then:

make[2]: *** No rule to make target `/Users/konradfeiler/.pyenv/versions/3.8.11/lib/libpython3.8.dylib', needed by `pxr/base/tf/libusd_tf.dylib'.  Stop.

Apparently when using pyenv it does not create the dynamic dylib's by default, so I had to

env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.8.0

After this step, I managed to build v21.11 myself (on x86_64).

PS: In the Readme file to the precompiled USD tools by Apple they also compile it with --build-args TBB,extra_inc=big_iron.inc. Not sure what the impact of having or not having big_iron.inc is

@jilliene
Copy link

Filed as internal issue #USD-7127

@sreeneel
Copy link
Author

You got me interested, so I just tried compiling it on MacOs too, i usually run it with --no-usdview so it doesn't need PySide. But also couldn't compile it, always failed trying to compile TBB and I couldn't determine the actual cause in the really large /usr/local/USD/src/oneTBB-2018_U1/log.txt.

When trying to compile in Rosetta-Terminal, I got all the way to the last step but then:

make[2]: *** No rule to make target `/Users/konradfeiler/.pyenv/versions/3.8.11/lib/libpython3.8.dylib', needed by `pxr/base/tf/libusd_tf.dylib'.  Stop.

Apparently when using pyenv it does not create the dynamic dylib's by default, so I had to

env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.8.0

After this step, I managed to build v21.11 myself (on x86_64).

PS: In the Readme file to the precompiled USD tools by Apple they also compile it with --build-args TBB,extra_inc=big_iron.inc. Not sure what the impact of having or not having big_iron.inc is

Thanks Bersaelor.
I could not build even in rosetta-shell. Same error as above i.e for some reason TBB linking fails for armv4t while the Mac is just arm64
I could only use rosetta-shell to use pre-compiled Apple's usdpython tools..this works fine, but not the build itself

I tried Apple's build command
python USD/build_scripts/build_usd.py --build-args TBB,extra_inc=big_iron.inc --python --no-imaging --docs --no-usdview --build-monolithic /opt/local/USD
This also fails with following error:

../../src/tbbmalloc/frontend.cpp:766:8: error: invalid instruction, any one of the following would fix this:
       "clz %0, %1\n"
       ^
<inline asm>:1:2: note: instantiated into assembly here
        clz r0, r0
        ^
../../src/tbbmalloc/frontend.cpp:766:8: note: instruction requires: armv5t
       "clz %0, %1\n"
       ^
<inline asm>:1:2: note: instantiated into assembly here
        clz r0, r0
        ^
../../src/tbbmalloc/frontend.cpp:766:8: note: instruction requires: thumb2
       "clz %0, %1\n"
       ^
<inline asm>:1:2: note: instantiated into assembly here
        clz r0, r0
        ^
10 warnings and 1 error generated.
make[1]: *** [frontend.o] Error 1
make: *** [tbbmalloc] Error 2

here's my clang version:

Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@haikusw
Copy link

haikusw commented Mar 13, 2022

To get past the TBB attempting to build for the wrong architecture on M1 Macs, this worked for me:

python ./build_scripts/build_usd.py clean --build-args TBB,"arch=arm64" --no-python ./built

No idea why it's pulling up the wrong arm architecture by default.

(--no-python is to avoid the python issue).

@FlorianZ
Copy link
Contributor

Also see Issue #1718.

@erwincoumans
Copy link

erwincoumans commented Jul 14, 2022

I just tried compiling USD on Mac M1/arm64 and it seems to proceed:

python3 build_scripts/build_usd.py --build-args TBB,arch=arm64 --python --no-imaging --no-usdview --prefer-safety-over-speed --build-monolithic /opt/homebrew/USD

The arm64 wheel works as well, for homebrew python3.9, here is a precompiled wheel in case someone wants to try it:

/opt/homebrew/opt/[email protected]/bin/python3.9 -m pip install https://pybullet.org/download/usd_core-22.5.post1-py3-none-any.whl

@yageek
Copy link

yageek commented Jul 16, 2022

Thanks @erwincoumans for the help! I struggled one hour to make it work.

I managed my python versions using pyenv. I am not familiar with the build script but it seems it does not work in coordination with it.

I needed to uninstall it completely and reinstall the python version with home-brew

@sunyab
Copy link
Contributor

sunyab commented Jul 25, 2022

Hello, I wanted to mention that v22.08 added support for native builds on M1 via build_usd.py, so using Rosetta or the additional build arguments should not be necessary. However, USD does not currently have a native M1 usd-core Python package available via pip. That's being tracked in #1718.

I'm going to close this out, please file a new issue if you run into any problems. Thanks!

@erwincoumans
Copy link

Other ARM64 platforms lack similar wheels, here is another one for GH200 (Ubuntu 22.04 on ARM64)
Above line still works, just had to use /tmp (not root)
python3 build_scripts/build_usd.py --build-args TBB,arch=arm64 --python --no-imaging --no-usdview --prefer-safety-over-speed --build-monolithic /tmp/homebrew/USD and install a missing library ``sudo apt-get install libxt-dev
python3.10 -m pip install https://pybullet.org/download/usd_core-24.3-py3-none-any.whl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants