Skip to content
  • Sergei Trofimovich's avatar
    compiler/cmm/PprC.hs: constify labels in .rodata · b68697e5
    Sergei Trofimovich authored and Ben Gamari's avatar Ben Gamari committed
    
    
    Consider one-line module
        module B (v) where v = "hello"
    in -fvia-C mode it generates code like
        static char gibberish_str[] = "hello";
    
    It resides in data section (precious resource on ia64!).
    The patch switches genrator to emit:
        static const char gibberish_str[] = "hello";
    
    Other types if symbols that gained 'const' qualifier are:
    
    - info tables (from haskell and CMM)
    - static reference tables (from haskell and CMM)
    
    Cleanups along the way:
    
    - fixed info tables defined in .cmm to reside in .rodata
    - split out closure declaration into 'IC_' / 'EC_'
    - added label declaration (based on label type) right before
      each label definition (based on section type) so that C
      compiler could check if declaration and definition matches
      at definition site.
    
    Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
    
    Test Plan: ran testsuite on unregisterised x86_64 compiler
    
    Reviewers: simonmar, ezyang, austin, bgamari, erikd
    
    Reviewed By: bgamari, erikd
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #8996
    
    Differential Revision: https://phabricator.haskell.org/D3481
    b68697e5