Comments (9)
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.
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.
Did you try the cpp method? It should just work.
from tree-sitter-python.
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.
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.
Yeah, I think you need a c build and a C++ build.
from tree-sitter-python.
Gotcha, makes sense -- I got it to work, thank you for the help.
from tree-sitter-python.
FWIW, using C++ does seem to preclude static linking using musl
from tree-sitter-python.
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)
- `Error during compilation: cannot execute ‘cc1plus’: execvp: No such file or directory` HOT 2
- Missing git tag for v0.20.2 HOT 2
- Two nodes with kind "lambda" in 0.20.2 HOT 1
- Parsing error in while loop HOT 3
- Cannot compile due to call to undeclared function 'static_assert' HOT 7
- Comment parsing HOT 2
- 3.12 "`type`" soft keyword (PEP 0695) HOT 1
- Extra indent when using an open bracket/parenthesis in string literal HOT 1
- Helping injected languages parse docstrings HOT 1
- Parameter highlight group doesn't capture references in body HOT 6
- Trailing comma in Annotated causes an error
- bug: Bad parse/behavior with docstring containing extraneous "-character HOT 1
- feature: doctest support HOT 2
- bug: Fail to parse type expression
- bug: Fail to parse from here but the online playground is fine
- bug: release for 0.21.0 HOT 11
- bug: Special case not managed by the parser, when an expression is split without a backslash and the second line is dedented.
- bug: arguments in Callable not marked as types HOT 3
- bug: `.1l` is not valid in python2 HOT 3
- feature: pre-compiled binary wheels for M chip macOS (arm64) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tree-sitter-python.