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

Mac OSX M1 build issue - not resolving #67

Open
bahman777 opened this issue May 17, 2024 · 8 comments
Open

Mac OSX M1 build issue - not resolving #67

bahman777 opened this issue May 17, 2024 · 8 comments

Comments

@bahman777
Copy link

Hi,
I continue to have an issue on Mac OSX 14 M1. Either the native compiler doesn't compile due to C++11 features or if I use the latest from brew, I get ld issues - error message listed below. Any help is appreciated.
Parser compilation failed.
Stdout:
Stderr: ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libSystem.tbd' for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
error Command failed with exit code 1.

@VanshajSaxena
Copy link

I'm also having issues compiling tree-sitter-norg on Apple M1 Sonoma 14.5.

[nvim-treesitter] [0/1] Downloading tree-sitter-norg...
[nvim-treesitter] [0/1] Creating temporary directory
[nvim-treesitter] [0/1] Extracting tree-sitter-norg...
[nvim-treesitter] [0/1] Compiling...
nvim-treesitter[norg]: Error during compilation
src/scanner.cc:176:6: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
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 member 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 member 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 member 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 member 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 member 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 member 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 member 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 member 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 member 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 member 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 specifiers
    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, TokenType>' (aka 'const unordered_map<int, TokenType>') cannot be initialized with an initializer list
    const unordered_map<int32_t, TokenType> m_DetachedModifierExtensions = {
                                                                           ^
src/scanner.cc:256:67: error: non-aggregate type 'const unordered_map<int32_t, TokenType>' (aka 'const unordered_map<int, TokenType>') cannot be initialized with an initializer 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();
                ^
src/scanner.cc:293:33: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
            if (m_TagContext != TagType::NONE && ((char)m_TagContext % 2) == 0)
                                ^
src/scanner.cc:299:17: error: use of undeclared identifier 'is_newline'
            if (is_newline(lexer->lookahead))
                ^
src/scanner.cc:303:17: error: use of undeclared identifier 'reset_active_modifiers'
                reset_active_modifiers();
                ^
src/scanner.cc:313:20: error: use of undeclared identifier 'is_blank'
            while (is_blank(lexer->lookahead))
                   ^
src/scanner.cc:329:28: error: use of undeclared identifier 'is_blank'
                    while (is_blank(lexer->lookahead))
                           ^
src/scanner.cc:333:44: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        && m_TagContext == TagType::IN_VERBATIM_TAG)
                                           ^
src/scanner.cc:336:40: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                        m_TagContext = TagType::NONE;
                                       ^
src/scanner.cc:345:75: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                if (m_LastToken == RANGED_VERBATIM_TAG || m_TagContext == TagType::IN_VERBATIM_TAG)
                                                                          ^
src/scanner.cc:353:32: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                m_TagContext = TagType::ON_VERBATIM_TAG;
                               ^
src/scanner.cc:357:33: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
            if (m_TagContext == TagType::IN_VERBATIM_TAG)
                                ^
src/scanner.cc:358:24: error: use of undeclared identifier 'parse_text'
                return parse_text();
                       ^
src/scanner.cc:361:60: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
            if (lexer->lookahead == '=' && m_TagContext != TagType::IN_VERBATIM_TAG)
                                                           ^
src/scanner.cc:374:32: error: use of undeclared identifier 'is_newline'
                           && !is_newline(lexer->lookahead))
                               ^
src/scanner.cc:397:29: error: use of undeclared identifier 'is_newline'
                        if (is_newline(lexer->lookahead))
                            ^
src/scanner.cc:432:32: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                m_TagContext = TagType::ON_TAG;
                               ^
src/scanner.cc:437:65: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
            else if (lexer->lookahead == '|' && m_TagContext != TagType::IN_VERBATIM_TAG)
                                                                ^
src/scanner.cc:449:28: error: use of undeclared identifier 'is_blank'
                    while (is_blank(lexer->lookahead))
                           ^
src/scanner.cc:473:32: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
                m_TagContext = TagType::ON_TAG;
                               ^
src/scanner.cc:478:65: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
            else if (lexer->lookahead == '#' && m_TagContext != TagType::IN_VERBATIM_TAG)
                                                                ^
src/scanner.cc:484:25: error: use of undeclared identifier 'is_newline'
                    if (is_newline(lexer->lookahead))
                        ^
src/scanner.cc:496:65: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
            else if (lexer->lookahead == '+' && m_TagContext != TagType::IN_VERBATIM_TAG)
                                                                ^
src/scanner.cc:506:65: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
            else if (lexer->lookahead == '.' && m_TagContext != TagType::IN_VERBATIM_TAG)
                                                                ^
src/scanner.cc:525:32: error: expected expression
            if (check_detached({HEADING1, HEADING2, HEADING3,
                               ^
src/scanner.cc:530:32: error: expected expression
            if (check_detached({QUOTE1, QUOTE2, QUOTE3, QUOTE4, QUOTE5, QUOTE6}, '>'))
                               ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
27 warnings and 20 errors generated.

Any help would be appriatiated.

@SuperCuber
Copy link

Same here, seems there was an attempt to fix it but it doesn't look like it worked
5e2495f

@SuperCuber
Copy link

SuperCuber commented Jul 13, 2024

Rest of the error for me:

Failed to execute the following command:
{
  cmd = "cc",
  err = "Error during compilation",
  info = "Compiling...",
  opts = {
    args = { "-o", "parser.so", "-I./src", "src/parser.c", "src/scanner.cc", "-0s", "-bundle", "-lstdc++", "-fPIC" },
    cwd = "/Users/myusername/.local/share/nvim/tree-sitter-norg"
  }
}

I also cloned the repo and ran yarn and yarn gen myself which worked, however yarn test which runs tree-sitter test failed with the stack of errors above, and before it:

Warning: Using a C++ scanner is now deprecated. Please migrate your scanner code to C, as C++ support will be removed in the near future.
Parser compilation failed.
Stdout:
Stderr: clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated

@VanshajSaxena
Copy link

Same here, seems there was an attempt to fix it but it doesn't look like it worked 5e2495f

  {

    "vhyrro/luarocks.nvim",
    priority = 1000,
    opts = {
      luarocks_build_args = {
        "--with-lua-include=/usr/include",
      },
    },
  },

this worked for me.

@SuperCuber
Copy link

@VanshajSaxena you got it working on mac m1 using that, and you had the errors above before that? Could you please reproduce with/without? I find it hard to believe that with-lua-include would a c compilation error🙃

@SuperCuber
Copy link

Got it working! After installing a recent c++ compiler with brew install gcc and selecting it like so:

$ gcc --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ CC=gcc nvim -c "TSInstall norg"

@andrewcrook
Copy link

Apple clang version 15.0.0 (clang-1500.3.9.4)

I thought Apple provides clang and gcc with Xcode?
You can install the command line tools with

xcode-select --install

iirc homebrew requires this anyway?

@SuperCuber
Copy link

Apple clang version 15.0.0 (clang-1500.3.9.4)

I thought Apple provides clang and gcc with Xcode? You can install the command line tools with

xcode-select --install

iirc homebrew requires this anyway?

I guess it by default uses a different compiler that doesn't support what's required

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

4 participants