Opened 10 years ago

Closed 10 years ago

#771 closed defect (fixed)

llvm-gcc hang on OS X 10.7

Reported by: Jim Ursetto Owned by: felix winkelmann
Priority: minor Milestone:
Component: compiler Version: 4.7.x
Keywords: Cc:
Estimated difficulty:

Description

ddp may have found the root cause of hanging of chicken binaries compiled with llvm-gcc: http://blog.phusion.nl/2011/12/30/xcode-4-ships-a-buggy-compiler/

The current workaround is to force gcc-4.2 during compilation. However, Xcode 4.2 (shipped in November) removes plain gcc-4.2. Since this breaks Ruby's garbage collector, I assume either Apple will provide a fix or Ruby will work around it (which fix we should adopt).

The usual solution for non-alloca platforms is to use a stub function to take the address of a local variable (requiring compiler support for noinline). If the workaround becomes necessary, I would want to target it as narrowly as possible, as it is ugly. The remaining question is how narrowly it can be targeted.

Attachments (2)

0001-Make-C_stack_pointer-work-with-LLVM-backend.patch (1.8 KB) - added by Jim Ursetto 10 years ago.
0002-Use-C_stack_pointer-instead-of-C_alloc-0-when-genera.patch (1.1 KB) - added by Jim Ursetto 10 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 10 years ago by Jim Ursetto

Ignore the stub function comment, it's not really right. So far I've attempted to simulate alloca(0) via retrieving the value of SP using inline assembly. This is basically what Ruby Enterprise Edition falls back to when alloca is not available or broken. However, llvm-gcc appears to treat SP and BP differently than plain gcc, so I'm not yet convinced this approach is sound.

comment:2 Changed 10 years ago by Jim Ursetto

Owner: set to Jim Ursetto
Status: newassigned

comment:3 Changed 10 years ago by Jim Ursetto

Attached two patches fix the hangs on LLVM with optimization enabled. This fix is also required on Linux (tested with Ubuntu 10.04 and their llvm-gcc-4.2 package (LLVM 2.7)); my assumption is that the build success on Linux reported by Felix was done with optimization disabled.

As an interesting data point, building Chicken after make spotless is much faster when using LLVM chicken: 123sec vs 161sec here. Considering that includes the runtime for both "chicken" and "gcc", the speedup for chicken must be significant.

comment:4 Changed 10 years ago by Jim Ursetto

Confirmed it works with clang (llvm 3.0) on OS X as well, although that wasn't really in doubt.

comment:5 Changed 10 years ago by Jim Ursetto

Owner: changed from Jim Ursetto to felix winkelmann

comment:6 Changed 10 years ago by felix winkelmann

Resolution: fixed
Status: assignedclosed

Thanks - patches are pushed. I actually forgot to sign off.

Note: See TracTickets for help on using tickets.