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

Error during compilation #45

Open
buraksirma opened this issue Jan 12, 2023 · 7 comments · May be fixed by nvim-neorg/neorg#1587
Open

Error during compilation #45

buraksirma opened this issue Jan 12, 2023 · 7 comments · May be fixed by nvim-neorg/neorg#1587

Comments

@buraksirma
Copy link

buraksirma commented Jan 12, 2023

I've updated my plugins after a few months and tree sitter for norg doesn't get compiled.

Error stack tree:

nvim-treesitter[norg]: Error during compilation                                    
src/scanner.cc:176:6: warning: scoped enumerations are a C++11 extension [-Wc++11-e
xtensions]                                                                         
enum class TagType : char                                                          
     ^                                                                             
src/scanner.cc:194:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11
-extensions]                                                                       
    for (auto& elem : vec)                                                         
         ^                                                                         
src/scanner.cc:194:21: warning: range-based for loop is a C++11 extension [-Wc++11-
extensions]                                                                        
    for (auto& elem : vec)                                                         
                    ^                                                              
src/scanner.cc:213:16: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    m_Previous = 0,  // previous char                                              
               ^                                                                   
src/scanner.cc:214:15: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    m_Current = 0;   // current char                                               
              ^                                                                    
src/scanner.cc:216:26: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    TagType m_TagContext = TagType::NONE;                                          
                         ^                                                         
src/scanner.cc:217:23: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    size_t m_TagLevel = 0;                                                         
er is a C++11 extension [-Wc++11-extensions]                                       
    bool m_InLinkLocation = false;                                                 
                          ^                                                        
src/scanner.cc:223:27: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    TokenType m_LastToken = NONE;                                                  
                          ^                                                        
src/scanner.cc:226:26: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    size_t m_ParsedChars = 0;                                                      
                         ^                                                         
src/scanner.cc:228:50: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    const array<int32_t, 12> m_DetachedModifiers = {                               
                                                 ^                                 
src/scanner.cc:243:74: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    const unordered_map<int32_t, TokenType> m_DetachedModifierExtensions = {       
                                                                         ^         
src/scanner.cc:256:65: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    const unordered_map<int32_t, TokenType> m_AttachedModifiers = {                
                                                                ^                  
src/scanner.cc:811:6: error: expected expression                                   
    [[nodiscard]]                                                                  
     ^                                                                             
src/scanner.cc:812:5: error: expected member name or ';' after declaration specifie
rs                                                                                 
    bool check_detached(const vector<TokenType>& results, const int32_t expected)  
    ^                                                                              
src/scanner.cc:216:28: warning: use of enumeration in a nested name specifier is a 
C++11 extension [-Wc++11-extensions]                                               
    TagType m_TagContext = TagType::NONE;                                          
                           ^                                                       
src/scanner.cc:243:76: error: non-aggregate type 'const unordered_map<int32_t, Toke
nType>' (aka 'const unordered_map<int, TokenType>') cannot be initialized with an I

src/scanner.cc:217:23: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    size_t m_TagLevel = 0;                                                         
                      ^                                                            
src/scanner.cc:219:27: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    bool m_InLinkLocation = false;                                                 
                          ^                                                        
src/scanner.cc:223:27: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    TokenType m_LastToken = NONE;                                                  
                          ^                                                        
src/scanner.cc:226:26: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    size_t m_ParsedChars = 0;                                                      
                         ^                                                         
src/scanner.cc:228:50: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    const array<int32_t, 12> m_DetachedModifiers = {                               
                                                 ^                                 
src/scanner.cc:243:74: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    const unordered_map<int32_t, TokenType> m_DetachedModifierExtensions = {       
                                                                         ^         
src/scanner.cc:256:65: warning: default member initializer for non-static data memb
er is a C++11 extension [-Wc++11-extensions]                                       
    const unordered_map<int32_t, TokenType> m_AttachedModifiers = {                
                                                                ^                  
src/scanner.cc:811:6: error: expected expression                                   
    [[nodiscard]]                                                                  
     ^                                                                             
src/scanner.cc:812:5: error: expected member name or ';' after declaration specifie
rs                                                                                 
    bool check_detached(const vector<TokenType>& results, const int32_t expected)  
    ^                                                                              
src/scanner.cc:216:28: warning: use of enumeration in a nested name specifier is a 
C++11 extension [-Wc++11-extensions]                                               
    TagType m_TagContext = TagType::NONE;                                          
                           ^                                                       
src/scanner.cc:243:76: error: non-aggregate type 'const unordered_map<int32_t, Toke
nType>' (aka 'const unordered_map<int, TokenType>') cannot be initialized with an i
nitializer list                                                                    
    const unordered_map<int32_t, TokenType> m_DetachedModifierExtensions = {       
                                                                           ^       
src/scanner.cc:256:67: error: non-aggregate type 'const unordered_map<int32_t, Toke
nType>' (aka 'const unordered_map<int, TokenType>') cannot be initialized with an i
nitializer list                                                                    
    const unordered_map<int32_t, TokenType> m_AttachedModifiers = {                
                                                                  ^                
src/scanner.cc:272:13: error: use of undeclared identifier 'reset_active_modifiers'                                                                             
            reset_active_modifiers();                                              
            ^                                                                      
src/scanner.cc:279:20: error: use of undeclared identifier 'parse_text'            
            return parse_text();                                                   
                   ^                                                               
src/scanner.cc:281:18: error: use of undeclared identifier 'is_newline'            
        else if (is_newline(lexer->lookahead))                                     
                 ^ 
src/scanner.cc:289:17: error: use of undeclared identifier 'reset_active_modifiers'
                reset_active_modifiers();                                          
                ^                         

CC version:

Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.2.0
Thread model: posix

Default standart from man pages if it helps

The default C language standard is gnu17, except on PS4, where it is gnu99.
@buraksirma
Copy link
Author

I fixed the problem by changing the used gcc binary. macOs is getting shipped with apple version of clang and it's the problem. You can install gcc via brew. If you symlink it with gcc it will override apple one and TSUpdate will work but if you don't want to symlink it just install gcc and pass it nvim-treesitter with the config below.

require("nvim-treesitter.install").compilers = { "gcc-12" }

@monaqa
Copy link

monaqa commented Jan 18, 2023

I am facing the same problem.
I tried the same approach as above, but another error occurred:

nvim-treesitter[norg]: Error during compilation
0  0x102f641a0  __assert_rtn + 140
1  0x102deba8c  mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536
2  0x102dbdd38  mach_o::relocatable::Parser<arm64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 148
3  0x102e264ac  ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468
4  0x102e29360  ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56
5  0x18a312544  _dispatch_client_callout2 + 20
6  0x18a327654  _dispatch_apply_invoke_and_wait + 224
7  0x18a326938  _dispatch_apply_with_attr_f + 1152
8  0x18a326b48  dispatch_apply + 108
9  0x102e291f4  ld::tool::InputFiles::InputFiles(Options&) + 616
10  0x102dab6c0  main + 552
A linker snapshot was created at:
^I/tmp/parser.so-2023-01-18-223913.ld-snapshot
ld: Assertion failed: (_file->_atomsArrayCount == computedAtomCount && "more atoms allocated than expected"), function parse, file macho_relocatable_file.cpp, line 2061.
collect2: error: ld returned 1 exit status

I use Homebrew GCC 12.2.0 on M1 Mac.

$ gcc-12 --version
gcc-12 (Homebrew GCC 12.2.0) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@monaqa
Copy link

monaqa commented Jan 18, 2023

Sorry, I found the comment that solves the problem.

#7 (comment)

@pernambucano
Copy link

pernambucano commented Mar 19, 2023

The above comment will probably solve the issue, but another way to solve this is to remove the xcode from your mac, and install the latest version of clt directly using xcode-select --install, and use the gcc-12 when installing the parser like this CC=$(which gcc-12) nvim -c "TSUpdate norg"

@rodhash
Copy link

rodhash commented Nov 22, 2023

I fixed the problem by changing the used gcc binary. macOs is getting shipped with apple version of clang and it's the problem. You can install gcc via brew. If you symlink it with gcc it will override apple one and TSUpdate will work but if you don't want to symlink it just install gcc and pass it nvim-treesitter with the config below.

require("nvim-treesitter.install").compilers = { "gcc-12" }

same here, thanks

@mikesmithgh
Copy link

mikesmithgh commented Sep 11, 2024

I had this problem attempting to install norg directly via nvim-treesitter.

require('nvim-treesitter.configs').setup({
  ensure_installed = {
    'norg',
  },
})

However, I don't have any issues if I install via the command

:Neorg sync-parsers    

@pcekm
Copy link

pcekm commented Sep 29, 2024

I ran into this and spent some time digging into it. There's a few things going on here, but the fundamental issue is that Neorg is reaching into nvim-treesitter to a) change the version of tree-sitter-norg that it builds and b) install a kludge that changes the way it builds parsers.

I've created nvim-neorg/neorg#1587 which should fix this.

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

Successfully merging a pull request may close this issue.

6 participants