Bug 81497 - [7 Regression] error compiling arm_acle.h
Summary: [7 Regression] error compiling arm_acle.h
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.1.0
: P2 normal
Target Milestone: 8.2
Assignee: ktkachov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-20 18:04 UTC by Ivan Nazarenko
Modified: 2019-11-14 10:13 UTC (History)
0 users

See Also:
Host:
Target: arm
Build:
Known to work: 6.4.0, 8.1.1, 9.0
Known to fail: 7.1.0, 7.5.0, 8.1.0
Last reconfirmed: 2017-07-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Nazarenko 2017-07-20 18:04:57 UTC

    
Comment 1 Ivan Nazarenko 2017-07-20 18:25:21 UTC
The following code:

###############
#include <arm_acle.h>

int main() {return 0; }
###############

does not cross-compile to ARM architecture on 7.1.0 and emits the following errors:

$ ./arm-linux-g++ ~/teste.cpp   
In file included from /home/ivan/teste.cpp:1:0:
/home/ivan/buildroot-git2/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/7.1.0/include/arm_acle.h: In function ‘void __arm_ldc(unsigned int, unsigned int, const void*)’:
/home/ivan/buildroot-git2/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/7.1.0/include/arm_acle.h:48:49: error: invalid conversion from ‘const void*’ to ‘const int*’ [-fpermissive]
   return __builtin_arm_ldc (__coproc, __CRd, __p);
                                                 ^
<built-in>: note:   initializing argument 3 of ‘void __builtin_arm_ldc(unsigned int, unsigned int, const int*)’
/home/ivan/buildroot-git2/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/7.1.0/include/arm_acle.h: In function ‘void __arm_ldcl(unsigned int, unsigned int, const void*)’:
/home/ivan/buildroot-git2/buildroot/output/host/lib/gcc/arm-buildroot-linux-musleabihf/7.1.0/include/arm_acle.h:55:50: error: invalid conversion from ‘const void*’ to ‘const int*’ [-fpermissive]
   return __builtin_arm_ldcl (__coproc, __CRd, __p);


... and so on, similar errors, 8 in total.

Verifying the latest arm_acle.h from git suggest that this problem is still present.

as asked from the "reporting bug" procedure:

$ ./arm-linux-g++ -v
Using built-in specs.
COLLECT_GCC=/home/ivan/buildroot-git2/buildroot/output/host/bin/arm-linux-g++.br_real
COLLECT_LTO_WRAPPER=/home/ivan/buildroot-git2/buildroot/output/host/libexec/gcc/arm-buildroot-linux-musleabihf/7.1.0/lto-wrapper
Target: arm-buildroot-linux-musleabihf
Configured with: ./configure --prefix=/home/ivan/buildroot-git2/buildroot/output/host --sysconfdir=/home/ivan/buildroot-git2/buildroot/output/host/etc --enable-static --target=arm-buildroot-linux-musleabihf --with-sysroot=/home/ivan/buildroot-git2/buildroot/output/host/arm-buildroot-linux-musleabihf/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --with-gmp=/home/ivan/buildroot-git2/buildroot/output/host --with-mpc=/home/ivan/buildroot-git2/buildroot/output/host --with-mpfr=/home/ivan/buildroot-git2/buildroot/output/host --with-pkgversion='Buildroot 2017.08-git-01191-g9c542ba' --with-bugurl=http://bugs.buildroot.net/ --disable-libmpx --disable-libquadmath --disable-libsanitizer --enable-tls --enable-plugins --enable-lto --disable-libmudflap --enable-threads --without-isl --without-cloog --disable-decimal-float --with-abi=aapcs-linux --with-cpu=cortex-a53 --with-fpu=neon-vfpv4 --with-float=hard --with-mode=arm --enable-languages=c,c++,fortran --with-build-time-tools=/home/ivan/buildroot-git2/buildroot/output/host/arm-buildroot-linux-musleabihf/bin --enable-shared --enable-libgomp
Thread model: posix
gcc version 7.1.0 (Buildroot 2017.08-git-01191-g9c542ba)
Comment 2 ktkachov 2017-07-21 08:43:36 UTC
Confirmed. This happens only in g++.
The intrinsics that have void return type should not "return" their builtin, they should just call it.
Comment 3 ktkachov 2018-06-04 08:49:18 UTC
Testing a patch.
Comment 4 ktkachov 2018-06-05 09:50:48 UTC
Author: ktkachov
Date: Tue Jun  5 09:50:16 2018
New Revision: 261191

URL: https://gcc.gnu.org/viewcvs?rev=261191&root=gcc&view=rev
Log:
[arm] PR target/81497: Fix arm_acle.h for C++

When trying to compile something with arm_acle.h using G++ we get a number of nasty errors:
arm_acle.h:48:49: error: invalid conversion from ‘const void*’ to ‘const int*’ [-fpermissive]
    return __builtin_arm_ldc (__coproc, __CRd, __p);

This is because the intrinsics that are supposed to be void return the "result" of their builtin,
which is void. C lets that slide but C++ complains.

After fixing that we run into further errors:
arm_acle.h:48:46: error: invalid conversion from 'const void*' to 'const int*' [-fpermissive]
    return __builtin_arm_ldc (__coproc, __CRd, __p);
                                               ^~~
Because the pointer arguments in these intrinsics are void pointers but the builtin
expects int pointers. So this patch introduces new qualifiers for void pointers and their
const-qualified versions and uses that in the specification of these intrinsics.

This gives us the opportunity of creating an arm subdirectory in g++.dg and inaugurates it
with the first arm-specific C++ tests (in that directory).


	PR target/81497
	* config/arm/arm-builtins.c (arm_type_qualifiers): Add
	qualifier_void_pointer and qualifier_const_void_pointer.
	(arm_ldc_qualifiers, arm_stc_qualifiers): Use the above.
	(arm_init_builtins): Handle the above.
	* config/arm/arm_acle.h (__arm_cdp, __arm_ldc, __arm_ldcl, __arm_stc,
	__arm_stcl, __arm_mcr, __arm_cdp2, __arm_ldc2, __arm_ldcl2, __arm_stc2,
	__arm_stcl2,__arm_mcr2, __arm_mcrr, __arm_mcrr2): Remove return for
	void intrinsics.

	* g++.target/arm/arm.exp: New file.
	* g++.target/arm/pr81497.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.target/arm/
    trunk/gcc/testsuite/g++.target/arm/arm.exp
    trunk/gcc/testsuite/g++.target/arm/pr81497.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm-builtins.c
    trunk/gcc/config/arm/arm_acle.h
    trunk/gcc/testsuite/ChangeLog
Comment 5 ktkachov 2018-06-05 09:52:03 UTC
Fixed on trunk. Will backport to the branches after a few days.
Comment 6 ktkachov 2018-06-08 08:19:15 UTC
Author: ktkachov
Date: Fri Jun  8 08:18:43 2018
New Revision: 261305

URL: https://gcc.gnu.org/viewcvs?rev=261305&root=gcc&view=rev
Log:
[arm] PR target/81497: Fix arm_acle.h for C++

	Backport from mainline
	2018-06-05  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

	PR target/81497
	* config/arm/arm-builtins.c (arm_type_qualifiers): Add
	qualifier_void_pointer and qualifier_const_void_pointer.
	(arm_ldc_qualifiers, arm_stc_qualifiers): Use the above.
	(arm_init_builtins): Handle the above.
	* config/arm/arm_acle.h (__arm_cdp, __arm_ldc, __arm_ldcl, __arm_stc,
	__arm_stcl, __arm_mcr, __arm_cdp2, __arm_ldc2, __arm_ldcl2, __arm_stc2,
	__arm_stcl2,__arm_mcr2, __arm_mcrr, __arm_mcrr2): Remove return for
	void intrinsics.

	* g++.target/arm/arm.exp: New file.
	* g++.target/arm/pr81497.C: Likewise.

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.target/arm/
    branches/gcc-8-branch/gcc/testsuite/g++.target/arm/arm.exp
    branches/gcc-8-branch/gcc/testsuite/g++.target/arm/pr81497.C
Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/config/arm/arm-builtins.c
    branches/gcc-8-branch/gcc/config/arm/arm_acle.h
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 7 Richard Biener 2019-11-14 10:13:37 UTC
Fixed in GCC 8.2.