Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
1154 commits behind the upstream repository.
  • Arsen Arsenović's avatar
    25b0b404
    Split out the C-- preprocessor, and make it pass -g0 · 25b0b404
    Arsen Arsenović authored and Marge Bot's avatar Marge Bot committed
    Previously, C-- was processed with the C preprocessor program.  This
    means that it inherited flags passed via -optc.  A flag that is somewhat
    often passed through -optc is -g.  At certain -g levels (>=2), GCC
    starts emitting defines *after* preprocessing, for the purposes of
    debug info generation.  This is not useful for the C-- compiler, and, in
    fact, causes lexer errors.  We can suppress this effect (safely, if
    supported) via -g0.
    
    As a workaround, in older versions of GCC (<=10), GCC only emitted
    defines if a certain set of -g*3 flags was passed.  Newer versions check
    the debug level.  For the former, we filter out those -g*3 flags and,
    for the latter, we specify -g0 on top of that.
    
    As a compatible and effective solution, this change adds a C--
    preprocessor distinct from the C compiler and preprocessor, but that
    keeps its flags.  The command line produced for C-- preprocessing now
    looks like:
    
      $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP
    
    Closes: #24474
    25b0b404
    History
    Split out the C-- preprocessor, and make it pass -g0
    Arsen Arsenović authored and Marge Bot's avatar Marge Bot committed
    Previously, C-- was processed with the C preprocessor program.  This
    means that it inherited flags passed via -optc.  A flag that is somewhat
    often passed through -optc is -g.  At certain -g levels (>=2), GCC
    starts emitting defines *after* preprocessing, for the purposes of
    debug info generation.  This is not useful for the C-- compiler, and, in
    fact, causes lexer errors.  We can suppress this effect (safely, if
    supported) via -g0.
    
    As a workaround, in older versions of GCC (<=10), GCC only emitted
    defines if a certain set of -g*3 flags was passed.  Newer versions check
    the debug level.  For the former, we filter out those -g*3 flags and,
    for the latter, we specify -g0 on top of that.
    
    As a compatible and effective solution, this change adds a C--
    preprocessor distinct from the C compiler and preprocessor, but that
    keeps its flags.  The command line produced for C-- preprocessing now
    looks like:
    
      $pgmCmmP $optCs_without_g3 $g0_if_supported $optCmmP
    
    Closes: #24474
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ghc_toolchain.m4 8.97 KiB