Opened 5 months ago

Closed 5 months ago

#8562 closed bug (fixed)

Builtin function __builtin___clear_cache is unavailable on GCC 4.2

Reported by: heatsink Owned by:
Priority: normal Milestone:
Component: Runtime System Version: 7.7
Keywords: Cc: simonmar, nkpart@…
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: GHC doesn't work at all Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets: #8561

Description

A recent update to the RTS uses the GCC builtin function __builtin___clear_cache. This function was introduced in GCC 4.3. In older GCCs that don't have this builtin function, it's treated as an undefined function, leading to a link-time error. My system has GCC 4.2.1, bundled with XCode 3.2.6.

The function is called from rts/sm/Storage.c.

It seems that x86 architectures don't need a cache flush, so a possible fix is to do nothing on GCC < 4.3.6 on x86 architectures.

Attachments (1)

0001-Use-new-flushExec-implementation-on-all-operating-sy.patch (3.4 KB) - added by heatsink 5 months ago.
Patch applying the linux fix to other OSes

Download all attachments as: .zip

Change History (9)

comment:1 follow-up: Changed 5 months ago by Joachim Breitner <mail@…>

comment:2 in reply to: ↑ 1 Changed 5 months ago by nomeata

Replying to Joachim Breitner <mail@…>:

In 66de8c1e8f1a101bbfe551c46edca49473f6acd0/testsuite:

Mark #8562 as fixed

Sorry, that’s a typo. I did not do anything about #8562.

comment:3 Changed 5 months ago by nkpart

  • Cc nkpart@… added

comment:4 Changed 5 months ago by Austin Seipp <austin@…>

In 9fbb8c788d4bdf091709778b42a1294bbdabef95/ghc:

Rejigger flushExec implementation (#8562, #8561)

Instead, just don't do anything on x86/amd64, and on !x86, use either A)
__clear_cache from libgcc, or B) sys_icache_invalidate for OS X (and
iOS.)

Signed-off-by: Austin Seipp <austin@well-typed.com>

comment:5 Changed 5 months ago by thoughtpolice

  • Resolution set to fixed
  • Status changed from new to closed

This should now be fixed, thanks!

comment:6 Changed 5 months ago by heatsink

  • Owner simonmar deleted
  • Resolution fixed deleted
  • Status changed from closed to new

The fix only applies to linux (it's guarded by an #if defined(linux_HOST_OS)). On darwin, it still doesn't work. I'm attaching a patch to apply the fix to all OSes. It works for me, but I can't run the validation script because of #8266.

Changed 5 months ago by heatsink

Patch applying the linux fix to other OSes

comment:7 Changed 5 months ago by Austin Seipp <austin@…>

In 95854ca5276e3f4063ade7fe3a934bed46648270/ghc:

Use new flushExec implementation on all operating systems (#8562)

An earlier patch fixes a bug in flushExec on linux only.  This
patch uses the fixed code on all operating systems.

Signed-off-by: Austin Seipp <austin@well-typed.com>

comment:8 Changed 5 months ago by thoughtpolice

  • Resolution set to fixed
  • Status changed from new to closed

Merged, thanks!

Note: See TracTickets for help on using tickets.