Messages in this thread | | | From | Nick Desaulniers <> | Date | Wed, 18 May 2022 15:38:18 -0700 | Subject | Re: [PATCH v3 4/4] ARM: pass -march= only to compiler |
| |
Lore thread, for context: https://lore.kernel.org/llvm/20220516210954.1660716-1-ndesaulniers@google.com/
On Tue, May 17, 2022 at 6:26 PM kernel test robot <lkp@intel.com> wrote: > > Hi Nick, > > I love your patch! Yet something to improve: > > [auto build test ERROR on 0ac824f379fba2c2b17b75fd5ada69cd68c66348] > > url: https://github.com/intel-lab-lkp/linux/commits/Nick-Desaulniers/pass-march-only-to-compiler/20220517-051756 > base: 0ac824f379fba2c2b17b75fd5ada69cd68c66348 > config: arm-randconfig-r026-20220516 (https://download.01.org/0day-ci/archive/20220518/202205180917.RNpZaxIl-lkp@intel.com/config)
^ looks like this is a THUMB2 build.
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 853fa8ee225edf2d0de94b0dcbd31bea916e825e) > reproduce (this is a W=1 build): > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # install arm cross compiling tool for clang build > # apt-get install binutils-arm-linux-gnueabi > # https://github.com/intel-lab-lkp/linux/commit/6da98100eed87e4316be5ec584fe415134f25a3e > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review Nick-Desaulniers/pass-march-only-to-compiler/20220517-051756 > git checkout 6da98100eed87e4316be5ec584fe415134f25a3e > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot <lkp@intel.com> > > All errors (new ones prefixed by >>): > > >> arch/arm/crypto/poly1305-core.S:16:1: error: target does not support ARM mode > .code 32 > ^
It looks like arch/arm/crypto/poly1305-core.S has a preprocessor guard for __thumb2__.
My change changes the command line from:
from: $(CC) ... -march=armv7-m ... to: $(CC ... -Wa,-march=armv7-m ...
(where ... contains `-mthumb -Wa,-mthumb` for BOTH).
$ arm-linux-gnueabi-gcc -march=armv7-m -mthumb -dM -E - < /dev/null | grep thumb #define __thumb2__ 1 #define __thumb__ 1 $ arm-linux-gnueabi-gcc -Wa,-march=armv7-m -mthumb -dM -E - < /dev/null | grep thumb #define __thumb__ 1 $ clang --target=arm-linux-gnueabi -march=armv7-m -mthumb -dM -E - < /dev/null | grep thumb #define __thumb2__ 1 #define __thumb__ 1 $ clang --target=arm-linux-gnueabi -Wa,-march=armv7-m -mthumb -dM -E - < /dev/null | grep thumb #define __thumb__ 1 $
(so it seems that the preprocessor definition of `__thumb2__` is dependent on `-march=`, not `-Wa,-march=`).
David, we might have a very subtle bug in clang:
$ clang --target=arm-linux-gnueabi -mthumb -Wa,-mthumb -march=armv7-m -Wa,-march=armv7-m -x assembler-with-cpp -Wunused-command-line-argument - < /dev/null -dM -E <prints a bunch of preprocessor defines, but no instance of -Wunused-command-line-argument> $ clang --target=arm-linux-gnueabi -mthumb -Wa,-mthumb -march=armv7-m -Wa,-march=armv7-m -x assembler-with-cpp -Wunused-command-line-argument - < /dev/null -dM -c clang-15: warning: argument unused during compilation: '-march=armv7-m' [-Wunused-command-line-argument]
That seems weird because -c vs -E have different behaviors regarding -Wunused-command-line-argument, and it seems like for `-x assembler-with-cpp` that the -march= flag without -Wa, prefix *is* expected to control the behavior of certain preprocessor defines like `__thumb2__`.
Perhaps a more straightforward test case: ```asm @ x.S @ clang --target=arm-linux-gnueabi -mthumb -Wa,-mthumb -march=armv7-m \ @ -Wa,-march=armv7-m -Wunused-command-line-argument x.S -c .syntax unified .text foo: movs r0, #__thumb2__ ```
$ clang --target=arm-linux-gnueabi -mthumb -Wa,-mthumb -march=armv7-m -Wa,-march=armv7-m -Wunused-command-line-argument x.S -c clang-15: warning: argument unused during compilation: '-march=armv7-m' [-Wunused-command-line-argument]
$ llvm-objdump -dr x.o | tail -n 2 00000000 <foo>: 0: 01 20 movs r0, #1
Obviously that warning about `-Wunused-command-line-argument` is incorrect; the value of `__thumb2__` comes from the preprocessor and is controlled by `-march=armv7-m`. It can't be simultaneously "unused" and used to define particular preprocessor directives.
Using the above command line invocation without `-march=armv7-m` produces the assembler-time failure: /tmp/x-03ab60.s:10:3: error: unsupported relocation on symbol movs r0, #__thumb2__ ^ because __thumb2__ is not defined.
(perhaps `#ifundef __thumb2__ #error "oops" #endif` would be simpler yet).
> > -- > 0-DAY CI Kernel Test Service > https://01.org/lkp >
-- Thanks, ~Nick Desaulniers
| |