Re: Issue with undefined reference with assembler in rr

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

 



On Wed, Jan 13, 2016 at 10:00:08PM -0700, Dave Johansen wrote:
> I was working on packaging rr [1] and one of the tests [2] fails to build
> when optimizations are turned on. I've reduced it to the following and
> still been able to reproduce the issue:
> 
> static const float xmm0 = 10;
> 
> int main() {
>   __asm__ __volatile__(
> #if __i386__
>       "movss xmm0, %xmm0\n\t"
> #elif __x86_64__
>       "movss xmm0(%rip), %xmm0\n\t"
> #else
> #error unexpected architecture
> #endif
>       );
> 
>   return 0;
> }
> 
> Here's the output on F23 x86_64:
> $ gcc fxregs.c -O0
> $ gcc fxregs.c -O1
> /tmp/cccdze3O.o: In function `main':
> fxregs.c:(.text+0x4): undefined reference to `xmm0'
> collect2: error: ld returned 1 exit status
> 
> Is this a gcc bug or is there something that I need to do in the build to
> get the tests to build without error?

I think it's a bug in your test.  GCC is just optimizing away the xmm0
variable because it cannot see "inside" the asm to know that it is
being used.

This works for me.  I believe you don't need the #if conditional
either since this should work on any x86 machine:

  __asm__ __volatile__ ("movss %0, %%xmm0\n\t" : : "m" (xmm0) : "%xmm0");

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
--
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
http://lists.fedoraproject.org/admin/lists/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux