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

Bug#946678: [cpp-9] Cannot compile inline asm statement with -m32



Package: cpp-9
Version: 9.2.1-21
Severity: normal

Hi,

current gcc 9.2 cannot compile this program with -m32:

int main() {
    asm volatile ("mov %%eax, %%eax\n" : : "i" ("A string"));
    return 0;
}

Result is:

$ gcc -m32 test.c
test.c: In function ‘main’:
test.c:3:5: warning: asm operand 0 probably doesn’t match constraints
    3 |     asm volatile ("mov %%eax, %%eax\n" : : "i" ("A string"));
      |     ^~~
test.c:3:5: error: impossible constraint in ‘asm’

I believe that the program is valid, though. The same program compiles
on Compiler Explorer[1], it compiles with clang, and it compiles with a
vanilla gcc 9.2 compiled from upstream distributed sources. It also
compiles with Debian's gcc 9.2 without -m32.

 [1] https://godbolt.org/z/f87U62

I use an up-to-date Debian sid, with this gcc:

> $ gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
> OFFLOAD_TARGET_NAMES=nvptx-none:hsa
> OFFLOAD_TARGET_DEFAULT=1
> Target: x86_64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Debian 9.2.1-21' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
> Thread model: posix
> gcc version 9.2.1 20191130 (Debian 9.2.1-21) 

The vanilla gcc 9.2 that manages to compile is:

> $ /tmp/gcc/bin/gcc -v
> Using built-in specs.
> COLLECT_GCC=/tmp/gcc/bin/gcc
> COLLECT_LTO_WRAPPER=/tmp/gcc/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
> Target: x86_64-pc-linux-gnu
> Configured with: ./configure --enable-languages=c --prefix=/tmp/gcc
> Thread model: posix
> gcc version 9.2.0 (GCC) 

Although apparently the same problem appears on Arch[2].

 [2]
https://lists.nongnu.org/archive/html/tinycc-devel/2019-12/msg00075.html

Thanks, Giovanni.


--- System information. ---
Architecture: Kernel:       Linux 5.2.0-3-amd64

Debian Release: bullseye/sid
  500 xenial          updates.signal.org   500 unstable-debug
debug.mirrors.debian.org   500 unstable        deb.debian.org   500
testing         deb.debian.org   500 stable          repo.skype.com
500 stable          dl.google.com     1 experimental    deb.debian.org
--- Package information. ---
Depends            (Version) | Installed
============================-+-==============
gcc-9-base      (= 9.2.1-21) | libc6              (>= 2.14) | libgmp10
     (>= 2:5.0.1~) | libisl22           (>= 0.15) | libmpc3
         | libmpfr6          (>= 3.1.3) | zlib1g          (>= 1:1.1.4) |

Package's Recommends field is empty.

Suggests           (Version) | Installed
============================-+-===========
gcc-9-locales         (>= 8) |
-- 
Giovanni Mascellani <g.mascellani@gmail.com>
Postdoc researcher - Université Libre de Bruxelles

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: