Unverified Commit c7d20693 authored by Atemu's avatar Atemu Committed by GitHub
Browse files

Merge pull request #330252 from ExpidusOS/fix/pkgsllvm/x265

x265: fix compiling with clang
parents 03930d17 f0c1ce4d
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
{ lib
, gccStdenv
, stdenv
, fetchurl
, fetchpatch
@@ -66,7 +67,11 @@ stdenv.mkDerivation rec {
    })
    # Fix detection of NEON (and armv6 build) :
    ./fix-neon-detection.patch
  ];
  ]
    # CMake files require a bit of patching to support CMAKE_ASM_COMPILER.
    # Made by @RossComputerGuy for x265 v3.5.
    # https://mailman.videolan.org/pipermail/x265-devel/2024-July/013734.html
    ++ lib.optional (stdenv.cc.isClang && !stdenv.targetPlatform.isDarwin) ./fix-clang-asm.patch;

  postPatch = ''
    substituteInPlace cmake/Version.cmake \
@@ -89,7 +94,9 @@ stdenv.mkDerivation rec {
    (mkFlag ppaSupport "ENABLE_PPA")
    (mkFlag vtuneSupport "ENABLE_VTUNE")
    (mkFlag werrorSupport "WARNINGS_AS_ERRORS")
  ];
  ]
    # Clang does not support the endfunc directive so use GCC.
    ++ lib.optional (stdenv.cc.isClang && !stdenv.targetPlatform.isDarwin) "-DCMAKE_ASM_COMPILER=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc";

  cmakeStaticLibFlags = [
    "-DHIGH_BIT_DEPTH=ON"
+34 −0
Original line number Diff line number Diff line
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a407271b4..593628e0f 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -310,7 +310,7 @@ if(GCC)
     endif()
     check_cxx_compiler_flag(-mstackrealign CC_HAS_STACK_REALIGN) 
     if (CC_HAS_STACK_REALIGN)
-        add_definitions(-mstackrealign)
+        add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-mstackrealign>)
     endif()
     # Disable exceptions. Reduce executable size, increase compability.
     check_cxx_compiler_flag(-fno-exceptions CC_HAS_FNO_EXCEPTIONS_FLAG)
@@ -545,7 +545,7 @@ if((MSVC_IDE OR XCODE OR GCC) AND ENABLE_ASSEMBLY)
             list(APPEND ASM_OBJS ${ASM}.${SUFFIX})
             add_custom_command(
                 OUTPUT ${ASM}.${SUFFIX}
-                COMMAND ${CMAKE_CXX_COMPILER}
+                COMMAND ${CMAKE_ASM_COMPILER}
                 ARGS ${ARM_ARGS} -c ${ASM_SRC} -o ${ASM}.${SUFFIX}
                 DEPENDS ${ASM_SRC})
         endforeach()
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 12b643ad5..876f3543d 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -16,6 +16,7 @@ endif(EXTRA_LIB)
 if(ENABLE_ASSEMBLY)
     set_source_files_properties(threading.cpp primitives.cpp pixel.cpp PROPERTIES COMPILE_FLAGS -DENABLE_ASSEMBLY=1)
     list(APPEND VFLAGS "-DENABLE_ASSEMBLY=1")
+    enable_language(ASM)
 endif(ENABLE_ASSEMBLY)
 
 if(ENABLE_ASSEMBLY AND X86)