diff mbox

PATCH: Fix libsanitizer for x32

Message ID CAMe9rOqLEyOTAqrKom5fqPQsmjgBTH-FWX5aG6oSJCqUji2aHA@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu Dec. 5, 2013, 2:37 p.m. UTC
On Thu, Dec 5, 2013 at 4:59 AM, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> On Thu, Dec 5, 2013 at 4:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> There are at least 2 fallouts:
>>
>> 1. -mx32 is broken.
>
> Please send a patch to the llvm-commits list
>

I am enclosing 2 patches here.  You can test x32 on Ubuntu
13.04 or newer.

struct stat defined in <asm/stat.h> is incorrect for x32.  <asm/stat.h>
is included to get struct __old_kernel_stat.  But struct __old_kernel_stat
isn't used for x86-64 and x32.  The first patch includes <sys/stat.h> instead
of <asm/stat.h> and comments out size check of struct __old_kernel_stat
for x86-64.

Some fields in shmid_ds as well as clock_t are int64 for x32.  The second
patch corrects them for x32.

Thanks.

Comments

Konstantin Serebryany Dec. 6, 2013, 11:31 a.m. UTC | #1
Ok to commit, assuming other targets will not break.
But I will not be able to do another merge until the two versions
(upstream and GCC) are equivalent again.
So, please don't close
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59402 until it's done.

--kcc

On Thu, Dec 5, 2013 at 6:37 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Dec 5, 2013 at 4:59 AM, Konstantin Serebryany
> <konstantin.s.serebryany@gmail.com> wrote:
>> On Thu, Dec 5, 2013 at 4:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>
>>> There are at least 2 fallouts:
>>>
>>> 1. -mx32 is broken.
>>
>> Please send a patch to the llvm-commits list
>>
>
> I am enclosing 2 patches here.  You can test x32 on Ubuntu
> 13.04 or newer.
>
> struct stat defined in <asm/stat.h> is incorrect for x32.  <asm/stat.h>
> is included to get struct __old_kernel_stat.  But struct __old_kernel_stat
> isn't used for x86-64 and x32.  The first patch includes <sys/stat.h> instead
> of <asm/stat.h> and comments out size check of struct __old_kernel_stat
> for x86-64.
>
> Some fields in shmid_ds as well as clock_t are int64 for x32.  The second
> patch corrects them for x32.
>
> Thanks.
>
> --
> H.J.
H.J. Lu Dec. 6, 2013, 11:49 a.m. UTC | #2
On Fri, Dec 6, 2013 at 3:31 AM, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> Ok to commit, assuming other targets will not break.
> But I will not be able to do another merge until the two versions
> (upstream and GCC) are equivalent again.
> So, please don't close
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59402 until it's done.

I checked them in and leave the bug report open.

Thanks.

H.J.
> --kcc
>
> On Thu, Dec 5, 2013 at 6:37 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Thu, Dec 5, 2013 at 4:59 AM, Konstantin Serebryany
>> <konstantin.s.serebryany@gmail.com> wrote:
>>> On Thu, Dec 5, 2013 at 4:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>
>>>> There are at least 2 fallouts:
>>>>
>>>> 1. -mx32 is broken.
>>>
>>> Please send a patch to the llvm-commits list
>>>
>>
>> I am enclosing 2 patches here.  You can test x32 on Ubuntu
>> 13.04 or newer.
>>
>> struct stat defined in <asm/stat.h> is incorrect for x32.  <asm/stat.h>
>> is included to get struct __old_kernel_stat.  But struct __old_kernel_stat
>> isn't used for x86-64 and x32.  The first patch includes <sys/stat.h> instead
>> of <asm/stat.h> and comments out size check of struct __old_kernel_stat
>> for x86-64.
>>
>> Some fields in shmid_ds as well as clock_t are int64 for x32.  The second
>> patch corrects them for x32.
>>
>> Thanks.
>>
>> --
>> H.J.
diff mbox

Patch

diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
index 01de9c9..bc37df0 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
@@ -27,6 +27,9 @@ 
 // are not defined anywhere in userspace headers. Fake them. This seems to work
 // fine with newer headers, too.
 #include <asm/posix_types.h>
+#if defined(__x86_64__)
+#include <sys/stat.h>
+#else
 #define ino_t __kernel_ino_t
 #define mode_t __kernel_mode_t
 #define nlink_t __kernel_nlink_t
@@ -41,6 +44,7 @@ 
 #undef uid_t
 #undef gid_t
 #undef off_t
+#endif
 
 #include <linux/aio_abi.h>
 
@@ -58,7 +62,7 @@  namespace __sanitizer {
   unsigned struct_statfs64_sz = sizeof(struct statfs64);
 }  // namespace __sanitizer
 
-#if !defined(__powerpc64__)
+#if !defined(__powerpc64__) && !defined(__x86_64__)
 COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
 #endif