Skip to content

Commit b48f1cb

Browse files
committed
fix(macos): add deployment target flags for compatibility
- Set macOS minimum deployment target to 13.0 across build configurations - Apply target flags to CFLAGS, CPPFLAGS, and LDFLAGS for autoconf builds - Apply target flags to FFmpeg extra compiler and linker flags - Ensures consistent build environment for macOS compatibility
1 parent 4d1cf3d commit b48f1cb

6 files changed

Lines changed: 31 additions & 8 deletions

File tree

.github/workflows/ffmpeg-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
runner: macos-15-intel
3333
- os: darwin
3434
arch: arm64
35-
runner: macos-latest
35+
runner: macos-15
3636
fail-fast: false
3737

3838
steps:

.github/workflows/ffmpeg-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
runner: macos-15-intel
3232
- os: darwin
3333
arch: arm64
34-
runner: macos-latest
34+
runner: macos-15
3535
fail-fast: false
3636

3737
steps:

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runner: macos-15-intel
2626
- os: darwin
2727
arch: arm64
28-
runner: macos-latest
28+
runner: macos-15
2929
fail-fast: false
3030

3131
steps:

internal/builder/buildsystems.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,22 @@ func (a *AutoconfBuild) Configure(lib *Library, srcPath, buildDir, installDir st
2626
incDir := filepath.Join(installDir, "include")
2727
libDir := filepath.Join(installDir, "lib")
2828

29+
cflags := fmt.Sprintf("-O3 -I%s", incDir)
30+
cppflags := fmt.Sprintf("-I%s", incDir)
31+
ldflags := fmt.Sprintf("-L%s", libDir)
32+
33+
// Add macOS deployment target to ensure compatibility
34+
if runtime.GOOS == "darwin" {
35+
deploymentTarget := " -mmacosx-version-min=13.0"
36+
cflags += deploymentTarget
37+
cppflags += deploymentTarget
38+
ldflags += deploymentTarget
39+
}
40+
2941
args = append(args,
30-
fmt.Sprintf("CFLAGS=-O3 -I%s", incDir),
31-
fmt.Sprintf("CPPFLAGS=-I%s", incDir),
32-
fmt.Sprintf("LDFLAGS=-L%s", libDir),
42+
fmt.Sprintf("CFLAGS=%s", cflags),
43+
fmt.Sprintf("CPPFLAGS=%s", cppflags),
44+
fmt.Sprintf("LDFLAGS=%s", ldflags),
3345
)
3446
}
3547

internal/builder/libraries.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,10 +706,19 @@ var ffmpeg = &Library{
706706
incDir := filepath.Join(stagingDir, "include")
707707
libDir := filepath.Join(stagingDir, "lib")
708708

709+
extraCflags := fmt.Sprintf("-I%s", incDir)
710+
extraLdflags := fmt.Sprintf("-L%s", libDir)
711+
712+
// Add macOS deployment target to ensure compatibility
713+
if os == "darwin" {
714+
extraCflags += " -mmacosx-version-min=13.0"
715+
extraLdflags += " -mmacosx-version-min=13.0"
716+
}
717+
709718
args := []string{
710719
"--pkg-config-flags=--static",
711-
fmt.Sprintf("--extra-cflags=-I%s", incDir),
712-
fmt.Sprintf("--extra-ldflags=-L%s", libDir),
720+
fmt.Sprintf("--extra-cflags=%s", extraCflags),
721+
fmt.Sprintf("--extra-ldflags=%s", extraLdflags),
713722
}
714723

715724
// Add common FFmpeg arguments (platform-specific)

internal/builder/library.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ func buildEnv(installDir string) []string {
209209

210210
// Set minimum macOS deployment target to avoid version mismatch warnings
211211
// This ensures libraries work on macOS 13.0 and later (supports Intel and Apple Silicon)
212+
// Note: We also set -mmacosx-version-min=13.0 in compiler flags, but some build
213+
// tools may check this environment variable directly
212214
if runtime.GOOS == "darwin" {
213215
hasDeploymentTarget := false
214216
for _, e := range env {

0 commit comments

Comments
 (0)