Skip to content

Commit cf3035e

Browse files
committed
contrib: flac: Include -pthread in the pkg-config file when necessary
This fixes linking with llvm-mingw (or any mingw distribution that doesn't default to linking in winpthreads). This wasn't noticed in the upstream VLC CI, as it builds with extras/packages/win32/build.sh, which passes in -Wl,-l:libpthread.a in VLC_LDFLAGS (in order to prefer linking winpthreads statically, rather than dynamically, for libraries that do use winpthreads). This patch has been sent upstream in xiph/flac#832.
1 parent 669e53c commit cf3035e

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From 8e74f100fa822852dd567cd0dbaf7245b26c412f Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <[email protected]>
3+
Date: Mon, 5 May 2025 13:42:15 +0300
4+
Subject: [PATCH] cmake: Include "-pthread" in the pkg-config file if using
5+
pthreads
6+
7+
This makes sure that users of the library pass the right linker
8+
flags if linking libflac statically, with a mingw toolchain that
9+
doesn't automatically link in pthreads.
10+
---
11+
CMakeLists.txt | 3 ++-
12+
1 file changed, 2 insertions(+), 1 deletion(-)
13+
14+
diff --git a/CMakeLists.txt b/CMakeLists.txt
15+
index 9396130d..c8f4e7ff 100644
16+
--- a/CMakeLists.txt
17+
+++ b/CMakeLists.txt
18+
@@ -157,7 +157,7 @@ if(MINGW AND (WITH_FORTIFY_SOURCE OR WITH_STACK_PROTECTOR))
19+
link_libraries("ssp.a")
20+
# static libraries don't carry over other static libraries in mingw
21+
# we need to export it in the pkg-config
22+
- set(FLAC_STATIC_LIBS "-lssp")
23+
+ set(FLAC_STATIC_LIBS "${FLAC_STATIC_LIBS} -lssp")
24+
endif()
25+
elseif(NOT MSVC)
26+
set(HAVE_LIBSSP 1)
27+
@@ -212,6 +212,7 @@ if(ENABLE_MULTITHREADING)
28+
find_package(Threads)
29+
if(CMAKE_USE_PTHREADS_INIT)
30+
set(HAVE_PTHREAD 1)
31+
+ set(FLAC_STATIC_LIBS "${FLAC_STATIC_LIBS} -pthread")
32+
endif()
33+
endif()
34+
35+
--
36+
2.43.0
37+

contrib/src/flac/rules.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ $(TARBALLS)/flac-$(FLAC_VERSION).tar.xz:
1515

1616
flac: flac-$(FLAC_VERSION).tar.xz .sum-flac
1717
$(UNPACK)
18+
$(APPLY) $(SRC)/flac/0001-cmake-Include-pthread-in-the-pkg-config-file-if-usin.patch
1819
$(call pkg_static,"src/libFLAC/flac.pc.in")
1920
$(MOVE)
2021

0 commit comments

Comments
 (0)