Skip to contentSkip to conversation

Disable movw/movt with clang

DISCUSSION Andrei Borzenkov 2 participants 4 messages Jan 28, 2017

lore
Share & tools
lore
#0 lore raw
Quoted 11 lines
configure.ac +3 -0
index 4e980c5..ab7fa92 100644
@@ -1152,6 +1152,16 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then
 fi
 
 if test "x$target_cpu" = xarm; then
+  AC_CACHE_CHECK([whether option -mllvm -arm-use-movt=0 works], grub_cv_cc_mllvm_arm_use_movt, [
+    CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0 -Werror"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; then · line 1167

Quoted 10 lines
configure.ac +7 -0
+                     [grub_cv_cc_mllvm_arm_use_movt=yes],
+                     [grub_cv_cc_mllvm_arm_use_movt=no])
+  ])
+  if test "x$grub_cv_cc_mllvm_arm_use_movt" = xyes; then
+    # A trick so that clang doesn't see it on link stage
+    TARGET_CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0"
+  fi
   AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [
     CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],

Is this option supported by all clang versions? What should we do if this is *not* supported? As far as I understand commit message this leads to broken code?

Is "-mllvm -arm-use-movt=0" different from "-mno-movt" which appears to be "official" way to disable it?

#1 lore raw
Quoted 21 lines · On Sat, 28 Jan 2017, 09:27 Andrei Borzenkov <[email protected]> wrote:

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi;

Quoted 5 lines
configure.ac +0 -0
index 4e980c5..ab7fa92 100644
@@ -1152,6 +1152,16 @@ if test "$target_cpu"-"$platform" = x86_64-efi;

then

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1155

Quoted 4 lines
configure.ac +1 -0
 fi
 
 if test "x$target_cpu" = xarm; then
+  AC_CACHE_CHECK([whether option -mllvm -arm-use-movt=0 works],

grub_cv_cc_mllvm_arm_use_movt, [

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1165

Quoted 10 lines
configure.ac +9 -0
+    CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0 -Werror"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+                     [grub_cv_cc_mllvm_arm_use_movt=yes],
+                     [grub_cv_cc_mllvm_arm_use_movt=no])
+  ])
+  if test "x$grub_cv_cc_mllvm_arm_use_movt" = xyes; then
+    # A trick so that clang doesn't see it on link stage
+    TARGET_CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0"
+  fi
   AC_CACHE_CHECK([whether option -mlong-calls works],
Quoted 8 lines

grub_cv_cc_mlong_calls, [

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1167

Quoted 2 lines
configure.ac +0 -0
     CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],

Is this option supported by all clang versions? What should we do if this is *not* supported? As far as I understand commit message this leads to broken code?

The only other workaround there is, is to use -march=armv6. The window for the problem is narrow as apparently there wasn't a lot of time between use of movt/movw and the option to disable it.
The problem when exists is successfully detected by module-verifier.

Quoted 4 lines

Is "-mllvm -arm-use-movt=0" different from "-mno-movt" which appears to be "official" way to disable it?

I peeked this option at uboot which has the same problem.
Mno-movt needs clang 3.8 whereas the llvm variant only 3.7. I'm unsure when movt/movw was introduced.

Quoted 6 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
Quoted 39 lines · On Sat, 28 Jan 2017, 14:49 Vladimir 'phcoder' Serbinenko <[email protected]>…

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi;

Quoted 5 lines · On Sat, 28 Jan 2017, 09:27 Andrei Borzenkov <[email protected]> wrote:
configure.ac +0 -0
index 4e980c5..ab7fa92 100644
@@ -1152,6 +1152,16 @@ if test "$target_cpu"-"$platform" = x86_64-efi;

then

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1155

Quoted 4 lines
configure.ac +1 -0
 fi
 
 if test "x$target_cpu" = xarm; then
+  AC_CACHE_CHECK([whether option -mllvm -arm-use-movt=0 works],

grub_cv_cc_mllvm_arm_use_movt, [

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1165

Quoted 10 lines
configure.ac +9 -0
+    CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0 -Werror"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+                     [grub_cv_cc_mllvm_arm_use_movt=yes],
+                     [grub_cv_cc_mllvm_arm_use_movt=no])
+  ])
+  if test "x$grub_cv_cc_mllvm_arm_use_movt" = xyes; then
+    # A trick so that clang doesn't see it on link stage
+    TARGET_CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0"
+  fi
   AC_CACHE_CHECK([whether option -mlong-calls works],

grub_cv_cc_mlong_calls, [

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1167

Quoted 2 lines
configure.ac +0 -0
     CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],

Is this option supported by all clang versions? What should we do if this is *not* supported? As far as I understand commit message this leads to broken code?

The only other workaround there is, is to use -march=armv6. The window for the problem is narrow as apparently there wasn't a lot of time between use of movt/movw and the option to disable it.
The problem when exists is successfully detected by module-verifier.

Quoted 7 lines

Is "-mllvm -arm-use-movt=0" different from "-mno-movt" which appears to be "official" way to disable it?

I peeked this option at uboot which has the same problem.
Mno-movt needs clang 3.8 whereas the llvm variant only 3.7. I'm unsure when movt/movw was introduced.

This being said, I'm fine with preferring mno-movt. I just didn't care enough either way.

Quoted 7 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
In reply to Vladimir 'phcoder' Serbinenko
Quoted 39 lines · On Sat, 28 Jan 2017, 14:49 Vladimir 'phcoder' Serbinenko <[email protected]>…

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi;

Quoted 5 lines · On Sat, 28 Jan 2017, 09:27 Andrei Borzenkov <[email protected]> wrote:
configure.ac +0 -0
index 4e980c5..ab7fa92 100644
@@ -1152,6 +1152,16 @@ if test "$target_cpu"-"$platform" = x86_64-efi;

then

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1155

Quoted 4 lines
configure.ac +1 -0
 fi
 
 if test "x$target_cpu" = xarm; then
+  AC_CACHE_CHECK([whether option -mllvm -arm-use-movt=0 works],

grub_cv_cc_mllvm_arm_use_movt, [

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1165

Quoted 10 lines
configure.ac +9 -0
+    CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0 -Werror"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+                     [grub_cv_cc_mllvm_arm_use_movt=yes],
+                     [grub_cv_cc_mllvm_arm_use_movt=no])
+  ])
+  if test "x$grub_cv_cc_mllvm_arm_use_movt" = xyes; then
+    # A trick so that clang doesn't see it on link stage
+    TARGET_CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0"
+  fi
   AC_CACHE_CHECK([whether option -mlong-calls works],

grub_cv_cc_mlong_calls, [

configure.ac if test "$target_cpu"-"$platform" = x86_64-efi; · line 1167

Quoted 2 lines
configure.ac +0 -0
     CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],

Is this option supported by all clang versions? What should we do if this is *not* supported? As far as I understand commit message this leads to broken code?

The only other workaround there is, is to use -march=armv6. The window for the problem is narrow as apparently there wasn't a lot of time between use of movt/movw and the option to disable it.
The problem when exists is successfully detected by module-verifier.

Quoted 7 lines

Is "-mllvm -arm-use-movt=0" different from "-mno-movt" which appears to be "official" way to disable it?

I peeked this option at uboot which has the same problem.
Mno-movt needs clang 3.8 whereas the llvm variant only 3.7. I'm unsure when movt/movw was introduced.

Actually mllvm variant apparently was introduced even earlier. My clang 3.5 has it already. On the other hand apparently 3.9 recognises only mno-movt. I'll fix it to prefer mno-movt.

phcoder@localhost:~/clang-uboot$ clang -mno-llvm 1.c -c
clang: error: unknown argument: '-mno-llvm'
phcoder@localhost:~/clang-uboot$ clang -mllvm -arm-use-movt=0 1.c -c
phcoder@localhost:~/clang-uboot$ clang --version
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: arm-unknown-linux-gnueabihf
Thread model: posix
Quoted 7 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel