[vlc-commits] [Git][videolan/vlc][master] 4 commits: contrib: rust: replace "test ! -z" with "test -n"

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Jul 31 17:14:17 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
19719525 by Steve Lhomme at 2024-07-31T15:53:02+00:00
contrib: rust: replace "test ! -z" with "test -n"

It's stricly equivalent and avoids a negative test.

- - - - -
79e07550 by Steve Lhomme at 2024-07-31T15:53:02+00:00
contrib: rust: only enable windows-gnullvm with LLVM

And only windows-gnu when not compiled with LLVM.

- - - - -
a5f604ce by Steve Lhomme at 2024-07-31T15:53:02+00:00
contrib: rust: allow both MSVCRT and UCRT with windows-gnu*

When using a static Rust libstd the linker can pick the runtime it wants.
It will correspond to the same runtime we use for the rest of the code.

See https://code.videolan.org/videolan/vlc/-/merge_requests/5675#note_447873

gnullvm targets most importantly use LLVM libraries and ABI. So libgcc is replaced
with libunwind, the linker is LLD, it uses native TLS instead of emutls, function
sections are enabled, and there's probably something else that I forgot. UCRT
is another difference, but a smaller one since the changes from my previous
sentence cause builds with GCC/Binutils to break.

windows-gnu targets are built with MSVCRT, but that shouldn't be a big deal as
long as you stick to the default static std library (in other words, as long as
you don't use -C prefer-dynamic). I can't guarantee it will always work, but
t's much better compared to using windows-gnullvm targets, which have a 100%
chance of failing when using them with GCC/Binutils. Unless you want to migrate
to LLVM as well (windows-gnullvm targets by default will pick Clang from PATH
as the linker), but that would be a much bigger change than this PR implies.

- - - - -
0119f814 by Steve Lhomme at 2024-07-31T15:53:02+00:00
contrib: rust: remove unused --ucrt option

- - - - -


3 changed files:

- configure.ac
- contrib/src/get-rust-target.sh
- contrib/src/main-rust.mak


Changes:

=====================================
configure.ac
=====================================
@@ -1895,8 +1895,8 @@ AS_IF([test "${enable_rust}" = "yes"],[
   AS_IF([test "$vlc_winstore_app" = "1"],[
     rust_target_flags="${rust_target_flags} --uwp"
   ])
-  AS_IF([test "${win_ucrt_build}" = "yes"],[
-    rust_target_flags="${rust_target_flags} --ucrt"
+  AS_IF([test -n "$(eval ${CC} --version 2>/dev/null | grep 'clang')"],[
+    rust_target_flags="${rust_target_flags} --llvm"
   ])
   AS_IF([test "${HAVE_TVOS}" = "1"],[
     rust_target_flags="${rust_target_flags} --darwin=tvos"


=====================================
contrib/src/get-rust-target.sh
=====================================
@@ -11,8 +11,8 @@
 DARWIN=
 ARCH=
 OS=
+LLVM=
 UWP=
-UCRT=
 SIMULATOR=
 TRIPLET=
 
@@ -61,7 +61,7 @@ validate_triplet()
   OS=$(echo $1 | cut -f 3 -d '-')
   REST=$(echo $1 | cut -f 4 -d '-')
 
-  if test ! -z "$REST"; then
+  if test -n "$REST"; then
     OS=$REST
   fi
   if test -z "$ARCH" || test -z "$UNUSED" || test -z "$OS"; then
@@ -71,7 +71,7 @@ validate_triplet()
 
 print_usage()
 {
-    echo "Usage: $0 [--ucrt] [--uwp] [--darwin {macos,ios,tvos,watchos,xros}] [--simulator] triplet"
+    echo "Usage: $0 [--uwp] [--llvm] [--darwin {macos,ios,tvos,watchos,xros}] [--simulator] triplet"
 }
 
 
@@ -80,8 +80,8 @@ for ARG in "$@"; do
     --uwp)
       UWP=1
       ;;
-    --ucrt)
-      UCRT=1
+    --llvm)
+      LLVM=1
       ;;
     --simulator)
       SIMULATOR=1
@@ -102,7 +102,7 @@ done
 
 case $OS in
   mingw32|mingw32ucrt|mingw32uwp)
-    if test ! -z "$UWP"; then
+    if test -n "$UWP"; then
       abort_err "UWP Windows is Tier 3"
     fi
     case $ARCH in
@@ -110,7 +110,7 @@ case $OS in
         abort_err "ARMv7 Windows not supported by Rust"
         ;;
     esac
-    if test ! -z "$UCRT"; then
+    if test -n "$LLVM"; then
       return_triplet $ARCH-pc-windows-gnullvm
     else
       return_triplet $ARCH-pc-windows-gnu
@@ -147,7 +147,7 @@ case $OS in
         ;;
 
       ios)
-        if test ! -z "$SIMULATOR"; then
+        if test -n "$SIMULATOR"; then
           case $ARCH in
             aarch64|arm64)
               return_triplet aarch64-apple-ios-sim


=====================================
contrib/src/main-rust.mak
=====================================
@@ -13,10 +13,13 @@ endif
 ifdef HAVE_UCRT
 # does not work as Tier 2 before that
 RUST_VERSION_MIN=1.79.0
-RUST_TARGET_FLAGS += --ucrt
 endif
 endif
 
+ifdef HAVE_CLANG
+RUST_TARGET_FLAGS += --llvm
+endif
+
 ifdef HAVE_DARWIN_OS
 ifdef HAVE_TVOS
 RUST_TARGET_FLAGS += --darwin=tvos



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c60be60d2f4fb24f5101fb928b6ca83457e0fdc4...0119f8141b8ef38822540313d77594baf6a78e07

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c60be60d2f4fb24f5101fb928b6ca83457e0fdc4...0119f8141b8ef38822540313d77594baf6a78e07
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