Project

General

Profile

Bug #12657

[PATCH] ANSI aliasing fix for XL compiler

Added by Zarko (Zarko Todorovski) about 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
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

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

Updated by shyouhei (Shyouhei Urabe) about 4 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) about 4 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) about 4 years ago

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

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) about 4 years ago

Nobuyoshi Nakada wrote:

Does this patch really compile?

Yes, at least to me.

Updated by nobu (Nobuyoshi Nakada) about 4 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.

#6

Updated by shyouhei (Shyouhei Urabe) about 4 years ago

  • Status changed from Feedback to Closed

Applied in changeset r55831.


  • internal.h (RBASIC_CLEAR_CLASS): Reroute ANSI C's strict aliasing rule. [ruby-core:74427][Bug #12191][ruby-core:76747][Bug #12657]
#7

Updated by vo.x (Vit Ondruch) almost 4 years ago

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

Updated by vo.x (Vit Ondruch) almost 4 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

Also available in: Atom PDF