SVT-AV1 Emscripten构建

huangapple go评论75阅读模式
英文:

SVT-AV1 Emscripten build

问题

我尝试使用emscripten 3.1.32为ffmpeg构建svt-av1 v1.4.1。我按照Build-Guide的指南进行操作,最终得到以下命令:

cd Build

BUILD_DIR=/home/jozefchutka/ffmpeg-wasm/build/
TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake

emmake cmake .. -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_FILE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCMAKE_HAVE_LIBC_PTHREAD=On -DCMAKE_C_FLAGS="-O3 -I/home/jozefchutka/ffmpeg-wasm/build/include -s USE_PTHREADS=1 -msimd128"

emmake make -j

但是在以下步骤失败:

...
[ 95%] Building C object Source/App/EncApp/CMakeFiles/SvtAv1EncApp.dir/EbTime.c.o
[ 96%] Linking C executable ../../../../Bin/Release/SvtAv1EncApp.js
emcc: error: noexecstack: 没有此文件或目录(根据提供的命令行参数,"noexecstack"应该是一个输入文件)
make[2]: *** [Source/App/EncApp/CMakeFiles/SvtAv1EncApp.dir/build.make:213: ../Bin/Release/SvtAv1EncApp.js] Error 1
make[1]: *** [CMakeFiles/Makefile2:574: Source/App/EncApp/CMakeFiles/SvtAv1EncApp.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....

生成的build.make和link.txt包含了一些相关信息:

211: ../Bin/Release/SvtAv1EncApp.js: Source/App/EncApp/CMakeFiles/SvtAv1EncApp.dir/link.txt
212:	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/jozefchutka/ffmpeg-wasm/modules/svtav1/Build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_8) "Linking C executable ../../../../Bin/Release/SvtAv1EncApp.js";
213:	cd /home/jozefchutka/ffmpeg-wasm/modules/svtav1/Build/Source/App/EncApp && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/SvtAv1EncApp.dir/link.txt --verbose=$(VERBOSE)
/home/jozefchutka/ffmpeg-wasm/modules/emsdk/upstream/emscripten/emcc -O3 -I/home/jozefchutka/ffmpeg-wasm/build/include -s USE_PTHREADS=1 -msimd128 -O3 -DNDEBUG  -z noexecstack -z relro -z now @CMakeFiles/SvtAv1EncApp.dir/objects1.rsp -o ../../../../Bin/Release/SvtAv1EncApp.js @CMakeFiles/SvtAv1EncApp.dir/linklibs.rsp

由于我不精通C/C++及相关构建堆栈,所以我不确定问题是构建错误配置、svt-av1源代码还是emscripten引起的。请帮助我解决这个问题,或至少识别出问题的原因,以便我可以在相关问题跟踪器中继续工作。

英文:

I am trying to build svt-av1 v1.4.1 for ffmpeg with emscripten 3.1.32. I have followed Build-Guide and ended up with the following command:

cd Build

BUILD_DIR=/home/jozefchutka/ffmpeg-wasm/build/
TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake

emmake cmake .. -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_FILE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCMAKE_HAVE_LIBC_PTHREAD=On -DCMAKE_C_FLAGS="-O3 -I/home/jozefchutka/ffmpeg-wasm/build/include -s USE_PTHREADS=1 -msimd128"

emmake make -j

however the process fails on:

...
[ 95%] Building C object Source/App/EncApp/CMakeFiles/SvtAv1EncApp.dir/EbTime.c.o
[ 96%] Linking C executable ../../../../Bin/Release/SvtAv1EncApp.js
emcc: error: noexecstack: No such file or directory ("noexecstack" was expected to be an input file, based on the commandline arguments provided)
make[2]: *** [Source/App/EncApp/CMakeFiles/SvtAv1EncApp.dir/build.make:213: ../Bin/Release/SvtAv1EncApp.js] Error 1
make[1]: *** [CMakeFiles/Makefile2:574: Source/App/EncApp/CMakeFiles/SvtAv1EncApp.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Generated build.make and link.txt which contains some relevant info.

211: ../Bin/Release/SvtAv1EncApp.js: Source/App/EncApp/CMakeFiles/SvtAv1EncApp.dir/link.txt
212:	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/jozefchutka/ffmpeg-wasm/modules/svtav1/Build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_8) "Linking C executable ../../../../Bin/Release/SvtAv1EncApp.js"
213:	cd /home/jozefchutka/ffmpeg-wasm/modules/svtav1/Build/Source/App/EncApp && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/SvtAv1EncApp.dir/link.txt --verbose=$(VERBOSE)
/home/jozefchutka/ffmpeg-wasm/modules/emsdk/upstream/emscripten/emcc -O3 -I/home/jozefchutka/ffmpeg-wasm/build/include -s USE_PTHREADS=1 -msimd128 -O3 -DNDEBUG  -z noexecstack -z relro -z now @CMakeFiles/SvtAv1EncApp.dir/objects1.rsp -o ../../../../Bin/Release/SvtAv1EncApp.js @CMakeFiles/SvtAv1EncApp.dir/linklibs.rsp

As I am not fluent in c/c++ and related build stack, I am not sure if the problem is my build misconfiguration, svt-av1 sources or emscripten.

Please help me resolve the issue or at least identify the cause, so I can continue in relevant issue tracker.

答案1

得分: 0

问题已通过包括一个额外的标志-DBUILD_APPS=OFF来解决,这导致有问题的代码行不会被执行。

英文:

The issue was resolved by including an extra flag -DBUILD_APPS=OFF, which caused that the problematic line is not executed.

答案2

得分: 0

以下是翻译好的内容:

For your reference, the line that adds those linker flags is here: https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/v1.4.1/CMakeLists.txt#L211

if(UNIX)
    if(APPLE)
        ...
    else()
        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
    endif()
endif()

Since this is setting a variable (and variables are scoped to CMake directories), this variable must be applying to a target in the same or deeper directory scope, and the error is happening because these linker flags are not supported by emcc (the Emscripten compiler and linker). The reference docs for Emscripten's commandline flags can be found here: https://emscripten.org/docs/tools_reference/emcc.html#command-line-syntax. I have also found this resource useful for finding out which option flags are for compiling and which are for linking: https://emsettings.surma.technology/.

Looking through the target definitions in SVT-AV1, you'll find that executables are defined in the Source/App folder: Source/App/DecApp/CMakeLists.txt and Source/App/EncApp/CMakeLists.txt. Those executables get added by default.

See this line in the root CMakeLists.txt (notice that the default is ON):

option(BUILD_APPS "Build Enc and Dec Apps" ON)

And these lines that add_subdirectory the apps folders:

if(BUILD_APPS AND BUILD_ENC)
    add_subdirectory(Source/App/EncApp)
endif()
if(BUILD_APPS AND BUILD_DEC)
    add_subdirectory(Source/App/DecApp)

So if you don't need those apps to be built for your purposes, you can stop them from being built by adding -DBUILD_APPS=OFF in your configure command.

If you do need those to be built for your purposes, raise an issue ticket or implement changes in a Merge Request to somehow resolve that issue when the Emscripten toolchain is being used. You can use the EMSCRIPTEN CMake variable, which the Emscripten CMake toolchain file defines to do the platform check.

英文:

For your reference, the line that adds those linker flags is here: https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/v1.4.1/CMakeLists.txt#L211

if(UNIX)
    if(APPLE)
        ...
    else()
        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
    endif()
endif()

Since this is setting a variable (and variables are scoped to CMake directories), this variable must be applying to a target in the same or deeper directory scope, and the error is happening because these linker flags are not supported by emcc (the Emscripten compiler and linker). The reference docs for Emscripten's commandline flags can be found here: https://emscripten.org/docs/tools_reference/emcc.html#command-line-syntax. I have also found this resource useful for finding out which option flags are for compiling and which are for linking: https://emsettings.surma.technology/.

Looking through the target definitions in SVT-AV1, you'll find that executables are defined in the Source/App folder: Source/App/DecApp/CMakeLists.txt and Source/App/EncApp/CMakeLists.txt. Those executables get added by default.

See this line in the root CMakeLists.txt (notice that the default is ON):

option(BUILD_APPS "Build Enc and Dec Apps" ON)

And these lines that add_subdirectory the apps folders:

if(BUILD_APPS AND BUILD_ENC)
    add_subdirectory(Source/App/EncApp)
endif()
if(BUILD_APPS AND BUILD_DEC)
    add_subdirectory(Source/App/DecApp)
endif()

So if you don't need those apps to be built for your purposes, you can stop them from being built by adding -DBUILD_APPS=OFF in your configure command.

If you do need those to be built for your purposes, raise an issue ticket or implement changes in a Merge Request to somehow resolve that issue when the Emscripten toolchain is being used. You can use the EMSCRIPTEN CMake variable, which the Emscripten CMake toolchain file defines to do the platform check.

huangapple
  • 本文由 发表于 2023年2月23日 19:17:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75544088.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定