Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghc-tags seems to choke on CPP ! negation #6

Open
juhp opened this issue May 18, 2022 · 3 comments
Open

ghc-tags seems to choke on CPP ! negation #6

juhp opened this issue May 18, 2022 · 3 comments

Comments

@juhp
Copy link

juhp commented May 18, 2022

I often use CPP like:

#if !MIN_VERSION_simple_cmd_args(0,1,4)
: 

in my code which seems to trip up ghc-tags (I am using 1.5).

I get an error like:

ghc-tags -e

Common.hs:6:0: error:
     error: missing binary operator before token "("
        6 | #if !MIN_VERSION_http_directory(0,1,6)
          | 
  |
6 | #if !MIN_VERSION_http_directory(0,1,6)
  | ^

Common.hs:12:0: error:
 
    error: missing bQiunearry
y. hosp:eMr2aa4it:no.r0h :sb :eerror:f8o
:re 0  :t  o error:ke 
ne r
 "r (o "r 
:U  R meL ir. srh sosir: n: g 9  m:1bi2is0 ns:|ai  rnerror:#ygi  
fob pi !en Mra Iar Nty_o  VroeE prRberSeroIfarOot:Nro _ermh  ittbstoespkfi_eondnrgi e r" be(tic"ont
kaoerr nyy   ( "o0 (p,"e1 
r, a6  t)2 o
4 r    |b   e # f i of r  8e !   M|t I o N#k _ie|Vfn E  
R!"SM(II" ON
 N_ _V |sE 
iR mS 1pI2lO  eN |__ cs  mi9dm #(p|0l i,e#f2_i ,cf!0m M)dMI
_INaN_ r_V gVE sER (RS0SI ,IO 1ON ,N_ 4_h )ht 
tt|tp  p_
 _d di ir re  ec  ct| to
 or ry2 y(4|(0  0,|
,11, ,6 9)# )
|
i
 f   8  !  |M| I N  ^_ 
V# E Ri Sf I |
O! NM
_IsNi_ mVC pEo|lRm
eSm_Io9cOn mN.|d_h(ss 0i:,m#2p1,l6i0e:f)_ 
c0Mm:I d N _error:_ aV|r
EgR s S^( I
0 O, N1_, h4et)rt
rQuery.hs:1:1: error:
    `gcc' failed in phase `C pre-processor'. (Exit code: 1)
po_ rd :i| rme ic^st
soirnyg( 0
b,i1n,aM9ra)yi
 no. ph es|r:a t1^o6
r: b0e:f 
oerror:re
 UtR oL k. eh ns : "e(3r"3r
:or 0: :   m error:is 
s i  n1 g6    b|i  n#eairrfry o MroI:pN e_mrViaEstRsoSirIn OgbN e_bfsioinrmaepr lyte o_okcpemendr (a"0t(,o"2r
, 0b )e 
f o  r e     t o1 k6 e  n|    "# (i|"f 
 
! M I  N  _ V| E
 R S13I63O  N||_ s #iim#fp li!efM_ IcMNmI_dNV__EaVRrESgRIsSO(IN0O_,Nh1_t,st7ip)m_
pdli er _e cc mtdo (r 0y ,( 20 ,, 01|), 
9
) 
     |   |  
^
 1 6   | 
  | #
if   ! M|I
N_3V3E R|SIC OoNm#_msoiinfm. ph!lsMe:I_Nc2_m5Vd:E_Ra0Sr:Ig Oserror:N(_0h
,t1t ,p 7_ )d 
ir  ee cr tr|oorr y:^( 
0m,i1s,s9i
)n
g M ba ii nn|a.rh ys^ :
op2e4r:aURL.hs:1:1: error:
    `gcc' failed in phase `C pre-processor'. (Exit code: 1)
t0o:r  error:be
fo r e   to keernr o"r(:" 
mi s s i ng   b i2n5a r|y  #oipfe r!aMtIoNr_ VbEeRfSoIrOeN _thotktepn_ d"i(r"e
ct o r y (0 , 1 ,264) 
|  # i f  ! M I N _ V E|R S
ION _ s i|m
pl2e5_ c|md _a#rgisf( 0!,M1I,N7_)V
ER S I O N_ h t t p _ d|i r
ect o r y|(
0,214, 6|)
  #  i|f  !^M
IN_VERSION_simple_cCommon.hs:1:1: error:
md    `gcc' failed in phase `C pre-processor'. (Exit code: 1)
_args(0,1,7)
   | ^
Main.hs:1:1: error:
    `gcc' failed in phase `C pre-processor'. (Exit code: 1)

which is quite "interesting". :)

If you want to reproduce this is with https://github.com/juhp/fedora-repoquery but I don't think that particularly matters.

@arybczak
Copy link
Owner

arybczak commented May 18, 2022

You need to add these defines to ghc-tags.yaml, like

cpp_options:
- -DMIN_VERSION_http_directory(x,y,z)=1

since ghc-tags doesn't know about these (perhaps it could get support for including a file generated by cabal that has these defines, PRs welcome).

The garbled output is an unfortunate consequence of multithreading + GHC calling gcc for preprocessing, I can't do much about this since I can't control gcc's output. If you want readable output in case of errors to figure out which defines you need to add to the configuration, temporarily pass -j1 to ghc-tags.

@juhp
Copy link
Author

juhp commented May 20, 2022

(perhaps it could get support for including a file generated by cabal that has these defines, PRs welcome).

Not really sure how to teach it to look for cabal_macros.h under dist, dist-newstyle, or .stack-work?

@arybczak
Copy link
Owner

Yeah, me neither to be fair 😞

jmtd added a commit to jmtd/hledger that referenced this issue Aug 31, 2023
Provide a ghc-tags.yaml file to make use of ghc-tags with Hledger easy.

ghc-tags is a standalone tool to replace the formerly-builtto -in
":ctags" feature (and I presume ":etags") in GHCi. These walked over
the source and produced a TAGS file (in vim-compatible ctags or
Emacs-compatible etags format) that allows the relevant editors to
quickly navigate around function definitions.

ghc-tags trips over some of the CPP used in Hledger. The solution
is to provide ghc-tags with explicit CPP defines via a YAML file.
However, if a YAML file is provided, one also must specify the source
paths, as the tool XORs config file | paths-on-command-line.

See <arybczak/ghc-tags#6> for more
information.

Signed-off-by: Jonathan Dowland <jon@dow.land>
jmtd added a commit to jmtd/hledger that referenced this issue Aug 31, 2023
Provide a ghc-tags.yaml file to make use of ghc-tags with Hledger easy.

ghc-tags is a standalone tool to replace the formerly-built-in
":ctags" feature (and I presume ":etags") in GHCi. These walked over
the source and produced a TAGS file (in vim-compatible ctags or
Emacs-compatible etags format) that allows the relevant editors to
quickly navigate around function definitions.

ghc-tags trips over some of the CPP used in Hledger. The solution
is to provide ghc-tags with explicit CPP defines via a YAML file.
However, if a YAML file is provided, one also must specify the source
paths, as the tool XORs config file | paths-on-command-line.

See <arybczak/ghc-tags#6> for more
information.

Signed-off-by: Jonathan Dowland <jon@dow.land>
simonmichael pushed a commit to simonmichael/hledger that referenced this issue Aug 31, 2023
Provide a ghc-tags.yaml file to make use of ghc-tags with Hledger easy.

ghc-tags is a standalone tool to replace the formerly-built-in
":ctags" feature (and I presume ":etags") in GHCi. These walked over
the source and produced a TAGS file (in vim-compatible ctags or
Emacs-compatible etags format) that allows the relevant editors to
quickly navigate around function definitions.

ghc-tags trips over some of the CPP used in Hledger. The solution
is to provide ghc-tags with explicit CPP defines via a YAML file.
However, if a YAML file is provided, one also must specify the source
paths, as the tool XORs config file | paths-on-command-line.

See <arybczak/ghc-tags#6> for more
information.

Signed-off-by: Jonathan Dowland <jon@dow.land>
jmtd added a commit to jmtd/hledger that referenced this issue Sep 12, 2023
Provide a ghc-tags.yaml file to make use of ghc-tags with Hledger easy.

ghc-tags is a standalone tool to replace the formerly-built-in
":ctags" feature (and I presume ":etags") in GHCi. These walked over
the source and produced a TAGS file (in vim-compatible ctags or
Emacs-compatible etags format) that allows the relevant editors to
quickly navigate around function definitions.

ghc-tags trips over some of the CPP used in Hledger. The solution
is to provide ghc-tags with explicit CPP defines via a YAML file.
However, if a YAML file is provided, one also must specify the source
paths, as the tool XORs config file | paths-on-command-line.

See <arybczak/ghc-tags#6> for more
information.

Signed-off-by: Jonathan Dowland <jon@dow.land>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants