[GHC] #8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Other Architecture: Unknown/Multiple | Type of failure: Building GHC Difficulty: Easy (less than 1 | failed hour) | Test Case: Blocked By: | Blocking: Related Tickets: | -------------------------------------+------------------------------------- The __builtin___clear_cache from GCC is just called __clear_cache with clang, and must be declared. Otherwise the build fails (introduced in https://github.com/ghc/ghc/commit/5bab1a57f572e29dfdffd6d1ce8e53a2772b18fd) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by lukexi): Actually, __clear_cache seems to be missing entirely on iOS, so I'm not sure what to do here. (I found a reference to someone reimplementing it in assembly? http://permalink.gmane.org/gmane.comp.lang.pcre.devel/1986) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by thoughtpolice): A few years ago I helped Mike Pall (of LuaJIT) dig into using the JIT component on iOS, which involved finding a way to clear the icache. I dug up the code. On Darwin, the trick seems to be `sys_icache_invalidate`: http://repo.or.cz/w/luajit-2.0.git/blob/HEAD:/src/lj_mcode.c#l31 I imagine this still works, but I can't test it (I no longer have a jailbroken iOS device where the JIT would work.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by lukexi): OK, thanks for that! I'm running a build now with {{{ #if defined(ios_HOST_OS) || defined (darwin_HOST_OS) void sys_icache_invalidate(void *start, size_t len); #endif /* Synchronize data/instruction cache. */ void clearCache(void *start, void *end) { #if defined(ios_HOST_OS) || defined (darwin_HOST_OS) sys_icache_invalidate(start, (char *)end-(char *)start); #elif defined(__GNUC__) __builtin___clear_cache(start, end); #else #error "Missing builtin to flush instruction cache" #endif }}} adapted from that to test -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by carter): heatsink is likely to follow up on this, but GCC 4.2 lacks the builtin clear cache primitive, and thus any OS X system with XCode < 5 has a GCC old enough that builtin___clear_cache shoudn't be used. (at least if we want to support working at all on older OS X systems, which i think is worth doing) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- Comment (by carter): that is, on x86 architectures we perhaps shouldn't be calling clear cache at all. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #8562 -------------------------------------+------------------------------------- Changes (by heatsink): * related: => #8562 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #8562 -------------------------------------+------------------------------------- Changes (by nkpart): * cc: nkpart@… (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #8562 -------------------------------------+------------------------------------- Comment (by lukexi): (just the above in patch form, it's been working quite happily in intense use on iOS) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #8562 -------------------------------------+------------------------------------- Comment (by amosrobinson): Thanks! I'm trying now on OSX10.8.5 & GCC 4.2.1. I got a warning (and error due to -Werror) that clearCache didn't have a prototype before it, so I made it static. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #8562 -------------------------------------+------------------------------------- Comment (by lukexi): Thanks! updated. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #8562 -------------------------------------+------------------------------------- Comment (by carter): i'm meh about that fixup patch, the real issue is we don't need to call any cache synchronization on x86/ x86_64 architectures. I'll integrate the above patch into my fixup. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use
__clear_cache instead
-------------------------------------+-------------------------------------
Reporter: lukexi | Owner:
Type: bug | Status: new
Priority: high | Milestone:
Component: Compiler | Version: 7.6.3
Resolution: | Keywords:
Operating System: Other | Architecture: Unknown/Multiple
Type of failure: Building GHC | Difficulty: Easy (less than 1
failed | hour)
Test Case: | Blocked By:
Blocking: | Related Tickets: #8562
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #8562 -------------------------------------+------------------------------------- Comment (by thoughtpolice): This should now be fixed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8561: Clang/iOS: __builtin___clear_cache doesn't exist in clang, use __clear_cache instead -------------------------------------+------------------------------------- Reporter: lukexi | Owner: Type: bug | Status: closed Priority: high | Milestone: Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Other | Architecture: Unknown/Multiple Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #8562 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8561#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC