Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated compiler/linker options when building ffmpeg #6005

Closed
marcosfrm opened this issue Apr 27, 2024 · 2 comments
Closed

Duplicated compiler/linker options when building ffmpeg #6005

marcosfrm opened this issue Apr 27, 2024 · 2 comments

Comments

@marcosfrm
Copy link
Contributor

marcosfrm commented Apr 27, 2024

Problem Description

ffmpeg configure script does interpret CFLAGS and LDFLAGS environment variables. Then --extra-cflags and --extra-ldflags are added with almost the same options, leading to duplicated entries.

mingw host:

CC=/usr/bin/x86_64-w64-mingw32-gcc
CFLAGS="-I/home/marcos/Downloads/HandBrake/build/contrib/include -std=gnu99 -mfpmath=sse -msse2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mno-ms-bitfields -fno-common"
CXX=/usr/bin/x86_64-w64-mingw32-g++
CXXFLAGS="-I/home/marcos/Downloads/HandBrake/build/contrib/include -mfpmath=sse -msse2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mno-ms-bitfields -fno-common"
CPPFLAGS="-I/home/marcos/Downloads/HandBrake/build/contrib/include "
LDFLAGS="-L/home/marcos/Downloads/HandBrake/build/contrib/lib -fstack-protector-strong"
PKG_CONFIG_PATH="/home/marcos/Downloads/HandBrake/build/contrib/lib/pkgconfig:"
PATH="/home/marcos/Downloads/HandBrake/build/contrib/bin:/home/marcos/.local/bin:/home/marcos/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin"

./configure
[...]

--extra-ldflags="-mfpmath=sse -msse2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mno-ms-bitfields -fno-common -L/home/marcos/Downloads/HandBrake/build/contrib/lib "
--extra-cflags="-mfpmath=sse -msse2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mno-ms-bitfields -fno-common -I/home/marcos/Downloads/HandBrake/build/contrib/include -DNDEBUG"

(btw --extra-ldflag is adding ?extra when it should be ?extra.exe)

Possible cleanup (untested):

diff --git a/contrib/ffmpeg/module.defs b/contrib/ffmpeg/module.defs
index 95de990a1..7aa0b13fb 100644
--- a/contrib/ffmpeg/module.defs
+++ b/contrib/ffmpeg/module.defs
@@ -80,8 +80,7 @@ FFMPEG.CONFIGURE.extra = \
     --enable-filter=hwdownload \
     --enable-filter=hwmap \
     --enable-filter=hwupload \
-    --cc="$(FFMPEG.GCC.gcc)" \
-    --extra-ldflags="$(call fn.ARGS,FFMPEG.GCC,*archs *sysroot *minver ?extra) -L$(call fn.ABSOLUTE,$(CONTRIB.build/)lib) $(FFMPEG.GCC.args.extra-ldflags)"
+    --cc="$(FFMPEG.GCC.gcc)"

 ifeq (size-aggressive,$(GCC.O))
 FFMPEG.CONFIGURE.extra += \
@@ -141,7 +140,7 @@ else ifeq (1-mingw,$(HOST.cross)-$(HOST.system))
         --pkg-config-flags="--static"
     FFMPEG.GCC.args.extra += -fno-common
 else ifeq (darwin,$(HOST.system))
-    FFMPEG.GCC.args.extra-ldflags = -lc++
+    FFMPEG.CONFIGURE.extra += --extra-libs="-lc++"
 else
     FFMPEG.CONFIGURE.extra += --extra-libs="-lm -lstdc++"
 endif
@@ -149,13 +148,13 @@ endif
 ifneq (none,$(FFMPEG.GCC.g))
     FFMPEG.CONFIGURE.extra += --enable-debug
     ifeq (max,$(FFMPEG.GCC.g))
-        FFMPEG.CONFIGURE.extra += --extra-cflags="$(call fn.ARGS,FFMPEG.GCC,*archs *sysroot *minver ?extra) -I$(call fn.ABSOLUTE,$(CONTRIB.build/)include) -DDEBUG"
+        FFMPEG.CONFIGURE.extra += --extra-cflags="-DDEBUG"
     else
-        FFMPEG.CONFIGURE.extra += --extra-cflags="$(call fn.ARGS,FFMPEG.GCC,*archs *sysroot *minver ?extra) -I$(call fn.ABSOLUTE,$(CONTRIB.build/)include) -DNDEBUG"
+        FFMPEG.CONFIGURE.extra += --extra-cflags="-DNDEBUG"
     endif
 else
     FFMPEG.CONFIGURE.extra += --disable-debug
-    FFMPEG.CONFIGURE.extra += --extra-cflags="$(call fn.ARGS,FFMPEG.GCC,*archs *sysroot *minver ?extra) -I$(call fn.ABSOLUTE,$(CONTRIB.build/)include) -DNDEBUG"
+    FFMPEG.CONFIGURE.extra += --extra-cflags="-DNDEBUG"
 endif

 ifeq (none,$(FFMPEG.GCC.O))

Edit: even better, the debug defines can use FFMPEG.GCC.D += foo.

Activity Log, Crash Log or any other details

/usr/bin/x86_64-w64-mingw32-gcc -I. -I./ -I/home/marcos/Downloads/HandBrake/build/contrib/include  -D_ISOC11_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DWIN32_LEAN_AND_MEAN -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 -D__printf__=__gnu_printf__ -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -DBUILDING_avcodec

---> CFLAGS env var here:

-I/home/marcos/Downloads/HandBrake/build/contrib/include -std=gnu99 -mfpmath=sse -msse2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mno-ms-bitfields -fno-common

---> --extra-cflags here:

-mfpmath=sse -msse2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mno-ms-bitfields -fno-common -I/home/marcos/Downloads/HandBrake/build/contrib/include -DNDEBUG

-std=c17 -fomit-frame-pointer -I/home/marcos/Downloads/HandBrake/build/contrib/include -I/home/marcos/Downloads/HandBrake/build/contrib/include -I/home/marcos/Downloads/HandBrake/build/contrib/include -I/home/marcos/Downloads/HandBrake/build/contrib/include -I/home/marcos/Downloads/HandBrake/build/contrib/lib/pkgconfig/../../include -I/home/marcos/Downloads/HandBrake/build/contrib/lib/pkgconfig/../../include/vpl -DMFX_DEPRECATED_OFF -I/home/marcos/Downloads/HandBrake/build/contrib/include/opus -I/home/marcos/Downloads/HandBrake/build/contrib/include/opus -I/home/marcos/Downloads/HandBrake/build/contrib/include -I/home/marcos/Downloads/HandBrake/build/contrib/include -I/home/marcos/Downloads/HandBrake/build/contrib/include -I/home/marcos/Downloads/HandBrake/build/contrib/include -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-const-variable -Wno-bool-operation -Wno-char-subscripts -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wno-maybe-uninitialized   -MMD -MF libavcodec/cbs_mpeg2.d -MT libavcodec/cbs_mpeg2.o -c -o libavcodec/cbs_mpeg2.o libavcodec/cbs_mpeg2.c

What Operating System are you running?

Windows 11

What version of HandBrake are you running?

Nightly

Where did you download HandBrake from?

No response

@marcosfrm
Copy link
Contributor Author

-> #6008

@marcosfrm
Copy link
Contributor Author

Fixed by 3a431c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant