Skip to content

Commit

Permalink
Core: Update libdf.so to avoid AVX2 instruction set
Browse files Browse the repository at this point in the history
This fixes an issue on macOS where the AVX2 insruction set for x86_64
cannot be properly emulated on docker containters on darwinOS.
See: docker/for-mac#6620 for details
The rust lib was compiled without the vectorized optimizations and
this commit updates this file as well as the cmake files/
  • Loading branch information
omeryusufyagci committed Dec 7, 2024
1 parent 26bde71 commit 18267f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion MediaProcessor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -ffast-math -flto")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -march=native")

include(FetchContent)
set(FETCHCONTENT_BASE_DIR "${CMAKE_BINARY_DIR}/_deps") # helps with Docker to resolve
Expand Down
28 changes: 22 additions & 6 deletions MediaProcessor/cmake/src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_executable(MediaProcessor
${CMAKE_SOURCE_DIR}/src/ConfigManager.cpp
${CMAKE_SOURCE_DIR}/src/AudioProcessor.cpp
${CMAKE_SOURCE_DIR}/src/VideoProcessor.cpp
${CMAKE_SOURCE_DIR}/src/MediaProcessor.cpp
${CMAKE_SOURCE_DIR}/src/Engine.cpp
${CMAKE_SOURCE_DIR}/src/Utils.cpp
${CMAKE_SOURCE_DIR}/src/CommandBuilder.cpp
${CMAKE_SOURCE_DIR}/src/HardwareUtils.cpp
Expand All @@ -27,22 +27,39 @@ if(APPLE)
# set(DF_LIBRARY ${CMAKE_SOURCE_DIR}/lib/libdf.dylib)
endif()
elseif(WIN32)
set(DF_LIBRARY ${CMAKE_SOURCE_DIR}/lib/libdf.dll.a) # .dll.a for linking, .dll for runtime
set(DF_LIBRARY ${CMAKE_SOURCE_DIR}/lib/libdf.dll.a) # for linktime
set(DF_DLL_PATH ${CMAKE_SOURCE_DIR}/lib/df.dll) # for runtime

# Ensure the dll is present with the binary
add_custom_command(TARGET MediaProcessor POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DF_DLL_PATH}
$<TARGET_FILE_DIR:MediaProcessor>)

elseif(UNIX)
set(DF_LIBRARY ${CMAKE_SOURCE_DIR}/lib/libdf.so)
else()
message(FATAL_ERROR "Unsupported platform")
endif()


target_link_libraries(MediaProcessor PRIVATE
# Base libraries
set(LIBRARIES
Threads::Threads
${SNDFILE_LIBRARIES}
${DF_LIBRARY}
nlohmann_json::nlohmann_json
fmt::fmt
)

# macos-specific library fixes
if(APPLE)
list(APPEND LIBRARIES /opt/homebrew/lib/libsndfile.dylib)
else()
list(APPEND LIBRARIES ${SNDFILE_LIBRARIES})
endif()

target_link_libraries(MediaProcessor PRIVATE ${LIBRARIES})

target_compile_options(MediaProcessor PRIVATE -D_GLIBCXX_USE_CXX23_ABI)

# Some of this was for macOS try to remove if possible
Expand All @@ -51,5 +68,4 @@ set_target_properties(MediaProcessor PROPERTIES
INSTALL_RPATH "${CMAKE_SOURCE_DIR}/lib"
BUILD_RPATH "${CMAKE_SOURCE_DIR}/lib"
INSTALL_RPATH_USE_LINK_PATH TRUE
INTERPROCEDURAL_OPTIMIZATION TRUE
)
)
Binary file modified MediaProcessor/lib/libdf.so
Binary file not shown.

0 comments on commit 18267f7

Please sign in to comment.