[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error around cc-option on AArch64


  • To: Penny Zheng <Penny.Zheng@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 5 Nov 2021 13:47:19 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WmmuYe13+6QfsQMsh3TbBdhckZveyiGTojp8Dc28lrI=; b=U+Rf85aO6N11zw8vAn2KD+tYlfpcpeFet7ILuJnDsovSB9SNZEiwDEnlLC/7JyjEaCDxxKiYPVmWw6WtFIKhCsB0PtfOHeSvSvPd9oWy0w153KlkeDvwwrC4bEpsDIs7QICh7ZiRNiAVURTwe3QV4L1dmj4lE7KR7xpprqvSIsR24PtA2q5VvspbPnU+3OsmB/LVZqr4LAiGtCUeQ8u87YAn8RPEKCYjhNcrxAgN0VMAjYBxMPaeql/o4thdFqjxCULvZivSAMc1YrEmO9tn/xcfAM6Ku4SS5p7MfJR3UpbgQSQv1cDzTQAADjOAkPp/kRm/11mFD+zjZcXVyjUmNg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XY5nyhpToAk5loznZrzdETJYbm8JYFc+uG9Z42IqxaOqWOlxdqwLqwN/+1m6PhemBCBf6Q3iM7nhLjxKZwTKTP/Qnt6NfeEDz4eiYkd2glns2K5TkEvQ+fOYo+sHdF0uZAj4+CCTboIgXcs9PKuietXJKfpEJzraqIm/sYkuzqE7JXnLIjOnplvFMpn5t/7uJfWwxFgsNsSEZsXfuu93P/W5kclCrn/YcXvuWFRZLGj12DuQE3brGJm7amKOzGsU4HbgKM1LywpXSrHV1hErBE2kNPx1GeGs/yiFiobwLIZUUsK81AFHj1M0k1H/msyLcpMTe65ekjW78PUR8jBpCw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 05 Nov 2021 12:47:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.09.2021 15:03, Penny Zheng wrote:
> Hi Julien and Stefano
> 
> I found that the "cc-option/cc-option-add" is not working for "-march=xxx" 
> option on a few very common aarch64 compilers.
> Here is what I got when trying to compile XEN on r82 platform.
> ```
> diff --git a/xen/arch/arm/arch.mk b/xen/arch/arm/arch.mk
> index 11caec86ba..d2d71baef4 100644
> --- a/xen/arch/arm/arch.mk
> +++ b/xen/arch/arm/arch.mk
> @@ -10,6 +10,10 @@ $(call cc-option-add,CFLAGS,CC,-Wnested-externs)
> CFLAGS-$(CONFIG_ARM_32) += -msoft-float
> CFLAGS-$(CONFIG_ARM_32) += -mcpu=cortex-a15
> 
> +#ifeq ($(CONFIG_ARM64_V8R),y)
> +    CFLAGS-$(CONFIG_ARM_64) += $(call 
> cc-option,$(CC),-march=armv8-r,-march=armv8.4-a)
> +#endif
> +
> CFLAGS-$(CONFIG_ARM_64) += -mcpu=generic
> CFLAGS-$(CONFIG_ARM_64) += -mgeneral-regs-only # No fp registers etc
> $(call cc-option-add,CFLAGS-$(CONFIG_ARM_64),CC,-mno-outline-atomics)
> ```
> My gcc compiler version is as follows:
> ```
> Using built-in specs.
> COLLECT_GCC=aarch64-linux-gnu-gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/9/lto-wrapper
> Target: aarch64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu 
> 9.3.0-17ubuntu1~20.04'
> --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs 
> --enable-languages=c,ada,c++,
> go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only 
> --program-suffix=-9
> --enable-shared --enable-linker-build-id --libexecdir=/usr/lib 
> --without-included-gettext
> --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ 
> --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-libstdcxx-time=yes 
> --with-default-libstdcxx-abi=new
> --enable-gnu-unique-object --disable-libquadmath 
> --disable-libquadmath-support --enable-plugin
> --enable-default-pie --with-system-zlib --without-target-system-zlib 
> --enable-libpth-m2 --enable-multiarch
> --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release 
> --build=x86_64-linux-gnu
> --host=x86_64-linux-gnu --target=aarch64-linux-gnu 
> --program-prefix=aarch64-linux-gnu- 
> --includedir=/usr/aarch64-linux-gnu/include
> Thread model: posix
> gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
> ```
> However. even if my gcc compiler is indeed not supporting "-march=armv8-r", 
> above check will not identify it
> "unrecognized option" and seek to the "-march=armv8.4-a" as expected.
> See the resulting errors, it still uses "-march=armv8-r":
> ```
> make[3]: Entering directory 
> '/home/penny/FVP/r82/fvp_aemv8r_cortexr82_0.0_6347_gcc6.4/xen/xen'
> aarch64-linux-gnu-gcc -MMD -MP -MF ./.asm-offsets.s.d -DBUILD_ID 
> -fno-strict-aliasing -std=gnu99 -Wall
> -Wstrict-prototypes -Wdeclaration-after-statement 
> -Wno-unused-but-set-variable -Wno-unused-local-typedefs
> -O1 -fno-omit-frame-pointer -nostdinc -fno-builtin -fno-common -Werror 
> -Wredundant-decls -Wno-pointer-arith -Wvla
> -pipe -D__XEN__ -include 
> /home/penny/FVP/r82/fvp_aemv8r_cortexr82_0.0_6347_gcc6.4/xen/xen/include/xen/config.h
> -g -march=armv8-r -mgeneral-regs-only -mno-outline-atomics 
> -I/home/penny/FVP/r82/fvp_aemv8r_cortexr82_0.0_6347_gcc6.4
> /xen/xen/include -fno-stack-protector -fno-exceptions 
> -fno-asynchronous-unwind-tables -fcf-protection=none
> -Wnested-externs '-D__OBJECT_FILE__="asm-offsets.s"' -S -g0 -o 
> asm-offsets.s.new -MQ asm-offsets.s arch/arm/arm64/asm-offsets.c
> cc1: error: unknown value 'armv8-r' for '-march'
> cc1: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a 
> armv8.4-a armv8.5-a; did you mean 'armv8-a'?
> make[3]: *** [Makefile:413: asm-offsets.s] Error 1
> ```
> And the reason is that in the implementation of "cc-option": To handle this 
> we do a test compile, passing the option-under-test,
> on a code fragment that will always produce a warning (integer assigned to 
> pointer). We then grep for the option-under-test in
> the compiler's output, the presence of which would indicate an "unrecognized 
> command-line option" warning/error.
> ```
> cc-option = $(shell if test -z "`echo 'void*p=1;' | \
>                      $(1) $(2) -S -o /dev/null -x c - 2>&1 | grep -- $(2) 
> -`"; \
>                      then echo "$(2)"; else echo "$(3)"; fi ;)
> ```
> Here, that is, we are trying to grep "-march=armv8-r" in output message of 
> the test compile, and since the output
> message(unknown value 'armv8-r' for '-march') doesn't contain the COMPLETE 
> string, it thought the compiler supported this
> option, but it actually not...
> 
> Tracing back to the commit about the implementation of "cc-option", it 
> discards the linux method(using exit code to tell) for dealing with
> disable-warning options.
> See 
> https://github.com/xen-project/xen/commit/28f8fb7d2b3fde2f5cbe5526ac4f1c932e3f5d26
>  for more details.
> 
> To fix this issue, I could loose the "grep check", instead trying to grep the 
> COMPLETE option string("-march=armv8-r"), only partial(armv8-r) is
> enough. But, hmmm, the way of greping output message to check is kinds of 
> reliable, IMO, since there is no standard for that.

Since we need to be careful about not relaxing this too much, my
immediate suggestion here would be to split option strings at =
signs, and then use grep to check that every resulting piece is
present in the error message coming from the compiler. Afaict
this should cover your case and might also make a few others
less fragile. Unfortunately I expect this will make for quite a
bit more complicated a make macro. I wonder whether Linux hasn't
run into the same problem at some point, and has found some more
elegant and/or robust solution.

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.