Skip to content

can not build with profiling due to CPP definition name clash with C standard library #3064

Closed
@kokobd

Description

@kokobd

Your environment

Which OS do you use?
Ubuntu
Which version of GHC do you use and how did you install it?
GHC 9.2.3, installed through ghcup
How is your project built (alternative: link to the project)?

cabal.project.local:

ignore-project: False
profiling: True
executable-profiling: True
flags: -dynamic

Steps to reproduce

Checkout master, run cabal build exe:haskell-language-server

Expected behaviour

It should compiles

Actual behaviour

<command-line>: error: expected identifier or ‘(’ before numeric constant
`gcc' failed in phase `C Compiler'. (Exit code: 1)

Reason

Dig into the actual gcc command issued by ghc --make, we see:

-Xpreprocessor -Drename

But in <stdio.h>, there already exists a function called rename: https://en.cppreference.com/w/c/io/rename

So this finally lead to this line in the preprocessed C file (because rename is replaced by 1)

extern int 1 (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));

Then of course C compilation fails

Solution

I recommend adding a prefix to all CPP definitions in haskell-language-server executable. For example change -Drename to -Dhls_rename.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions