Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] configure: make the C and C++ standard settable
@ 2024-03-19 18:58 James Almer
  2024-03-19 18:58 ` [FFmpeg-devel] [PATCH 2/2] configure: check for C17 by default James Almer
  0 siblings, 1 reply; 5+ messages in thread
From: James Almer @ 2024-03-19 18:58 UTC (permalink / raw)
  To: ffmpeg-devel

Fallback to C11, the minimum supported version, if the requested standard is
not supported by the compliler.
Also, enforce C11 on the host compiler, same as we already do for C11 on the
target compiler.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 configure | 55 ++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 46 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index e019d1b996..b10d081549 100755
--- a/configure
+++ b/configure
@@ -387,7 +387,9 @@ Toolchain options:
   --windres=WINDRES        use windows resource compiler WINDRES [$windres_default]
   --x86asmexe=EXE          use nasm-compatible assembler EXE [$x86asmexe_default]
   --cc=CC                  use C compiler CC [$cc_default]
+  --stdc=STDC              use C standard STDC [$stdc_default]
   --cxx=CXX                use C compiler CXX [$cxx_default]
+  --stdcxx=STDCXX          use C standard STDCXX [$stdcxx_default]
   --objcc=OCC              use ObjC compiler OCC [$cc_default]
   --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
   --nvcc=NVCC              use Nvidia CUDA compiler NVCC or clang [$nvcc_default]
@@ -1454,6 +1456,21 @@ test_cflags_cc(){
 EOF
 }
 
+test_cxxflags_cc(){
+    log test_cxxflags_cc "$@"
+    flags=$1
+    header=$2
+    condition=$3
+    shift 3
+    set -- $($cflags_filter "$flags")
+    test_cxx "$@" <<EOF
+#include <$header>
+#if !($condition)
+#error "unsatisfied condition: $condition"
+#endif
+EOF
+}
+
 check_lib(){
     log check_lib "$@"
     name="$1"
@@ -1695,6 +1712,21 @@ int x;
 EOF
 }
 
+test_host_cflags_cc(){
+    log test_host_cflags_cc "$@"
+    flags=$1
+    header=$2
+    condition=$3
+    shift 3
+    set -- $($host_cflags_filter "$flags")
+    test_host_cc "$@" <<EOF
+#include <$header>
+#if !($condition)
+#error "unsatisfied condition: $condition"
+#endif
+EOF
+}
+
 test_host_cpp_condition(){
     log test_host_cpp_condition "$@"
     header=$1
@@ -3980,6 +4012,8 @@ mandir_default='${prefix}/share/man'
 # toolchain
 ar_default="ar"
 cc_default="gcc"
+stdc_default="c11"
+stdcxx_default="c++11"
 cxx_default="g++"
 host_cc_default="gcc"
 doxygen_default="doxygen"
@@ -4587,7 +4621,7 @@ if enabled cuda_nvcc; then
 fi
 
 set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \
-    target_exec x86asmexe metalcc metallib
+    target_exec x86asmexe metalcc metallib stdc stdcxx
 enabled cross_compile || host_cc_default=$cc
 set_default host_cc
 
@@ -4757,7 +4791,7 @@ icl_flags(){
             # Despite what Intel's documentation says -Wall, which is supported
             # on Windows, does enable remarks so disable them here.
             -Wall)                echo $flag -Qdiag-disable:remark ;;
-            -std=c11)             echo -Qstd=c11 ;;
+            -std=$stdc)           echo -Qstd=$stdc ;;
             -flto*)               echo -ipo ;;
         esac
     done
@@ -4805,7 +4839,7 @@ suncc_flags(){
                     athlon*)                   echo -xarch=pentium_proa  ;;
                 esac
                 ;;
-            -std=c11)             echo -xc11              ;;
+            -std=$stdc)           echo -x$stdc            ;;
             -fomit-frame-pointer) echo -xregs=frameptr    ;;
             -fPIC)                echo -KPIC -xcode=pic32 ;;
             -W*,*)                echo $flag              ;;
@@ -4894,8 +4928,8 @@ probe_cc(){
         _type=suncc
         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
-        _DEPFLAGS='-xM1 -xc11'
-        _ldflags='-std=c11'
+        _DEPFLAGS='-xM1 -x$stdc'
+        _ldflags='-std=$stdc'
         _cflags_speed='-O5'
         _cflags_size='-O5 -xspace'
         _flags_filter=suncc_flags
@@ -5526,18 +5560,21 @@ fi
 
 add_cppflags -D_ISOC11_SOURCE
 add_cxxflags -D__STDC_CONSTANT_MACROS
-check_cxxflags -std=c++11 || check_cxxflags -std=c++0x
+test_cxxflags_cc -std=$stdcxx ctype.h "__cplusplus >= 201103L" &&
+    add_cxxflags -std=$stdcxx || { check_cxxflags -std=c++11 || check_cxxflags -std=c++0x; }
 
 # some compilers silently accept -std=c11, so we also need to check that the
 # version macro is defined properly
-test_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L" &&
-    add_cflags -std=c11 || die "Compiler lacks C11 support"
+test_cflags_cc -std=$stdc ctype.h "__STDC_VERSION__ >= 201112L" &&
+    add_cflags -std=$stdc || die "Compiler lacks C11 support"
 
 check_cppflags -D_FILE_OFFSET_BITS=64
 check_cppflags -D_LARGEFILE_SOURCE
 
 add_host_cppflags -D_ISOC11_SOURCE
-check_host_cflags -std=c11
+test_host_cflags_cc -std=$stdc ctype.h "__STDC_VERSION__ >= 201112L" &&
+    add_host_cflags -std=$stdc || die "Host compiler lacks C11 support"
+
 check_host_cflags -Wall
 check_host_cflags $host_cflags_speed
 
-- 
2.44.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] configure: check for C17 by default
  2024-03-19 18:58 [FFmpeg-devel] [PATCH 1/2] configure: make the C and C++ standard settable James Almer
@ 2024-03-19 18:58 ` James Almer
  2024-03-19 21:21   ` Michael Niedermayer
  0 siblings, 1 reply; 5+ messages in thread
From: James Almer @ 2024-03-19 18:58 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: James Almer <jamrial@gmail.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index b10d081549..a9a9a65ca2 100755
--- a/configure
+++ b/configure
@@ -4012,7 +4012,7 @@ mandir_default='${prefix}/share/man'
 # toolchain
 ar_default="ar"
 cc_default="gcc"
-stdc_default="c11"
+stdc_default="c17"
 stdcxx_default="c++11"
 cxx_default="g++"
 host_cc_default="gcc"
-- 
2.44.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] configure: check for C17 by default
  2024-03-19 18:58 ` [FFmpeg-devel] [PATCH 2/2] configure: check for C17 by default James Almer
@ 2024-03-19 21:21   ` Michael Niedermayer
  2024-03-19 21:31     ` Michael Niedermayer
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Niedermayer @ 2024-03-19 21:21 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 805 bytes --]

On Tue, Mar 19, 2024 at 03:58:18PM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index b10d081549..a9a9a65ca2 100755
> --- a/configure
> +++ b/configure
> @@ -4012,7 +4012,7 @@ mandir_default='${prefix}/share/man'
>  # toolchain
>  ar_default="ar"
>  cc_default="gcc"
> -stdc_default="c11"
> +stdc_default="c17"
>  stdcxx_default="c++11"
>  cxx_default="g++"
>  host_cc_default="gcc"

That breaks build here

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] configure: check for C17 by default
  2024-03-19 21:21   ` Michael Niedermayer
@ 2024-03-19 21:31     ` Michael Niedermayer
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Niedermayer @ 2024-03-19 21:31 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 919 bytes --]

On Tue, Mar 19, 2024 at 10:21:52PM +0100, Michael Niedermayer wrote:
> On Tue, Mar 19, 2024 at 03:58:18PM -0300, James Almer wrote:
> > Signed-off-by: James Almer <jamrial@gmail.com>
> > ---
> >  configure | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/configure b/configure
> > index b10d081549..a9a9a65ca2 100755
> > --- a/configure
> > +++ b/configure
> > @@ -4012,7 +4012,7 @@ mandir_default='${prefix}/share/man'
> >  # toolchain
> >  ar_default="ar"
> >  cc_default="gcc"
> > -stdc_default="c11"
> > +stdc_default="c17"
> >  stdcxx_default="c++11"
> >  cxx_default="g++"
> >  host_cc_default="gcc"
> 
> That breaks build here

also i suspect this will break various fate clients


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] configure: check for C17 by default
  2024-03-19 22:44 [FFmpeg-devel] [PATCH 1/2 v2] configure: make the C and C++ standard settable James Almer
@ 2024-03-19 22:44 ` James Almer
  0 siblings, 0 replies; 5+ messages in thread
From: James Almer @ 2024-03-19 22:44 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: James Almer <jamrial@gmail.com>
---
No changes since last version.

 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index f8381d15ff..e6689f7077 100755
--- a/configure
+++ b/configure
@@ -4012,7 +4012,7 @@ mandir_default='${prefix}/share/man'
 # toolchain
 ar_default="ar"
 cc_default="gcc"
-stdc_default="c11"
+stdc_default="c17"
 stdcxx_default="c++11"
 cxx_default="g++"
 host_cc_default="gcc"
-- 
2.44.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-19 22:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 18:58 [FFmpeg-devel] [PATCH 1/2] configure: make the C and C++ standard settable James Almer
2024-03-19 18:58 ` [FFmpeg-devel] [PATCH 2/2] configure: check for C17 by default James Almer
2024-03-19 21:21   ` Michael Niedermayer
2024-03-19 21:31     ` Michael Niedermayer
2024-03-19 22:44 [FFmpeg-devel] [PATCH 1/2 v2] configure: make the C and C++ standard settable James Almer
2024-03-19 22:44 ` [FFmpeg-devel] [PATCH 2/2] configure: check for C17 by default James Almer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git