[vlc-commits] [Git][videolan/vlc][3.0.x] 12 commits: configure: use WINSTORECOMPAT when building for Windows Store

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Oct 14 13:48:07 UTC 2024



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
c99ecb1a by Steve Lhomme at 2024-10-14T12:39:18+00:00
configure: use WINSTORECOMPAT when building for Windows Store

We may use some forbidden APIs that are actually usable via WindowsStoreCompat

GetACP in the core, for example.

(cherry picked from commit 277b45efff01dcccd42f1e4943aa09297f99650e)

- - - - -
841ea442 by Steve Lhomme at 2024-10-14T12:39:18+00:00
contrib: libarchive: disable Werror when building

We have odd configurations that it may not expect. Like passing -gcodeview
to get .pdb files in clang.

Werror is on by default in debug builds.

(cherry picked from commit a57b38d5306fb0839283383a51c0792dae13954a) (rebased)
rebased:
- the comment about XP/Win7 support is different on 3.0

- - - - -
948bfcfe by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: build.sh: add an option to set the Windows SDK version

The NTDDI version contains the windows version and the subversion like the
Windows 10 flavor or Service Pack. This is supported by mingw64 and MSDK.

https://docs.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers
(cherry picked from commit 62cdc93a11775210f39f03b71afc3a2133f6d567) (edited)
edited:
- the minimum WINVER for 3.0 is XP SP1 (0x0502)
- when selecting UCRT we still force the minimum to Win7 (0x0601)

- - - - -
30f36be4 by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: set _UCRT when enabling URCT in mingw-64

_UCRT was not set automatically in with mingw-w64 older than 7 [1]. _UCRT is
needed to enable certain UCRT API. It's also set by MSVC.

[1] https://github.com/mingw-w64/mingw-w64/commit/8b2ece59fccf0a65257b1ba2fe8d67d7e8a2e8c1

(cherry picked from commit 4657ba2647ca051294dc5fce38a38488e775bb95)

- - - - -
214c7bc2 by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: detect we build with a UCRT toolchain

(cherry picked from commit 23fac2466a6284f1b341d3f87e3fa9f336d87c7e)

- - - - -
85b05c03 by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: detect when UCRT is enabled without a UCRT toolchain

(cherry picked from commit 5d219486314740ca005d55dc1320d491b7052d39)

- - - - -
88c0c371 by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: add the -l in the EXTRA_CRUNTIME string

So we don't have to repeat it each time

(cherry picked from commit 9178cfcd74764490076a1934c31dd6cdb1d8d75d) (rebased)
rebased:
- on 3.0 we set the minimum Windows version with UCRT support to Win7 (0x0601)

- - - - -
4ed2fd97 by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: don't force ucrt linking with C/C++ file

We already check that the C toolchain defaults to UCRT since 23fac2466a6284f1b341d3f87e3fa9f336d87c7e.
Using -lucrt with recent cland creates a warning.
arrib25 is compiled with -Werror which prevents it from compiling. But we don't
need -lucrt at all.

(cherry picked from commit e6cf68a5326d3e91fec81623b726b6104a803dbc) (rebased)
rebased:
- on 3.0 we set the minimum Windows version with UCRT support to Win7 (0x0601)

- - - - -
8a5276b3 by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: remove forced vcruntime140_app linking

We should not need it with UCRT.

(cherry picked from commit 522d0b7796bfb9d46a79a114bb2903998922f490) (rebased)
rebased:
- 522d0b7796bfb9d46a79a114bb2903998922f490

- - - - -
0fe8d038 by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: don't force windowsappcompat in contribs

It's already done in contrib/main.mak and should be removed from there.

(cherry picked from commit 36129d5171e07f3e1f2789aee0bf5d6988ddf921) (rebased)
rebased:
- on 3.0 we set the minimum Windows version with UCRT support to Win7 (0x0601)

- - - - -
ce24e0ed by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: fix UWP warnings when forcing windowsapp linking

When files are compiled they don't use the linker part and clang emits a warning.
Some contribs like libvpx use -Werror and won't build if there's anything
extra in the command-line.

(cherry picked from commit 98598ce92e9d36cb296d8ab39a0998a5f27d773c) (rebased)
rebased:
- on 3.0 we set the minimum Windows version with UCRT support to Win7 (0x0601)

- - - - -
651679fa by Steve Lhomme at 2024-10-14T12:39:18+00:00
package/win32: use the mingw-llvm ar/ranlib

If a regular gcc toolchain is also in the path the gcc-ar/gcc-ranlib
variants will be used. We want to use the one coming with the mingw-llvm toolchain.

(cherry picked from commit 232d0a2c2500fcd83c596f3fb5e292e1f452b075)

- - - - -


3 changed files:

- configure.ac
- contrib/src/libarchive/rules.mak
- extras/package/win32/build.sh


Changes:

=====================================
configure.ac
=====================================
@@ -343,9 +343,13 @@ AS_IF([test "${SYS}" = "mingw32"],[
   AS_IF([test "${enable_winstore_app}" = "yes"], [
     vlc_winstore_app=1
     LIBCOM=""
-     VLC_ADD_LIBS([libvlccore], [-lruntimeobject])
-     AC_LIBOBJ([gai_strerror])
-    ],[])
+    AX_APPEND_FLAG([-DWINSTORECOMPAT],[CFLAGS])
+    AX_APPEND_FLAG([-DWINSTORECOMPAT],[CPPFLAGS])
+    AX_APPEND_FLAG([-DWINSTORECOMPAT],[CXXFLAGS])
+    AX_APPEND_FLAG([-lwinstorecompat], [LDFLAGS])
+    VLC_ADD_LIBS([libvlccore], [-lruntimeobject])
+    AC_LIBOBJ([gai_strerror])
+  ],[])
   AC_SUBST(LIBCOM)
   ])
 AC_DEFINE_UNQUOTED(VLC_WINSTORE_APP, ${vlc_winstore_app}, [Define to 1 if you want to build for Windows Store apps])


=====================================
contrib/src/libarchive/rules.mak
=====================================
@@ -17,7 +17,7 @@ LIBARCHIVE_CONF := \
 		-DENABLE_CPIO=OFF -DENABLE_TAR=OFF -DENABLE_CAT=OFF \
 		-DENABLE_NETTLE=OFF \
 		-DENABLE_LIBXML2=OFF -DENABLE_LZMA=OFF -DENABLE_ICONV=OFF -DENABLE_EXPAT=OFF \
-		-DENABLE_TEST=OFF
+		-DENABLE_TEST=OFF -DENABLE_WERROR=OFF
 
 # CNG enables bcrypt on Windows and useless otherwise, it's not used when building for XP
 LIBARCHIVE_CONF +=-DENABLE_CNG=ON


=====================================
extras/package/win32/build.sh
=====================================
@@ -31,6 +31,7 @@ OPTIONS:
    -D <win_path> Create PDB files during the build, map the VLC sources to <win_path>
                  e.g.: -D c:/sources/vlc
    -x            Add extra checks when compiling
+   -S <sdkver>   Use maximum Windows API version (0x0601000 by default)
    -u            Use the Universal C Runtime (instead of msvcrt)
    -w            Restrict to Windows Store APIs
    -z            Build without GUI (libvlc only)
@@ -39,7 +40,7 @@ EOF
 }
 
 ARCH="x86_64"
-while getopts "hra:pcli:sb:dD:xuwzo:" OPTION
+while getopts "hra:pcli:sb:dD:xS:uwzo:" OPTION
 do
      case $OPTION in
          h)
@@ -81,6 +82,9 @@ do
          x)
              EXTRA_CHECKS="yes"
          ;;
+         S)
+             NTDDI=$OPTARG
+         ;;
          u)
              BUILD_UCRT="yes"
          ;;
@@ -136,6 +140,13 @@ else
     COMPILING_WITH_CLANG=0
 fi
 
+# Check if this is a UCRT toolchain
+if printf "#include <crtdefs.h>\n#if defined(_UCRT) || (__MSVCRT_VERSION__ >= 0x1400) || (__MSVCRT_VERSION__ >= 0xE00 && __MSVCRT_VERSION__ < 0x1000)\n# error This is a UCRT build\n#endif" | $CC -E - 1>/dev/null 2>/dev/null; then
+    COMPILING_WITH_UCRT=0
+else
+    COMPILING_WITH_UCRT=1
+fi
+
 info "Building extra tools"
 mkdir -p extras/tools
 cd extras/tools
@@ -157,6 +168,12 @@ cd ../../
 
 CONTRIB_PREFIX=$TRIPLET
 if [ ! -z "$BUILD_UCRT" ]; then
+
+    if [ ! "$COMPILING_WITH_UCRT" -gt 0 ]; then
+        echo "UCRT builds need a UCRT toolchain"
+        exit 1
+    fi
+
     if [ ! -z "$WINSTORE" ]; then
         CONTRIBFLAGS="$CONTRIBFLAGS --disable-disc --disable-srt --disable-sdl --disable-SDL_image --disable-caca"
         # modplug uses GlobalAlloc/Free and lstrcpyA/wsprintfA/lstrcpynA
@@ -200,33 +217,39 @@ fi
 
 if [ ! -z "$BUILD_UCRT" ]; then
     WIDL=${TRIPLET}-widl
-    CPPFLAGS="$CPPFLAGS -D__MSVCRT_VERSION__=0xE00"
+    CPPFLAGS="$CPPFLAGS -D__MSVCRT_VERSION__=0xE00 -D_UCRT"
 
     if [ ! -z "$WINSTORE" ]; then
         SHORTARCH="$SHORTARCH-uwp"
-        CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_UNICODE -DUNICODE"
-
-        # WinstoreCompat: hopefully can go away someday
-        LDFLAGS="$LDFLAGS -lwindowsapp -lwindowsappcompat"
-        CFLAGS="$CFLAGS -Wl,-lwindowsapp,-lwindowsappcompat"
-        CXXFLAGS="$CXXFLAGS -Wl,-lwindowsapp,-lwindowsappcompat"
-        CPPFLAGS="$CPPFLAGS -DWINSTORECOMPAT"
-        EXTRA_CRUNTIME="vcruntime140_app"
+        CPPFLAGS="$CPPFLAGS -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_UNICODE -DUNICODE"
+
+        if [ -z "$NTDDI" ]; then
+            WINVER=0x0A00
+        else
+            WINVER=`echo ${NTDDI} |cut -c 1-6`
+            if [ "$WINVER" != "0x0A00" ]; then
+                echo "Unsupported SDK/NTDDI version ${NTDDI} for Winstore"
+            fi
+        fi
+
+        LDFLAGS="$LDFLAGS -lwindowsapp"
+        CFLAGS="$CFLAGS -Wl,-lwindowsapp"
+        CXXFLAGS="$CXXFLAGS -Wl,-lwindowsapp"
+        if [ "$COMPILING_WITH_CLANG" -gt 0 ]; then
+            CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
+            CXXFLAGS="$CXXFLAGS -Wno-unused-command-line-argument"
+        fi
     else
         SHORTARCH="$SHORTARCH-ucrt"
-        # The current minimum for VLC is Windows 7
-        CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0601 -DWINVER=0x0601"
-        # this library doesn't exist yet, so use ucrt twice as a placeholder
-        # EXTRA_CRUNTIME="vcruntime140"
-        EXTRA_CRUNTIME="ucrt"
+        WINVER=0x0601
     fi
 
-    LDFLAGS="$LDFLAGS -l$EXTRA_CRUNTIME -lucrt"
+    LDFLAGS="$LDFLAGS -lucrt"
     if [ ! "$COMPILING_WITH_CLANG" -gt 0 ]; then
         # assume gcc
         NEWSPECFILE="`pwd`/specfile-$SHORTARCH"
         # tell gcc to replace msvcrt with ucrtbase+ucrt
-        $CC -dumpspecs | sed -e "s/-lmsvcrt/-l$EXTRA_CRUNTIME -lucrt/" > $NEWSPECFILE
+        $CC -dumpspecs | sed -e "s/-lmsvcrt/-lucrt/" > $NEWSPECFILE
         CFLAGS="$CFLAGS -specs=$NEWSPECFILE"
         CXXFLAGS="$CXXFLAGS -specs=$NEWSPECFILE"
 
@@ -237,18 +260,28 @@ if [ ! -z "$BUILD_UCRT" ]; then
             sed -i -e "s/-luser32//" $NEWSPECFILE
             sed -i -e "s/-lkernel32//" $NEWSPECFILE
         fi
-    else
-        CFLAGS="$CFLAGS -Wl,-l$EXTRA_CRUNTIME,-lucrt"
-        CXXFLAGS="$CXXFLAGS -Wl,-l$EXTRA_CRUNTIME,-lucrt"
     fi
 
     # the values are not passed to the makefiles/configures
     export LDFLAGS
-    export CPPFLAGS
 else
-    # The current minimum for VLC 3.0 is Windows XP SP1 and to use the regular msvcrt
-    CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0502 -DWINVER=0x502 -D__MSVCRT_VERSION__=0x700"
+    # use the regular msvcrt
+    CPPFLAGS="$CPPFLAGS -D__MSVCRT_VERSION__=0x700"
+fi
+
+if [ -n "$NTDDI" ]; then
+    WINVER=`echo ${NTDDI} |cut -c 1-6`
+    CPPFLAGS="$CPPFLAGS -DNTDDI_VERSION=$NTDDI"
 fi
+if [ -z "$WINVER" ]; then
+    # The current minimum for VLC 3.0 is Windows XP SP1
+    WINVER=0x0502
+fi
+CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=${WINVER} -DWINVER=${WINVER}"
+
+# the values are not passed to the makefiles/configures
+export CPPFLAGS
+
 CFLAGS="$CPPFLAGS $CFLAGS"
 CXXFLAGS="$CPPFLAGS $CXXFLAGS"
 
@@ -277,6 +310,15 @@ if [ ! -z "$WINSTORE" ]; then
     export HAVE_WINSTORE=1
 fi
 
+if [ "$COMPILING_WITH_CLANG" -gt 0 ]; then
+    # avoid using gcc-ar with the clang toolchain, if both are installed
+    AR="$TRIPLET-ar"
+    export AR
+    # avoid using gcc-ranlib with the clang toolchain, if both are installed
+    RANLIB="$TRIPLET-ranlib"
+    export RANLIB
+fi
+
 export CFLAGS
 export CXXFLAGS
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e020f9abb31809584e33d740593d6ae5a190771d...651679fa2f9f7941327cf7fc975383c4f08f7c95

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e020f9abb31809584e33d740593d6ae5a190771d...651679fa2f9f7941327cf7fc975383c4f08f7c95
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list