Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
e7cdb101 by Steve Lhomme at 2026-01-19T08:21:57+00:00
contrib: openapv: fix multiple issues in CMake file

- forcing -pthread on Windows
- including pthread. on Windows
- forcing hardcoded compiler flags
- using AVX2 not available in older compilers

- - - - -


6 changed files:

- + contrib/src/openapv/0001-detect-Windows-builds-with-_WIN32.patch
- + 
contrib/src/openapv/0002-CMake-use-CMake-way-of-selecting-strict-C99-support.patch
- + contrib/src/openapv/0003-CMake-don-t-add-pthread-for-Windows-builds.patch
- + 
contrib/src/openapv/0004-CMake-check-compiler-flags-are-supported-before-addi.patch
- + contrib/src/openapv/0005-CMake-check-_mm256_setr_m128i-is-supported.patch
- contrib/src/openapv/rules.mak


Changes:

=====================================
contrib/src/openapv/0001-detect-Windows-builds-with-_WIN32.patch
=====================================
@@ -0,0 +1,60 @@
+From f2448bb52b35f6b8305afc2a40c166890c11d442 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <[email protected]>
+Date: Wed, 14 Jan 2026 13:38:01 +0100
+Subject: [PATCH 1/5] detect Windows builds with _WIN32
+
+It's set by all Windows compilers, including x86_64 and arm64.
+
+Signed-off-by: Steve Lhomme <[email protected]>
+---
+ src/oapv_port.c  | 4 ++--
+ src/oapv_tpool.c | 4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/oapv_port.c b/src/oapv_port.c
+index 24d60f0..cc33a03 100644
+--- a/src/oapv_port.c
++++ b/src/oapv_port.c
+@@ -89,7 +89,7 @@ void oapv_trace_line(char *pre)
+     printf("%s\n", str);
+ }
+ 
+-#if defined(WIN32) || defined(WIN64) || defined(_WIN32)
++#if defined(_WIN32)
+ #include <windows.h>
+ #include <sysinfoapi.h>
+ #else /* LINUX, MACOS, Android */
+@@ -99,7 +99,7 @@ void oapv_trace_line(char *pre)
+ int oapv_get_num_cpu_cores(void)
+ {
+     int num_cores = 1; // default
+-#if defined(WIN32) || defined(WIN64) || defined(_WIN32)
++#if defined(_WIN32)
+     {
+         SYSTEM_INFO si;
+         GetNativeSystemInfo(&si);
+diff --git a/src/oapv_tpool.c b/src/oapv_tpool.c
+index 8be0740..349bf9d 100644
+--- a/src/oapv_tpool.c
++++ b/src/oapv_tpool.c
+@@ -32,7 +32,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include "oapv_tpool.h"
+-#if defined(WIN32) || defined(WIN64)
++#if defined(_WIN32)
+ #include <windows.h>
+ #include <process.h>
+ #else
+@@ -41,7 +41,7 @@
+ 
+ #define WINDOWS_MUTEX_SYNC 0
+ 
+-#if !defined(WIN32) && !defined(WIN64)
++#if !defined(_WIN32)
+ 
+ typedef struct thread_ctx {
+     // synchronization members
+-- 
+2.52.0.windows.1
+


=====================================
contrib/src/openapv/0002-CMake-use-CMake-way-of-selecting-strict-C99-support.patch
=====================================
@@ -0,0 +1,28 @@
+From 33243bab9848c6a06d12696bc34a0254d52a4db2 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <[email protected]>
+Date: Wed, 14 Jan 2026 13:41:39 +0100
+Subject: [PATCH 2/5] CMake: use CMake way of selecting strict C99 support
+
+Signed-off-by: Steve Lhomme <[email protected]>
+---
+ CMakeLists.txt | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 1ac32b0..14035ce 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -100,6 +100,10 @@ endif()
+ # Compilation flags
+ ########################################
+ 
++set(CMAKE_C_STANDARD 99)
++set(CMAKE_C_STANDARD_REQUIRED ON)
++set(CMAKE_C_EXTENSIONS OFF)
++
+ # Set compiler flags and options.
+ if(MSVC)
+   message("Not supported yet!")
+-- 
+2.52.0.windows.1
+


=====================================
contrib/src/openapv/0003-CMake-don-t-add-pthread-for-Windows-builds.patch
=====================================
@@ -0,0 +1,51 @@
+From 08f8cb25a6029220f4dda8b7e8761c7962c0ae17 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <[email protected]>
+Date: Wed, 14 Jan 2026 13:45:01 +0100
+Subject: [PATCH 3/5] CMake: don't add -pthread for Windows builds
+
+It can generate some warnings or compilations errors.
+
+The official CMake way of picking the thread library [^1] should probably be 
used for non-Windows targets.
+
+[^1]: https://cmake.org/cmake/help/latest/module/FindThreads.html
+
+Signed-off-by: Steve Lhomme <[email protected]>
+---
+ CMakeLists.txt     | 5 ++++-
+ src/CMakeLists.txt | 3 +++
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 14035ce..52bf365 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -121,8 +121,11 @@ elseif(UNIX OR MINGW)
+         set(OPT_DBG "-DNDEBUG") # disable assert
+     endif()
+ 
+-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPT_DBG} -${OPT_LV} 
-fomit-frame-pointer -pthread -std=c99")
++    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPT_DBG} -${OPT_LV} 
-fomit-frame-pointer -std=c99")
+     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unused-function 
-Wno-pointer-sign -Wno-pointer-to-int-cast")
++    if(NOT WIN32)
++      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
++    endif()
+     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lm")
+ else()
+     message("Unknown compiler")
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index d690068..29143cf 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -182,6 +182,9 @@ if(NOT MSVC)
+         set(EXTRA_CFLAGS "-DOAPV_STATIC_DEFINE")
+         set(EXTRA_CFLAGS_PRIVATE "")
+     endif()
++    if(NOT WIN32)
++        set(EXTRA_CFLAGS_PRIVATE "${EXTRA_CFLAGS_PRIVATE} -pthread")
++    endif()
+     configure_file(
+       "${CMAKE_SOURCE_DIR}/pkgconfig/${LIB_NAME_BASE}.pc.in"
+       "${CMAKE_BINARY_DIR}/${LIB_NAME_BASE}.pc" @ONLY)
+-- 
+2.52.0.windows.1
+


=====================================
contrib/src/openapv/0004-CMake-check-compiler-flags-are-supported-before-addi.patch
=====================================
@@ -0,0 +1,94 @@
+From ad8d7eab09773ee6e8684919f85acadf9bf56e25 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <[email protected]>
+Date: Wed, 14 Jan 2026 13:45:35 +0100
+Subject: [PATCH 4/5] CMake: check compiler flags are supported before adding
+ them
+
+Signed-off-by: Steve Lhomme <[email protected]>
+---
+ CMakeLists.txt     | 25 +++++++++++++++++++++++--
+ src/CMakeLists.txt | 18 ++++++++++++++----
+ 2 files changed, 37 insertions(+), 6 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 52bf365..8366800 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -104,6 +104,8 @@ set(CMAKE_C_STANDARD 99)
+ set(CMAKE_C_STANDARD_REQUIRED ON)
+ set(CMAKE_C_EXTENSIONS OFF)
+ 
++include(CheckCCompilerFlag)
++
+ # Set compiler flags and options.
+ if(MSVC)
+   message("Not supported yet!")
+@@ -121,8 +123,27 @@ elseif(UNIX OR MINGW)
+         set(OPT_DBG "-DNDEBUG") # disable assert
+     endif()
+ 
+-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPT_DBG} -${OPT_LV} 
-fomit-frame-pointer -std=c99")
+-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unused-function 
-Wno-pointer-sign -Wno-pointer-to-int-cast")
++    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPT_DBG} -${OPT_LV}")
++    check_c_compiler_flag("-fomit-frame-pointer" HAS_FLAG_OMIT_FRAME_POINTER)
++    if(HAS_FLAG_OMIT_FRAME_POINTER)
++      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
++    endif()
++    check_c_compiler_flag("-Wall" HAS_FLAG_WARNING_ALL)
++    if(HAS_FLAG_WARNING_ALL)
++      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
++    endif()
++    check_c_compiler_flag("-Wno-unused-function" HAS_FLAG_NO_UNUSED_FUNCTION)
++    if(HAS_FLAG_NO_UNUSED_FUNCTION)
++      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
++    endif()
++    check_c_compiler_flag("-Wno-pointer-sign" HAS_FLAG_NO_POINTER_SIGN)
++    if(HAS_FLAG_NO_POINTER_SIGN)
++      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-pointer-sign")
++    endif()
++    check_c_compiler_flag("-Wno-pointer-to-int-cast" 
HAS_FLAG_NO_POINTER_INT_CAST)
++    if(HAS_FLAG_NO_POINTER_INT_CAST)
++      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-pointer-to-int-cast")
++    endif()
+     if(NOT WIN32)
+       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
+     endif()
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 29143cf..e442e7f 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -14,6 +14,10 @@ file(GLOB LIB_AVX_INC "../src/avx/oapv_*.h" )
+ include(GenerateExportHeader)
+ include_directories("${CMAKE_BINARY_DIR}/include")
+ 
++include(CheckCCompilerFlag)
++check_c_compiler_flag("-flax-vector-conversions" HAS_ARM_VECTOR_CONVERSION)
++check_c_compiler_flag("-msse4.1" HAS_SSE41)
++check_c_compiler_flag("-mavx2" HAS_AVX2)
+ 
+ message("SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")
+ 
+@@ -107,10 +111,16 @@ if(MSVC)
+   endif()
+ elseif(UNIX OR MINGW)
+   if (ARM)
+-    set_property(SOURCE ${NEON} APPEND PROPERTY COMPILE_FLAGS 
"-flax-vector-conversions")
+-elseif (X86 OR UNIVERSAL)
+-    set_property(SOURCE ${SSE} APPEND PROPERTY COMPILE_FLAGS "-msse4.1")
+-    set_property(SOURCE ${AVX} APPEND PROPERTY COMPILE_FLAGS " -mavx2")
++    if(HAS_ARM_VECTOR_CONVERSION)
++      set_property(SOURCE ${NEON} APPEND PROPERTY COMPILE_FLAGS 
"-flax-vector-conversions")
++    endif()
++  elseif (X86 OR UNIVERSAL)
++    if(HAS_SSE41)
++      set_property(SOURCE ${SSE} APPEND PROPERTY COMPILE_FLAGS "-msse4.1")
++    endif()
++    if(HAS_AVX2)
++      set_property(SOURCE ${AVX} APPEND PROPERTY COMPILE_FLAGS "-mavx2")
++    endif()
+   endif()
+ 
+   if(OAPV_BUILD_SHARED_LIB)
+-- 
+2.52.0.windows.1
+


=====================================
contrib/src/openapv/0005-CMake-check-_mm256_setr_m128i-is-supported.patch
=====================================
@@ -0,0 +1,65 @@
+From 93b6064273ea4add336936698dfdb84d93f72c58 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <[email protected]>
+Date: Wed, 14 Jan 2026 14:16:08 +0100
+Subject: [PATCH 5/5] CMake: check _mm256_setr_m128i is supported
+
+Some older AVX2 compilers don't have it, but it's possible to use a macro 
instead [^1].
+
+[^1]: https://stackoverflow.com/a/32630658/1266123
+
+Signed-off-by: Steve Lhomme <[email protected]>
+---
+ src/CMakeLists.txt    | 19 +++++++++++++++++++
+ src/avx/oapv_tq_avx.c |  6 ++++++
+ 2 files changed, 25 insertions(+)
+
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index e442e7f..35dfb89 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -120,6 +120,25 @@ elseif(UNIX OR MINGW)
+     endif()
+     if(HAS_AVX2)
+       set_property(SOURCE ${AVX} APPEND PROPERTY COMPILE_FLAGS "-mavx2")
++      # check _mm256_setr_m128i is supported
++      include(CheckCSourceCompiles)
++      include(CMakePushCheckState)
++
++      cmake_push_check_state(RESET)
++      set(CMAKE_REQUIRED_FLAGS "-mavx2")
++      check_c_source_compiles("
++      #include <immintrin.h>
++      int main(void)
++      {
++        __m128i a, b;
++        _mm256_setr_m128i(a, b);
++        return 0;
++      }
++      " HAVE_MM256_SETR)
++      cmake_pop_check_state()
++      if(HAVE_MM256_SETR)
++        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_MM256_SETR")
++      endif(HAVE_MM256_SETR)
+     endif()
+   endif()
+ 
+diff --git a/src/avx/oapv_tq_avx.c b/src/avx/oapv_tq_avx.c
+index 5939986..4332783 100644
+--- a/src/avx/oapv_tq_avx.c
++++ b/src/avx/oapv_tq_avx.c
+@@ -32,6 +32,12 @@
+ #include "oapv_def.h"
+ #include "oapv_tq_avx.h"
+ 
++#ifndef HAVE_MM256_SETR
++#define _mm256_set_m128i(v0, v1)  
_mm256_insertf128_si256(_mm256_castsi128_si256(v1), (v0), 1)
++#define _mm256_setr_m128i(v0, v1) _mm256_set_m128i((v1), (v0))
++#endif
++
++
+ #if X86_SSE
+ #ifndef _mm256_set_m128i
+ #define _mm256_set_m128i(/* __m128i */ hi, /* __m128i */ lo) \
+-- 
+2.52.0.windows.1
+


=====================================
contrib/src/openapv/rules.mak
=====================================
@@ -20,6 +20,11 @@ openapv: openapv-$(OPENAPV_VERSION).tar.gz .sum-openapv
        $(call pkg_static,"pkgconfig/oapv.pc.in")
        # install the library in the usual <prefix>/lib place to match the .pc 
file
        sed -i.orig 
's,$${CMAKE_INSTALL_LIBDIR}/$${LIB_NAME_BASE},$${CMAKE_INSTALL_LIBDIR},g' 
$(UNPACK_DIR)/src/CMakeLists.txt
+       $(APPLY) $(SRC)/openapv/0001-detect-Windows-builds-with-_WIN32.patch
+       $(APPLY) 
$(SRC)/openapv/0002-CMake-use-CMake-way-of-selecting-strict-C99-support.patch
+       $(APPLY) 
$(SRC)/openapv/0003-CMake-don-t-add-pthread-for-Windows-builds.patch
+       $(APPLY) 
$(SRC)/openapv/0004-CMake-check-compiler-flags-are-supported-before-addi.patch
+       $(APPLY) 
$(SRC)/openapv/0005-CMake-check-_mm256_setr_m128i-is-supported.patch
        $(MOVE)
 
 .openapv: openapv toolchain.cmake



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/e7cdb1017391b2d16974a4a6e059ea1990cdb6c7

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/e7cdb1017391b2d16974a4a6e059ea1990cdb6c7
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to