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

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

Closed
kokobd opened this issue Jul 28, 2022 · 0 comments · Fixed by #3065
Closed
Labels
type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@kokobd
Copy link
Collaborator

kokobd commented Jul 28, 2022

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.

@kokobd kokobd added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage and removed status: needs triage labels Jul 28, 2022
@mergify mergify bot closed this as completed in #3065 Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant