GramEditor/gram
38
987
Fork
You've already forked gram
88

Can't build extensions /usr/bin/ld : option « --export=tree_sitter_xml » unrecognized #77

Closed
opened 2026年03月10日 06:28:35 +01:00 by nicoco · 13 comments
Member
Copy link

Built from 5d83e98f99

Example extension https://github.com/sweetppro/zed-xml/

Log:

2026年03月10日T06:25:39+01:00 INFO [extensions_ui] install_extension_from_repo: "https://github.com/sweetppro/zed-xml/"
2026年03月10日T06:25:39+01:00 INFO [extension_host] path= "/tmp/.tmpuPKg3U/"
2026年03月10日T06:25:39+01:00 INFO [extension::extension_builder] compile_extension: "/tmp/.tmpuPKg3U/" ExtensionManifest { id: "xml", name: "XML", version: "0.1.0", schema_version: SchemaVersion(1), description: Some("XML syntax support."), repository: Some("https://github.com/sweetppro/zed-xml"), authors: ["sweetppro"], lib: LibManifestEntry { kind: None, version: None }, themes: [], icon_themes: [], languages: ["languages/xml"], grammars: {"xml": GrammarManifestEntry { repository: "https://github.com/tree-sitter-grammars/tree-sitter-xml", rev: "863dbc381f44f6c136a399e684383b977bb2beaa", path: Some("xml") }}, language_servers: {}, snippets: None, capabilities: [], debug_adapters: {}, debug_locators: {} }
2026年03月10日T06:25:39+01:00 INFO [extension::extension_builder] compiling grammar xml for extension /tmp/.tmpuPKg3U/
2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] checking out xml parser
2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] git_dir="/tmp/.tmpuPKg3U/grammars/xml/.git"
2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] checkout_repo: running git init /tmp/.tmpuPKg3U/grammars/xml
2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] checkout_repo: running git --git-dir /tmp/.tmpuPKg3U/grammars/xml/.git remote add origin https://github.com/tree-sitter-grammars/tree-sitter-xml
2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] compiling xml parser
2026年03月10日T06:25:41+01:00 ERROR [crates/util/src/util.rs:664] failed to compile grammar 'xml'

Caused by:
failed to compile xml parser with clang: /usr/bin/ld : option « --export=tree_sitter_xml » non reconnue
/usr/bin/ld : utiliser --help pour afficher l'aide-mémoire
clang: error: linker command failed with exit code 1 (use -v to see invocation)

2026年03月10日T06:25:41+01:00 ERROR [crates/extension_host/src/extension_host.rs:602] failed to compile grammar 'xml'

Caused by:
failed to compile xml parser with clang: /usr/bin/ld : option « --export=tree_sitter_xml » non reconnue
/usr/bin/ld : utiliser --help pour afficher l'aide-mémoire
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Built from 5d83e98f99f6e15420e5bf9a13871aec535c8443 Example extension https://github.com/sweetppro/zed-xml/ Log: 2026年03月10日T06:25:39+01:00 INFO [extensions_ui] install_extension_from_repo: "https://github.com/sweetppro/zed-xml/" 2026年03月10日T06:25:39+01:00 INFO [extension_host] path= "/tmp/.tmpuPKg3U/" 2026年03月10日T06:25:39+01:00 INFO [extension::extension_builder] compile_extension: "/tmp/.tmpuPKg3U/" ExtensionManifest { id: "xml", name: "XML", version: "0.1.0", schema_version: SchemaVersion(1), description: Some("XML syntax support."), repository: Some("https://github.com/sweetppro/zed-xml"), authors: ["sweetppro"], lib: LibManifestEntry { kind: None, version: None }, themes: [], icon_themes: [], languages: ["languages/xml"], grammars: {"xml": GrammarManifestEntry { repository: "https://github.com/tree-sitter-grammars/tree-sitter-xml", rev: "863dbc381f44f6c136a399e684383b977bb2beaa", path: Some("xml") }}, language_servers: {}, snippets: None, capabilities: [], debug_adapters: {}, debug_locators: {} } 2026年03月10日T06:25:39+01:00 INFO [extension::extension_builder] compiling grammar xml for extension /tmp/.tmpuPKg3U/ 2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] checking out xml parser 2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] git_dir="/tmp/.tmpuPKg3U/grammars/xml/.git" 2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] checkout_repo: running git init /tmp/.tmpuPKg3U/grammars/xml 2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] checkout_repo: running git --git-dir /tmp/.tmpuPKg3U/grammars/xml/.git remote add origin https://github.com/tree-sitter-grammars/tree-sitter-xml 2026年03月10日T06:25:40+01:00 INFO [extension::extension_builder] compiling xml parser 2026年03月10日T06:25:41+01:00 ERROR [crates/util/src/util.rs:664] failed to compile grammar 'xml' Caused by: failed to compile xml parser with clang: /usr/bin/ld : option « --export=tree_sitter_xml » non reconnue /usr/bin/ld : utiliser --help pour afficher l'aide-mémoire clang: error: linker command failed with exit code 1 (use -v to see invocation) 2026年03月10日T06:25:41+01:00 ERROR [crates/extension_host/src/extension_host.rs:602] failed to compile grammar 'xml' Caused by: failed to compile xml parser with clang: /usr/bin/ld : option « --export=tree_sitter_xml » non reconnue /usr/bin/ld : utiliser --help pour afficher l'aide-mémoire clang: error: linker command failed with exit code 1 (use -v to see invocation)
Author
Member
Copy link

Workaround: sudo apt remove clang (this is on debian trixie)

Workaround: `sudo apt remove clang` (this is on debian trixie)
Owner
Copy link

The code expects to be compiling with clang, but this looks like it’s calling the GNU ld in your case.

But if we can I think we should make that work.

The code expects to be compiling with clang, but this looks like it’s calling the GNU ld in your case. But if we can I think we should make that work.
Owner
Copy link

@nicoco wrote in #77 (comment):

Workaround: sudo apt remove clang (this is on debian trixie)

Oh really, that seems backwards. Maybe it is calling clang but ends up using the GNU ld anyway. Then it really sounds like a bug.

@nicoco wrote in https://codeberg.org/GramEditor/gram/issues/77#issuecomment-11439613: > Workaround: `sudo apt remove clang` (this is on debian trixie) Oh really, that seems backwards. Maybe it _is_ calling clang but ends up using the GNU ld anyway. Then it really sounds like a bug.
Author
Member
Copy link

I am happy to test things out but full disclaimer: my knowledge of anything clang/gcc/ld/rust/wasm is very limited. Let me know if I can provide more info.

I am happy to test things out but full disclaimer: my knowledge of anything clang/gcc/ld/rust/wasm is _very_ limited. Let me know if I can provide more info.
Owner
Copy link

This seems to be a consequence of allowing use of the system-installed clang instead of always installing the WASI SDK. But the question is whether it would be fine to just export all symbols and not just the one, since the ld version you have installed doesn't support the --export argument. I will have to test this when I have more time.

This seems to be a consequence of allowing use of the system-installed clang instead of always installing the WASI SDK. But the question is whether it would be fine to just export all symbols and not just the one, since the `ld` version you have installed doesn't support the `--export` argument. I will have to test this when I have more time.
Contributor
Copy link

Apologies, haven't tested #64 properly. Could you check if it works for you on #84?

Apologies, haven't tested #64 properly. Could you check if it works for you on #84?

Your branch solved the issue with ld, but it seems it now throws a different error regarding tree-sitter. This also happens with other extensions not just the c3 one.

Caused by:
failed to compile c3 parser with clang: In file included from /home/nick/gram-extensions/c3-zed/grammars/c3/src/parser.c:3:
/home/nick/gram-extensions/c3-zed/grammars/c3/src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found
10 | #include <stdlib.h>
| ^~~~~~~~~~
1 error generated.
In file included from /home/nick/gram-extensions/c3-zed/grammars/c3/src/scanner.c:1:
/home/nick/gram-extensions/c3-zed/grammars/c3/src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found
10 | #include <stdlib.h>
| ^~~~~~~~~~
1 error generated.

2026年03月10日T22:00:23+01:00 ERROR [extensions_ui] Failed to install dev extension(144): failed to compile grammar 'c3'

Caused by:
failed to compile c3 parser with clang: In file included from /home/nick/gram-extensions/c3-zed/grammars/c3/src/parser.c:3:
/home/nick/gram-extensions/c3-zed/grammars/c3/src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found
10 | #include <stdlib.h>
| ^~~~~~~~~~
1 error generated.
In file included from /home/nick/gram-extensions/c3-zed/grammars/c3/src/scanner.c:1:
/home/nick/gram-extensions/c3-zed/grammars/c3/src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found
10 | #include <stdlib.h>
| ^~~~~~~~~~
1 error generated.

Your branch solved the issue with ld, but it seems it now throws a different error regarding tree-sitter. This also happens with other extensions not just the c3 one. Caused by: failed to compile c3 parser with clang: In file included from /home/nick/gram-extensions/c3-zed/grammars/c3/src/parser.c:3: /home/nick/gram-extensions/c3-zed/grammars/c3/src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found 10 | #include <stdlib.h> | ^~~~~~~~~~ 1 error generated. In file included from /home/nick/gram-extensions/c3-zed/grammars/c3/src/scanner.c:1: /home/nick/gram-extensions/c3-zed/grammars/c3/src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found 10 | #include <stdlib.h> | ^~~~~~~~~~ 1 error generated. 2026年03月10日T22:00:23+01:00 ERROR [extensions_ui] Failed to install dev extension(144): failed to compile grammar 'c3' Caused by: failed to compile c3 parser with clang: In file included from /home/nick/gram-extensions/c3-zed/grammars/c3/src/parser.c:3: /home/nick/gram-extensions/c3-zed/grammars/c3/src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found 10 | #include <stdlib.h> | ^~~~~~~~~~ 1 error generated. In file included from /home/nick/gram-extensions/c3-zed/grammars/c3/src/scanner.c:1: /home/nick/gram-extensions/c3-zed/grammars/c3/src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found 10 | #include <stdlib.h> | ^~~~~~~~~~ 1 error generated.
Contributor
Copy link

Do you have the wasi-libc package installed?

Do you have the `wasi-libc` package installed?
Owner
Copy link

The compilation probably also need to pass the --sysroot=/path/to/sysroot flag, but I am not sure what path to pass in there.

The compilation probably also need to pass the `--sysroot=/path/to/sysroot` flag, but I am not sure what path to pass in there.
Owner
Copy link

Quoting the WASI SDK documentation:

One could also use a standard Clang installation, build a sysroot from the sources mentioned above, and compile with --target=wasm32-wasi --sysroot=/path/to/sysroot. In this scenario, one would also need the libclang_rt.*.a objects available separately in the release downloads which must be extracted into $CLANG_INSTALL_DIR/$CLANG_VERSION/lib/.

Quoting the WASI SDK documentation: > One could also use a standard Clang installation, build a sysroot from the sources mentioned above, and compile with --target=wasm32-wasi --sysroot=/path/to/sysroot. In this scenario, one would also need the libclang_rt.*.a objects available separately in the release downloads which must be extracted into $CLANG_INSTALL_DIR/$CLANG_VERSION/lib/.
Contributor
Copy link

Checked with Debian forky, Fedora 43, and Alpine edge: Debian doesn't need a sysroot, but only builds wasm32-wasi and not wasm32-wasip2; Fedora needs a sysroot to /usr/wasm32-wasi and even then it looks like wasm32 compiler-rt is not available, Alpine needs a sysroot to /usr/share/wasi-sysroot.

We could easily check a list of common paths, but a list of needed packages will be very different per distro (libclang-rt-dev-wasm32, wasi-libc-devel, for some examples), and what is actually available also differs.

I think the easiest solution for now would be to download just a sysroot from wasi-sdk.

Checked with Debian forky, Fedora 43, and Alpine edge: Debian doesn't need a sysroot, but only builds `wasm32-wasi` and not `wasm32-wasip2`; Fedora needs a sysroot to `/usr/wasm32-wasi` and even then it looks like wasm32 compiler-rt is not available, Alpine needs a sysroot to `/usr/share/wasi-sysroot`. We could easily check a list of common paths, but a list of needed packages will be very different per distro (`libclang-rt-dev-wasm32`, `wasi-libc-devel`, for some examples), and what is actually available also differs. I think the easiest solution for now would be to download just a sysroot from wasi-sdk.
Owner
Copy link

I have made it so that we download the WASI sysroot even if we find a compatible compiler installed.

This probably still has some sharp edges, so I expect there to be more work needed here, and I also want to add some way for the user to opt into dowloading either the SDK or the sysroot. Just haven't found the right place to do so yet.

I have made it so that we download the WASI sysroot even if we find a compatible compiler installed. This probably still has some sharp edges, so I expect there to be more work needed here, and I also want to add some way for the user to opt into dowloading either the SDK or the sysroot. Just haven't found the right place to do so yet.
Sign in to join this conversation.
No Branch/Tag specified
main
test/wgpu-on-mac
test-ci/failing-test-mac
test/failing-test-mac
test/build-on-22-04
test/wgpu-present-mode-mailbox
v2.1
test/altgr-fix-again
test/2.0.0-rc1
test/linux-build
test/objc2
v1.2.1
3.0.1
3.0.0
2.2.0
2.1.2
2.1.1
2.1.0
2.0.0
1.2.1
1.2.0
1.1.0
1.0.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
GramEditor/gram#77
Reference in a new issue
GramEditor/gram
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?