public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32
@ 2013-11-06 10:26 hjl.tools at gmail dot com
  2013-11-06 10:27 ` [Bug sanitizer/59018] " hjl.tools at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-06 10:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

            Bug ID: 59018
           Summary: [4.9 Regression] libsanitizer doesn't build for x32
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org

r204368 breaks x32.  There are 4 problems:

1. internal_syscall casts pointers to uint64.  It doesn't work for
x32 since 32-bit pointers are signed extended to int64. They should
be casted to uptr first.  A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00403.html

2. internal_clone needs to allocate 2 int64 to restore 2 pointers
by pop which only pops 64-bit integer into 64-bit register. Also
"movq   %6,%%r8\n" can't be used to load 32-bit pointer into 64-bit
r8.  We should let compiler handle it.  A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00405.html

3. x32 uses the same file system calls as x86-64. The types
used in those system calls must be the same for x32 and x86-64.
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00407.html

4. X32 uses the same FPU state as x86-64.  We should check
__x86_64 instead of __WORDSIZE == 64.  A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00408.html

All patches are tested on x32, x86-64 and x86.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
@ 2013-11-06 10:27 ` hjl.tools at gmail dot com
  2013-11-06 17:48 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-06 10:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-06
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
  2013-11-06 10:27 ` [Bug sanitizer/59018] " hjl.tools at gmail dot com
@ 2013-11-06 17:48 ` jakub at gcc dot gnu.org
  2013-11-06 17:58 ` kcc at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-11-06 17:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Kostya Serebryany from comment #1)
> At least one of these patches does not build with clang:
> 
> /home/kcc/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:
> 807:21: error: ignored asm label 'r8' on automatic variable [-Werror]
>   void *r8 __asm__ ("r8") = newtls;
>                     ^
> /home/kcc/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:
> 808:21: error: ignored asm label 'r10' on automatic variable [-Werror]
>   int *r10 __asm__ ("r10") = child_tidptr;
>                     ^
> 
> is this some kind of gcc-specific syntax? 

There is missing register keyword of course for both.
So
  register void *r8 __asm__ ("r8") = newtls;
  register int *r10 __asm__ ("r10") = child_tidptr;


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
  2013-11-06 10:27 ` [Bug sanitizer/59018] " hjl.tools at gmail dot com
  2013-11-06 17:48 ` jakub at gcc dot gnu.org
@ 2013-11-06 17:58 ` kcc at gcc dot gnu.org
  2013-11-06 18:01 ` kcc at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kcc at gcc dot gnu.org @ 2013-11-06 17:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #4 from Kostya Serebryany <kcc at gcc dot gnu.org> ---
the patches look good and pass our testing on x86_64 and i386. 
Thanks! 
committed as http://llvm.org/viewvc/llvm-project?view=revision&revision=194155
(fixed 4 small lint warnings there)

We have few options: 
1. I do another full merge, but most likely next week
2. You submit these patches directly to gcc now (this may cause a very minor
headache at the next merge)


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2013-11-06 17:58 ` kcc at gcc dot gnu.org
@ 2013-11-06 18:01 ` kcc at gcc dot gnu.org
  2013-11-06 18:04 ` hjl.tools at gmail dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kcc at gcc dot gnu.org @ 2013-11-06 18:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #5 from Kostya Serebryany <kcc at gcc dot gnu.org> ---

> Can you try
> 
>   register void *r8 __asm__ ("r8") = newtls;
>   register int *r10 __asm__ ("r10") = child_tidptr;
Yep, works! 

> But you need to enable x32 first on your OS, which requires
> 
> 1. x32 enabled kernel, Linux kernel >= 3.4.0.
> 2. x32 glibc.

This does not match my system. :( 
Do you have a VM image (e.g. for VMWare player) with such a system? 

> 
> > 
> > 2. Is there any chance to test x32 off the clang tree, so that we keep the
> > upstream tree x32-clean all the time?
> 
> There was x32 port of llvm/clang last year.  But only parts
> of the x32 patches have been merged with llvm.

Do you need help with this? 
I'll be on the LLVM dev meeting today and tomorrow, may at least ask around.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2013-11-06 18:01 ` kcc at gcc dot gnu.org
@ 2013-11-06 18:04 ` hjl.tools at gmail dot com
  2013-11-06 18:07 ` hjl.tools at gmail dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-06 18:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Kostya Serebryany from comment #4)
> the patches look good and pass our testing on x86_64 and i386. 
> Thanks! 
> committed as
> http://llvm.org/viewvc/llvm-project?view=revision&revision=194155
> (fixed 4 small lint warnings there)
> 
> We have few options: 
> 1. I do another full merge, but most likely next week
> 2. You submit these patches directly to gcc now (this may cause a very minor
> headache at the next merge)

My current build has been failing. I'd like to get it fixed as soon
as possible. I will submit my patches to GCC now.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (4 preceding siblings ...)
  2013-11-06 18:04 ` hjl.tools at gmail dot com
@ 2013-11-06 18:07 ` hjl.tools at gmail dot com
  2013-11-06 18:15 ` kcc at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-06 18:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Kostya Serebryany from comment #5)
> > Can you try
> > 
> >   register void *r8 __asm__ ("r8") = newtls;
> >   register int *r10 __asm__ ("r10") = child_tidptr;
> Yep, works! 
> 
> > But you need to enable x32 first on your OS, which requires
> > 
> > 1. x32 enabled kernel, Linux kernel >= 3.4.0.
> > 2. x32 glibc.
> 
> This does not match my system. :( 
> Do you have a VM image (e.g. for VMWare player) with such a system? 

I can create an x32 VirtualBox image.  Do you have
a place I can upload it for you?

> > 
> > > 
> > > 2. Is there any chance to test x32 off the clang tree, so that we keep the
> > > upstream tree x32-clean all the time?
> > 
> > There was x32 port of llvm/clang last year.  But only parts
> > of the x32 patches have been merged with llvm.
> 
> Do you need help with this?

Yes, please.  I'd like to work with something to get
x32 support into llvm/clang.


> I'll be on the LLVM dev meeting today and tomorrow, may at least ask around.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (5 preceding siblings ...)
  2013-11-06 18:07 ` hjl.tools at gmail dot com
@ 2013-11-06 18:15 ` kcc at gcc dot gnu.org
  2013-11-06 21:51 ` hjl at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kcc at gcc dot gnu.org @ 2013-11-06 18:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #8 from Kostya Serebryany <kcc at gcc dot gnu.org> ---
>> I will submit my patches to GCC now.
Ok!


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (6 preceding siblings ...)
  2013-11-06 18:15 ` kcc at gcc dot gnu.org
@ 2013-11-06 21:51 ` hjl at gcc dot gnu.org
  2013-11-06 21:52 ` hjl at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl at gcc dot gnu.org @ 2013-11-06 21:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #9 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Wed Nov  6 21:49:36 2013
New Revision: 204480

URL: http://gcc.gnu.org/viewcvs?rev=204480&root=gcc&view=rev
Log:
Cast pointers to uptr for 64-bit syscalls

    PR sanitizer/59018
    * sanitizer_common/sanitizer_linux.cc (internal_mmap,
    internal_munmap, internal_open, internal_read, internal_write,
    internal_stat, internal_lstat, internal_fstat, internal_readlink,
    internal_unlink, internal_execve, NanoTime, BlockingMutex::Lock,
    BlockingMutex::Unlock, internal_ptrace, internal_getdents,
    internal_sigaltstack): Cast pointers to uptr for 64-bit syscalls.

Modified:
    trunk/libsanitizer/ChangeLog
    trunk/libsanitizer/sanitizer_common/sanitizer_linux.cc


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (7 preceding siblings ...)
  2013-11-06 21:51 ` hjl at gcc dot gnu.org
@ 2013-11-06 21:52 ` hjl at gcc dot gnu.org
  2013-11-06 21:53 ` hjl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl at gcc dot gnu.org @ 2013-11-06 21:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #10 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Wed Nov  6 21:50:42 2013
New Revision: 204481

URL: http://gcc.gnu.org/viewcvs?rev=204481&root=gcc&view=rev
Log:
Fix internal_clone for x32

    PR sanitizer/59018
    * sanitizer_common/sanitizer_linux.cc (internal_clone): Allocate
    2 64-bit integers to save and restore fn and arg.  Properly load
    newtls/child_tidptr into r8/r10.

Modified:
    trunk/libsanitizer/ChangeLog
    trunk/libsanitizer/sanitizer_common/sanitizer_linux.cc


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (8 preceding siblings ...)
  2013-11-06 21:52 ` hjl at gcc dot gnu.org
@ 2013-11-06 21:53 ` hjl at gcc dot gnu.org
  2013-11-06 21:54 ` hjl at gcc dot gnu.org
  2013-11-06 23:54 ` hjl.tools at gmail dot com
  11 siblings, 0 replies; 13+ messages in thread
From: hjl at gcc dot gnu.org @ 2013-11-06 21:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #11 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Wed Nov  6 21:51:41 2013
New Revision: 204482

URL: http://gcc.gnu.org/viewcvs?rev=204482&root=gcc&view=rev
Log:
Use 64-bit system types for x86-64

    PR sanitizer/59018
    * sanitizer_common/sanitizer_platform_limits_linux.cc
    (struct_kernel_stat64_sz): Initialize to 0 if __x86_64__ is
    defined.
    * sanitizer_common/sanitizer_platform_limits_posix.h
    (__sanitizer_dirent): Use 64-bit d_ino/d_off if __x86_64__ is
    defined.
    (__sanitizer___kernel_uid_t): Typedef as unsigned if __x86_64__
    is defined.
    (__sanitizer___kernel_gid_t): Likewise.
    (__sanitizer___kernel_off_t): Typedef as long long if __x86_64__
    is defined.

Modified:
    trunk/libsanitizer/ChangeLog
    trunk/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
    trunk/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (9 preceding siblings ...)
  2013-11-06 21:53 ` hjl at gcc dot gnu.org
@ 2013-11-06 21:54 ` hjl at gcc dot gnu.org
  2013-11-06 23:54 ` hjl.tools at gmail dot com
  11 siblings, 0 replies; 13+ messages in thread
From: hjl at gcc dot gnu.org @ 2013-11-06 21:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

--- Comment #12 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Wed Nov  6 21:52:29 2013
New Revision: 204483

URL: http://gcc.gnu.org/viewcvs?rev=204483&root=gcc&view=rev
Log:
Check __x86_64__ for FPU state

    PR sanitizer/59018
    * sanitizer_common/sanitizer_platform_limits_posix.cc
    (struct_user_fpxregs_struct_sz): Initialize to 0 if __x86_64__ is
    defined.

Modified:
    trunk/libsanitizer/ChangeLog
    trunk/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug sanitizer/59018] [4.9 Regression] libsanitizer doesn't build for x32
  2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
                   ` (10 preceding siblings ...)
  2013-11-06 21:54 ` hjl at gcc dot gnu.org
@ 2013-11-06 23:54 ` hjl.tools at gmail dot com
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-06 23:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59018

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #13 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-11-06 23:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-06 10:26 [Bug sanitizer/59018] New: [4.9 Regression] libsanitizer doesn't build for x32 hjl.tools at gmail dot com
2013-11-06 10:27 ` [Bug sanitizer/59018] " hjl.tools at gmail dot com
2013-11-06 17:48 ` jakub at gcc dot gnu.org
2013-11-06 17:58 ` kcc at gcc dot gnu.org
2013-11-06 18:01 ` kcc at gcc dot gnu.org
2013-11-06 18:04 ` hjl.tools at gmail dot com
2013-11-06 18:07 ` hjl.tools at gmail dot com
2013-11-06 18:15 ` kcc at gcc dot gnu.org
2013-11-06 21:51 ` hjl at gcc dot gnu.org
2013-11-06 21:52 ` hjl at gcc dot gnu.org
2013-11-06 21:53 ` hjl at gcc dot gnu.org
2013-11-06 21:54 ` hjl at gcc dot gnu.org
2013-11-06 23:54 ` hjl.tools at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).