Project

General

Profile

Actions

Bug #12657

closed

[PATCH] ANSI aliasing fix for XL compiler

Added by Zarko (Zarko Todorovski) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:76747]

Description

This is related to Bug #12191.

Changing in internal.h:983-985

from :

-#define RBASIC_CLEAR_CLASS(obj)        (((struct RBasicRaw *)((VALUE)(obj)))->klass = 0)
-#define RBASIC_SET_CLASS_RAW(obj, cls) (((struct RBasicRaw *)((VALUE)(obj)))->klass = (cls))

to:

#ifdef __ibmxl__
    #define RBASIC_SET_CLASS_RAW(obj, cls) memcpy(&((struct RBasicRaw *)((VALUE)(obj)))->klass, &(cls), sizeof(VALUE))
#else
    #define RBASIC_SET_CLASS_RAW(obj, cls) (((struct RBasicRaw *)((VALUE)(obj)))->klass = (cls))
#endif

#ifdef __ibmxl__
    #define RBASIC_CLEAR_CLASS(obj)        memset(&(((struct RBasicRaw *)((VALUE)(obj)))->klass), 0, sizeof(((struct RBasicRaw *)((VALUE)(obj)))->klass))
#else
    #define RBASIC_CLEAR_CLASS(obj)        (((struct RBasicRaw *)((VALUE)(obj)))->klass = 0)
#endif

This allows for ruby to build using XL compiler. Otherwise build fails because of ANSI aliasing issues.


Files

RBASIC_aliasing.patch (1.04 KB) RBASIC_aliasing.patch Zarko (Zarko Todorovski), 08/05/2016 04:41 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #12191: Violation of ANSI aliasing rules causing problems while compilingClosedActions

Updated by shyouhei (Shyouhei Urabe) over 7 years ago

  • Description updated (diff)

Thank you. I think we don't need the #else part because the memset/memcpy should just work for all ANSI-compliant compilers. Is it OK for me to merge your patch like that way?

Updated by Zarko (Zarko Todorovski) over 7 years ago

Shyouhei Urabe wrote:

Thank you. I think we don't need the #else part because the memset/memcpy should just work for all ANSI-compliant compilers. Is it OK for me to merge your patch like that way?

Yes, that should work.

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Description updated (diff)
  • Status changed from Open to Feedback

Does this patch really compile?
cls in RBASIC_CLEAR_CLASS sometimes isn't an l-value, and should not be able to be the operand of unary '&'.

Updated by shyouhei (Shyouhei Urabe) over 7 years ago

Nobuyoshi Nakada wrote:

Does this patch really compile?

Yes, at least to me.

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

RBASIC_CLEAR_CLASS doesn't use RBASIC_CLEAR_CLASS_RAW, and the former only is used with r-values.
Sorry for the noise.

Actions #6

Updated by shyouhei (Shyouhei Urabe) over 7 years ago

  • Status changed from Feedback to Closed

Applied in changeset r55831.


Actions #7

Updated by vo.x (Vit Ondruch) over 7 years ago

  • Related to Bug #12191: Violation of ANSI aliasing rules causing problems while compiling added

Updated by vo.x (Vit Ondruch) over 7 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED

I checked that the patches fix the warnings in Ruby 2.2. BTW r55833 is required alongside of r55831

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0