GithubHelp home page GithubHelp logo

Comments (9)

issue-label-bot avatar issue-label-bot commented on May 19, 2024 1

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.95. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

from tree-sitter-python.

maxbrunsfeld avatar maxbrunsfeld commented on May 19, 2024 1

I use it from Rust myself and have found it painless, since libc++/libstdc++ is available in almost every environment where a C compiler is available. C++ is also used in external scanners of other languages.

In the case of that file, we use C++ because of std::vector and std::string.

from tree-sitter-python.

maxbrunsfeld avatar maxbrunsfeld commented on May 19, 2024 1

Did you try the cpp method? It should just work.

from tree-sitter-python.

mcobzarenco avatar mcobzarenco commented on May 19, 2024

Thanks for this @maxbrunsfeld, would you mind sharing your build.rs that links with libstdc++? Have you tried linking statically (musl needs some shimming as it doesn't support C++ out of the box)? On nightly, the following build directive is useful (but still won't just work without rebuilding libstdc++ against musl):

println!("cargo:rustc-link-lib=static=stdc++");

from tree-sitter-python.

mcobzarenco avatar mcobzarenco commented on May 19, 2024

Ha! Thanks for that, it does help set up the env for dynlib case (static linking against C++ still requires recompiling libstd++ against musl, I think).

However, it seems that compiling parser.c with a C++ compiler rather than C doesn't work -- I am getting pages of the following:

...
cargo:warning=grammars/tree-sitter-python/src/parser.c:40434:3: sorry, unimplemented: non-trivial designated initializers not supported
cargo:warning=grammars/tree-sitter-python/src/parser.c:40434:3: sorry, unimplemented: non-trivial designated initializers not supported
cargo:warning=grammars/tree-sitter-python/src/parser.c:40434:3: sorry, unimplemented: non-trivial designated initializers not supported
cargo:warning=grammars/tree-sitter-python/src/parser.c:40434:3: sorry, unimplemented: non-trivial designated initializers not supported
...

This seems to be as parser.c uses designated initializers syntax (i.e. .field = value) which is not valid C++ according to the standard:

Note: out-of-order designated initialization, nested designated initialization, mixing of designated initializers and regular initializers, and designated initialization of arrays are all supported in the C programming language, but are not allowed in C++.

from tree-sitter-python.

maxbrunsfeld avatar maxbrunsfeld commented on May 19, 2024

Yeah, I think you need a c build and a C++ build.

from tree-sitter-python.

mcobzarenco avatar mcobzarenco commented on May 19, 2024

Gotcha, makes sense -- I got it to work, thank you for the help.

from tree-sitter-python.

mcobzarenco avatar mcobzarenco commented on May 19, 2024

FWIW, using C++ does seem to preclude static linking using musl

from tree-sitter-python.

maxbrunsfeld avatar maxbrunsfeld commented on May 19, 2024

Yeah, if you're trying to avoid dependencies on libc/libc++, I can see how this would complicate things.

One reference I might use is Emscripten, which compiles code written in both C and C++ into self-contained WebAssembly bindings using mostly-unmodified source files from libc++.

I think that you could probably use the same approach to create a statically-linked native binary, by adding several source files and include flags from libc++ to your build.

from tree-sitter-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.