Vargol / ffmpeg-apple-arm64-build

Build script for ffmpeg targeting the latest open source video codecs running on macOS using Apple's M1 processor.
235 stars 42 forks source link

Can't Build AOM - i386 #21

Open ProdigyView opened 1 year ago

ProdigyView commented 1 year ago

I am trying to build AOM and the logs give me this:

+ cmake -DCMAKE_INSTALL_PREFIX:PATH=/Users/xxxxxxxx/Development/ffmpeg-apple-arm64-build/tool -DENABLE_NEON=ON -DHAVE_NEON=1 -DENABLE_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release '-DCMAKE_CXX_FLAGS=-flto -O3' '-DCMAKE_C_FLAGS=-flto -O3' -DCMAKE_C_FLAGS_INIT=-flto=8 ../aom/
-- The C compiler identification is AppleClang 14.0.3.14030022
-- The CXX compiler identification is AppleClang 14.0.3.14030022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
CMake Warning at build/cmake/util.cmake:120 (message):
  HAVE_NEON has been set by CMake, but it may be overridden by the build
  system during environment detection
Call Stack (most recent call first):
  build/cmake/aom_config_defaults.cmake:33 (set_aom_detect_var)
  build/cmake/aom_configure.cmake:18 (include)
  CMakeLists.txt:73 (include)

--- aom_configure: Detected CPU: arm64
Running C compiler test: pie_check
-- Performing Test C_TEST_COMPILED
-- Performing Test C_TEST_COMPILED - Failed
C Compiler test pie_check failed.
-- The ASM compiler identification is AppleClang
-- Found assembler: /usr/bin/as

And it just hangs. When I try to compile it on my own with cmake aom, there error message its more in-depth with:

CMake Error at /opt/homebrew/Cellar/cmake/3.27.5/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/Users/xxxxxx/Development/CMakeFiles/CMakeScratch/TryCompile-pivjRb'

    Run Build Command(s): /opt/homebrew/Cellar/cmake/3.27.5/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_c6a0f/fast
    /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_c6a0f.dir/build.make CMakeFiles/cmTC_c6a0f.dir/build
    Building C object CMakeFiles/cmTC_c6a0f.dir/testCCompiler.c.o
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc   -arch i386  -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -MD -MT CMakeFiles/cmTC_c6a0f.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_c6a0f.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_c6a0f.dir/testCCompiler.c.o -c /Users/xxxxxx/Development/CMakeFiles/CMakeScratch/TryCompile-pivjRb/testCCompiler.c
    Linking C executable cmTC_c6a0f
    /opt/homebrew/Cellar/cmake/3.27.5/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c6a0f.dir/link.txt --verbose=1
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -arch i386  -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -Wl,-headerpad_max_install_names -arch i386  CMakeFiles/cmTC_c6a0f.dir/testCCompiler.c.o -o cmTC_c6a0f 
    ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
    ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib/libSystem.tbd (3 slices)
    ld: dynamic executables or dylibs must link with libSystem.dylib for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_c6a0f] Error 1
    make: *** [cmTC_c6a0f/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:28 (project)

So apparently its trying to compile with i386 and not x86_64. I've tried the suggested cmake aom -DCMAKE_TOOLCHAIN_FILE=aom/build/cmake/toolchains/x86-macos.cmake and the same result.

Any suggestions?

Vargol commented 1 year ago

I've just ran a build and it worked fine here, 8Gb M1 mac mini - compile aom took 187s

Are you trying to build for an Intel or Apple Silicon Mac. The script is designed to build on Apple Silicon, and some of the flags force that. You mentioned it not building for x86_64, maybe a typo for arm64 ?

ProdigyView commented 1 year ago

Its Silicon. Mac Book Pro, M1 Max. 32 GB of memory. It has

Vargol commented 1 year ago

cmake aom shouldn't ask for i386 if should detect the arm64 CPU. Back in the day, before Homebrew properly supported Apple Silicon a lot of Homebrew users changed their Terminal to run using Rosetta as that made build script detect the CPU as intel and build stuff for intel so that they could run Homebrew stuff under Rosetta, that's not the case here is it ?

Since I can't duplicate the freeze its a bit hard to help. You say you are building AOM, is that as part of my ffmpeg script or are you trying to build AOM separately using my make configuration ?

If the former I'd try stripping my command down to

cmake -DCMAKE_INSTALL_PREFIX:PATH=/Users/xxxxxxxx/Development/ffmpeg-apple-arm64-build/tool -DENABLE_NEON=ON -DHAVE_NEON=1 -DENABLE_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release ../aom/

The NEON commands are probably not needed anymore, I've not tried that.

If you want aomenc (is that what the command is called ?) to encode stuff, you'll need to get rid off -DENABLE_EXAMPLES=OFF as I'm only interested in building a static library.

paulrouget commented 9 months ago

Here is a workaround for that very specific issue: locate the GNU.cmake file in your homebrew Cellar, look for the call to as. You'll see an Wl option. Remove it.