[GHC] #9689: const_str support needed for hsc2hs in cross-compilation mode

GHC ghc-devs at haskell.org
Tue Oct 14 16:15:34 UTC 2014


#9689: const_str support needed for hsc2hs in cross-compilation mode
-------------------------------------+-------------------------------------
              Reporter:  aosivitz    |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.8.3
             Component:  hsc2hs      |         Keywords:  zlib ios cross-
            Resolution:              |  compilation
      Operating System:              |     Architecture:  arm
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:  Other       |       Blocked By:
             Test Case:              |  Related Tickets:
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by aosivitz):

 Digging a little deeper...

 The reason why const_str is not currently supported is that strings cannot
 be calculated for a cross-compiled target platform the same way numbers
 can.

 Booleans can be calculated by attempting to compile a specific program
 that uses the boolean value in a static array size. The compiler must
 calculate the array size to determine if it is non-negative. (A negative
 array size is a compiler error.)
 This trick can be extended to numbers repeatedly using them to form
 boolean expressions and performing a binary search.

 A const_str is something like #define VERSION "1.2.3"

 Since a string is just an array of chars, shouldn't we be able to
 calculate it at compile time as well?

 We can get the length of a string by testing for -Warray-bounds and
 -Werror. And then calculate the value of the array at each index.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9689#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list