Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support c++03 #1

Closed
wants to merge 7 commits into from
Closed

Support c++03 #1

wants to merge 7 commits into from

Conversation

414owen
Copy link
Owner

@414owen 414owen commented Jan 1, 2022

I'm making this a separate PR, as I'm not 100% sure I haven't messed up unicode support.

@tek are there tests that include unicode? Specifically on the symop codepath?

@wenkokke do you want to try compiling this branch to wasm?

@wenkokke
Copy link

wenkokke commented Jan 1, 2022

This version leaves me with the following error message:

Error: bad export type for `_ZTVNSt3__219basic_ostringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE`: undefined

@414owen
Copy link
Owner Author

414owen commented Jan 1, 2022

Huh, weird. Guess it doesn't like ostringstream...

Do you have a branch, and a command I can run to compile this for wasm?

@wenkokke
Copy link

wenkokke commented Jan 1, 2022

Yep, it's right here: https://github.com/wenkokke/tree-sitter-haskell/tree/tree-sitter-haskell-wasm-support-c%2B%2B03

I'm running...

make -B node_modules/web-tree-sitter && CXX=g++-11 ./script/parse-examples wasm

...to rebuild a patched version of tree-sitter and run the wasm tests.

@wenkokke
Copy link

wenkokke commented Jan 1, 2022

I am making progress however by using ostringstream we're definitely incurring a tree-sitter patch, and I'm afraid a rather large one.

@wenkokke
Copy link

wenkokke commented Jan 1, 2022

I was wrong, the following patch is enough:

--- a/lib/binding_web/exports.json
+++ b/lib/binding_web/exports.json
@@ -3,6 +3,11 @@
   "_free",
   "_malloc",

+  "__ZTTNSt3__219basic_ostringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE",
+  "__ZTVNSt3__219basic_ostringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE",
+  "__ZTVNSt3__29basic_iosIcNS_11char_traitsIcEEEE",
+  "__ZNSt3__25ctypeIcE2idE",
+
   "__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm",
   "__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv",
   "__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm",

Unfortunately, that still means a patch is needed.

@wenkokke
Copy link

wenkokke commented Jan 1, 2022

This version leaves me with the following error message:

Error: bad export type for `_ZTVNSt3__219basic_ostringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE`: undefined

This error was because I was accidentally running a version of web-tree-sitter compiled without --debug, which I didn't notice because usually the errors that you get without --debug are just "failed: undefined".

@wenkokke
Copy link

wenkokke commented Jan 1, 2022

However, I can report that this runs without any problems on macOS:

npx tree-sitter parse [file] # works!
npx tree-sitter test         # works!
npx tree-sitter build-wasm   # works, but requires patched web-tree-sitter

So patch or no patch, it's probably still worth merging to get proper macOS support.

@414owen
Copy link
Owner Author

414owen commented Jan 2, 2022

@wenkokke I've removed ostringstream. Maybe __ZNSt3__25ctypeIcE2idE is still needed?

@414owen
Copy link
Owner Author

414owen commented Jan 2, 2022

I'm going to create a PR upstream, because it's quite helpful in terms of portability eg.

We can deal with the remaining wasm patch, if there is one, separately.

@414owen 414owen closed this Jan 2, 2022
@414owen
Copy link
Owner Author

414owen commented Jan 2, 2022

see tree-sitter#58

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants