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

Cpp and markdown parsers not compile #5800

Open
FedericoBruzzone opened this issue Dec 17, 2023 · 8 comments
Open

Cpp and markdown parsers not compile #5800

FedericoBruzzone opened this issue Dec 17, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@FedericoBruzzone
Copy link

Describe the bug

I'm trying to install the cpp and markdown parser but I get this compilation error

image image

To Reproduce

I have automatic plugin installation, when I open a cpp or markdown file I get this error

Expected behavior

Installing the cpp/markdown parsers

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.20.8 (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v21.2.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `clang` executable found. Selected from { "clang" }
  Version: Apple clang version 15.0.0 (clang-1500.0.40.1)
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "23.1.0",
  sysname = "Darwin",
  version = "Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64"
} ~

Parser/Features         H L F I J
  - c                   ✓ ✓ ✓ ✓ ✓
  - gitcommit           ✓ . . . ✓
  - gitignore           ✓ . . . .
  - javascript          ✓ ✓ ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - ocaml               ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - scala               ✓ ✓ ✓ . ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

Output of nvim --version

NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1700008891

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.9.4/share/nvim"

Run :checkhealth for more info

Additional context

No response

@FedericoBruzzone FedericoBruzzone added the bug Something isn't working label Dec 17, 2023
@clason
Copy link
Contributor

clason commented Dec 17, 2023

Not enough context; please provide a minimal reproducing example (and check previous issues).

Needless to say, installing these parsers works fine on macOS with clang.

@lucario387
Copy link
Member

Properly this. tree-sitter/tree-sitter-cpp@2c93b82

Update your nvim-treesitter to latest version first

@FedericoBruzzone
Copy link
Author

Properly this. tree-sitter/tree-sitter-cpp@2c93b82

Update your nvim-treesitter to latest version first

I'm using the latest version of nvim-treesitter.
I just removed and reinstalled tree-sitter and I also have the same problem with the vim parser.

@theHamsta
Copy link
Member

Oh, no apple clang strikes again. The compiler seems to hint that it's missing symbols from the C standard librarry. Others that filed this issue for other projects on GitHub compiled for a target for which they to have missing the C library. Other parsers don't seem to have this problem probably because they don't use any symbols from the c standard library

Could you double check:

  • you have a Intel Mac (as indicated by the arch reported by neovim). You run a x86 binary of neovim.
  • your compiler by default targets x86_64 and not arm64 or arm64 for iOS

As a hacky work-around, could you try whether export CFLAGS=-DNDEBUG=1 helps? Static_asserts shouldn't cause any symbol dependencies as they are static assertions at compile time (there must be real assert in the code)

@FedericoBruzzone
Copy link
Author

FedericoBruzzone commented Dec 17, 2023

I hadn't read this message, but as you say the problem is that the symbols of the standard library are missing, in this case the use of assert causes this problem. _Static_assert is not a part of stdlib @lucario387

Compiling using clang, this code

// test.c

#include <assert.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
  assert(argc == 1);
  printf("Hello, world!\n");
  return 0;
}

produces

ld: Undefined symbols:
  ___assert_func, referenced from:
      _main in test-a125d7.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

But using clang++ compiles, with
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

@theHamsta thank you for your help.
So, answering your questions:

  1. I recently got this mac and was trying it out, and it's an intel. uname -m produces x86_64
  2. file $(which nvim) produces /usr/local/bin/nvim: Mach-O 64-bit executable x86_64

Until last week I was using a Unix machine, before retracing my steps I would like to try to give this Mac a little hope :'D

do you know how to fix this problem?

@clason
Copy link
Contributor

clason commented Dec 17, 2023

I recently got this mac and was trying it out, and it's an intel. uname -m produces x86_64

Are you sure? Apple stopped selling Intel Macs quite a while ago. It sounds rather that you're using an x86_64 terminal on an arm64 Mac. What's your terminal?

@FedericoBruzzone
Copy link
Author

I recently got this mac and was trying it out, and it's an intel. uname -m produces x86_64

Are you sure? Apple stopped selling Intel Macs quite a while ago. It sounds rather that you're using an x86_64 terminal on an arm64 Mac. What's your terminal?

It's not a new Mac, I borrowed this Mac from a friend of mine :D
Anyway, I'm using kitty

@clason
Copy link
Contributor

clason commented Dec 17, 2023

Then I'd recommend re-installing the XCode CLI tools for your OS, and make sure there are not outdated libraries/headers in your paths somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants