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

Linking error on rocksdb v0.22.0 #84

Closed
nalply opened this issue Nov 28, 2024 · 11 comments
Closed

Linking error on rocksdb v0.22.0 #84

nalply opened this issue Nov 28, 2024 · 11 comments

Comments

@nalply
Copy link

nalply commented Nov 28, 2024

Today I wanted to install rgit on my Arch Linux home server.

$ rustup update
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/nalp/.rustup

stable-x86_64-unknown-linux-gnu
rustc 1.82.0 (f6e511eec 2024-10-15)
$ cargo install --git https://github.com/w4/rgit
    Updating git repository `https://github.com/w4/rgit`
  Installing rgit v0.1.4 (https://github.com/w4/rgit#7cbbf9c1)
    Updating crates.io index
     Locking 359 packages to latest compatible versions
      Adding bindgen v0.69.5 (latest: v0.70.1)
      Adding comrak v0.29.0 (latest: v0.31.0)
      Adding dlv-list v0.5.2 (latest: v0.6.0)
      Adding faster-hex v0.9.0 (latest: v0.10.0)
      Adding generic-array v0.14.7 (latest: v1.1.1)

[redacted]

   Compiling gix-odb v0.65.0
   Compiling gix-worktree v0.38.0
   Compiling gix-diff v0.48.0
   Compiling gix-submodule v0.16.0
   Compiling gix v0.68.0
   Compiling rocksdb v0.22.0
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/nalp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/nalp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x

[redacted]

repository-1ef563a0ed4227ce/out" "-L" "/tmp/cargo-installLcH5xY/release/build/tree-sitter-grammar-repository-1ef563a0ed4227ce/out" "-L" "/tmp/cargo-installLcH5xY/release/build/tree-sitter-grammar-repository-1ef563a0ed4227ce/out" "-L" "/tmp/cargo-installLcH5xY/release/build/tree-sitter-grammar-repository-1ef563a0ed4227ce/out" "-L" "/tmp/cargo-installLcH5xY/release/build/tree-sitter-grammar-repository-1ef563a0ed4227ce/out" "-L" "/tmp/cargo-installLcH5xY/release/build/tree-sitter-ad1d93fa08170a05/out" "-L" "/home/nalp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/cargo-installLcH5xY/release/deps/rgit-cde0f5270468d4ec" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs"
  = note: /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(6b9ce5613ba2324f-scanner.o): in function `tree_sitter_html_external_scanner_create':
          scanner.cc:(.text.tree_sitter_html_external_scanner_create+0x0): multiple definition of `tree_sitter_html_external_scanner_create'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(721bdf1b04363eb7-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_create+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(6b9ce5613ba2324f-scanner.o): in function `tree_sitter_html_external_scanner_serialize':
          scanner.cc:(.text.tree_sitter_html_external_scanner_serialize+0x0): multiple definition of `tree_sitter_html_external_scanner_serialize'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(721bdf1b04363eb7-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_serialize+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(6b9ce5613ba2324f-scanner.o): in function `tree_sitter_html_external_scanner_destroy':
          scanner.cc:(.text.tree_sitter_html_external_scanner_destroy+0x0): multiple definition of `tree_sitter_html_external_scanner_destroy'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(721bdf1b04363eb7-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_destroy+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(6b9ce5613ba2324f-scanner.o): in function `tree_sitter_html_external_scanner_deserialize':
          scanner.cc:(.text.tree_sitter_html_external_scanner_deserialize+0x0): multiple definition of `tree_sitter_html_external_scanner_deserialize'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(721bdf1b04363eb7-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_deserialize+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(6b9ce5613ba2324f-scanner.o): in function `tree_sitter_html_external_scanner_scan':
          scanner.cc:(.text.tree_sitter_html_external_scanner_scan+0x0): multiple definition of `tree_sitter_html_external_scanner_scan'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(721bdf1b04363eb7-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_scan+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(b3aada6d28209d5c-scanner.o): in function `state_new':
          scanner.c:(.text.state_new+0x0): multiple definition of `state_new'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(29d5a2f7b44a084b-scanner.o):scanner.c:(.text.state_new+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(fff719e1cc5f1280-scanner.o): in function `scan_comment':
          scanner.c:(.text.scan_comment+0x0): multiple definition of `scan_comment'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(7916d75eb6270266-scanner.o):scanner.c:(.text.scan_comment+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(c30c88a57adc319b-scanner.o): in function `is_newline':
          scanner.c:(.text.is_newline+0x0): multiple definition of `is_newline'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(a20d3a3ca4e5ec1b-scanner.o):scanner.c:(.text.is_newline+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(c30c88a57adc319b-scanner.o): in function `is_space':
          scanner.c:(.text.is_space+0x0): multiple definition of `is_space'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(a20d3a3ca4e5ec1b-scanner.o):scanner.c:(.text.is_space+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(fac12513b716f374-scanner.o): in function `state_new':
          scanner.c:(.text.state_new+0x0): multiple definition of `state_new'; /tmp/cargo-installLcH5xY/release/deps/libtree_sitter_grammar_repository-c2edc9237dbf1a36.rlib(29d5a2f7b44a084b-scanner.o):scanner.c:(.text.state_new+0x0): first defined here
          collect2: error: ld returned 1 exit status
          

error: could not compile `rgit` (bin "rgit") due to 1 previous error
error: failed to compile `rgit v0.1.4 (https://github.com/w4/rgit#7cbbf9c1)`, intermediate artifacts can be found at `/tmp/cargo-installLcH5xY`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
$ # help me here, please!      

Please understand: I am reporting here and not at rocksdb because I got the impression that rocksdb can fail linking if you use the wrong features. If you disagree, please tell me why and then I can create a better issue for rocksdb. Thank you!

@lusk
Copy link

lusk commented Jan 5, 2025

I seem to be hitting the same issue. I'm trying to build a binary for musl based distribution (Alpine Linux) and these are the steps to reproduce:

  1. downloaded source from https://github.com/w4/rgit/archive/refs/heads/main.zip
  2. unzip and cd into rgit-main directory
  3. run cross-compilation container with docker run --rm -it -v "$(pwd)":/home/rust/src messense/rust-musl-cross:x86_64-musl which gives me a shell inside the container with rgit source code in working directory
  4. run cargo build --release (this is inside the container shell)
  5. observe the following error:
[ redacted ]

  = note: /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(8236faca916f56de-scanner.o): in function `tree_sitter_html_external_scanner_create':
          scanner.cc:(.text.tree_sitter_html_external_scanner_create+0x0): multiple definition of `tree_sitter_html_external_scanner_create'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(3d5288ccb8214aef-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_create+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(8236faca916f56de-scanner.o): in function `tree_sitter_html_external_scanner_serialize':
          scanner.cc:(.text.tree_sitter_html_external_scanner_serialize+0x0): multiple definition of `tree_sitter_html_external_scanner_serialize'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(3d5288ccb8214aef-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_serialize+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(8236faca916f56de-scanner.o): in function `tree_sitter_html_external_scanner_destroy':
          scanner.cc:(.text.tree_sitter_html_external_scanner_destroy+0x0): multiple definition of `tree_sitter_html_external_scanner_destroy'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(3d5288ccb8214aef-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_destroy+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(8236faca916f56de-scanner.o): in function `tree_sitter_html_external_scanner_deserialize':
          scanner.cc:(.text.tree_sitter_html_external_scanner_deserialize+0x0): multiple definition of `tree_sitter_html_external_scanner_deserialize'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(3d5288ccb8214aef-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_deserialize+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(8236faca916f56de-scanner.o): in function `tree_sitter_html_external_scanner_scan':
          scanner.cc:(.text.tree_sitter_html_external_scanner_scan+0x0): multiple definition of `tree_sitter_html_external_scanner_scan'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(3d5288ccb8214aef-scanner.o):scanner.cc:(.text.tree_sitter_html_external_scanner_scan+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(f1048fce08cc1992-scanner.o): in function `state_new':
          scanner.c:(.text.state_new+0x0): multiple definition of `state_new'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(0c1e729ee450b865-scanner.o):scanner.c:(.text.state_new+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(f756003e00b6e862-scanner.o): in function `scan_comment':
          scanner.c:(.text.scan_comment+0x0): multiple definition of `scan_comment'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(c726fa550d778cc8-scanner.o):scanner.c:(.text.scan_comment+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(d52b1044bfc240c6-scanner.o): in function `is_newline':
          scanner.c:(.text.is_newline+0x0): multiple definition of `is_newline'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(80e0de66cd4b4358-scanner.o):scanner.c:(.text.is_newline+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(d52b1044bfc240c6-scanner.o): in function `is_space':
          scanner.c:(.text.is_space+0x0): multiple definition of `is_space'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(80e0de66cd4b4358-scanner.o):scanner.c:(.text.is_space+0x0): first defined here
          /usr/local/musl/bin/../lib/gcc/x86_64-unknown-linux-musl/11.2.0/../../../../x86_64-unknown-linux-musl/bin/ld: /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(db5c911418115a7f-scanner.o): in function `state_new':
          scanner.c:(.text.state_new+0x0): multiple definition of `state_new'; /home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libtree_sitter_grammar_repository-d41da79721017802.rlib(0c1e729ee450b865-scanner.o):scanner.c:(.text.state_new+0x0): first defined here
          collect2: error: ld returned 1 exit status
          

error: could not compile `rgit` (bin "rgit") due to 1 previous error

@nalply
Copy link
Author

nalply commented Jan 5, 2025

I completely forgot about this, and today I retried and this time I did cargo install rgit with the current stable (1.83.0), and this time it worked?

EDIT: It seems that the instruction to install from git is wrong because rgit master is in development and currently build is broken on some flows? Perhaps it's better to build on a specific version instead? Today the most current published version is 0.10.0 from October 2022. Not sure.

EDIT 2: Ignore all this, it's a different project with the same name (https://github.com/morigm/rgit). They have registered their project to cargo.

@w4
Copy link
Owner

w4 commented Jan 5, 2025

Hi, apologies for the slow response. Please try again with this commit b13b804 - see JordanForks/helix@d4baf39 for more information

@nalply
Copy link
Author

nalply commented Jan 5, 2025

$ rm -fr /tmp/cargo-install*
$ uname -a
Linux nisaba 6.11.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 22 Oct 2024 18:31:38 +0000 x86_64 GNU/Linux
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/nalp/.rustup

stable-x86_64-unknown-linux-gnu (default)
rustc 1.83.0 (90b35a623 2024-11-26)
$ cargo install --git https://github.com/w4/rgit
[redacted]
  = note: /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(baf735c64e5c2c3c-scanner.o): in function `tree_sitter_html_external_scanner_create':
          scanner.cc:(.text.tree_sitter_html_external_scanner_create+0x0): multiple definition of `tree_sitter_html_external_scanner_create'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(abbc3bffe0d2a03e-scanner.o):scanner.c:(.text.tree_sitter_html_external_scanner_create+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(baf735c64e5c2c3c-scanner.o): in function `tree_sitter_html_external_scanner_serialize':
          scanner.cc:(.text.tree_sitter_html_external_scanner_serialize+0x0): multiple definition of `tree_sitter_html_external_scanner_serialize'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(abbc3bffe0d2a03e-scanner.o):scanner.c:(.text.tree_sitter_html_external_scanner_serialize+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(baf735c64e5c2c3c-scanner.o): in function `tree_sitter_html_external_scanner_destroy':
          scanner.cc:(.text.tree_sitter_html_external_scanner_destroy+0x0): multiple definition of `tree_sitter_html_external_scanner_destroy'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(abbc3bffe0d2a03e-scanner.o):scanner.c:(.text.tree_sitter_html_external_scanner_destroy+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(baf735c64e5c2c3c-scanner.o): in function `tree_sitter_html_external_scanner_deserialize':
          scanner.cc:(.text.tree_sitter_html_external_scanner_deserialize+0x0): multiple definition of `tree_sitter_html_external_scanner_deserialize'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(abbc3bffe0d2a03e-scanner.o):scanner.c:(.text.tree_sitter_html_external_scanner_deserialize+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(baf735c64e5c2c3c-scanner.o): in function `tree_sitter_html_external_scanner_scan':
          scanner.cc:(.text.tree_sitter_html_external_scanner_scan+0x0): multiple definition of `tree_sitter_html_external_scanner_scan'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(abbc3bffe0d2a03e-scanner.o):scanner.c:(.text.tree_sitter_html_external_scanner_scan+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(4aea5852a96efdbe-scanner.o): in function `state_new':
          scanner.c:(.text.state_new+0x0): multiple definition of `state_new'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(148a4046fa377462-scanner.o):scanner.c:(.text.state_new+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(f70076784a1be451-scanner.o): in function `scan_comment':
          scanner.c:(.text.scan_comment+0x0): multiple definition of `scan_comment'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(de5d9406394cb6c2-scanner.o):scanner.c:(.text.scan_comment+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(c768685ee2dd2507-scanner.o): in function `is_newline':
          scanner.c:(.text.is_newline+0x0): multiple definition of `is_newline'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(4455efb3ced9209c-scanner.o):scanner.c:(.text.is_newline+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(c768685ee2dd2507-scanner.o): in function `is_space':
          scanner.c:(.text.is_space+0x0): multiple definition of `is_space'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(4455efb3ced9209c-scanner.o):scanner.c:(.text.is_space+0x0): first defined here
          /usr/bin/ld: /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(b08f6264508721cf-scanner.o): in function `state_new':
          scanner.c:(.text.state_new+0x0): multiple definition of `state_new'; /tmp/cargo-installIdHJF4/release/deps/libtree_sitter_grammar_repository-42a2ca4f7523e4f9.rlib(148a4046fa377462-scanner.o):scanner.c:(.text.state_new+0x0): first defined here
          collect2: error: ld returned 1 exit status
$ # To make sure I got the most current version
$ grep JordanForks /home/nalp/.cargo//git/checkouts/rgit-279d9c5277f0946d/b13b804/tree-sitter-grammar-repository/build.rs 
const GRAMMAR_REPOSITORY_URL: &str = "https://github.com/JordanForks/helix";
$ # Yep!

@nalply
Copy link
Author

nalply commented Jan 5, 2025

I investigated a little bit and perhaps I found something?

JordanForks/helix@1603715

changes something in the Java grammar, but the linking problem affects the Html grammar.

Sorry if this is not helpful.

@w4
Copy link
Owner

w4 commented Jan 6, 2025

I can't seem to reproduce on my x86-64 server and is probably down to environment differences (gcc vs llvm, etc). I will keep trying though. Is it out of the question to use the Docker image built in CI or build using Nix?

@nalply
Copy link
Author

nalply commented Jan 6, 2025

I am going to try it with llvm. Meanwhile here some information.

[nalp@nisaba ~]$ cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20240910 (GCC) 
[nalp@nisaba ~]$ uname -a
Linux nisaba 6.11.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 22 Oct 2024 18:31:38 +0000 x86_64 GNU/Linux

@w4
Copy link
Owner

w4 commented Jan 6, 2025

Ok, I've reproduced now. There's a couple of conflicts between parsers when statically linking them, all variations of ikatyang/tree-sitter-vue#27. I've blacklisted vue, purescript, rst, comment, v and unison syntax highlighters in favour of the higher value highlighters they conflict with in 8869c6a.

[root@8fb99810e72c rgit]# cargo build
...
          /rgit/target/debug/build/tree-sitter-grammar-repository-14fff95ca4f47476/out/sources/unison/src/scanner.c:205: multiple definition of `state_new'; /rgit/target/debug/deps/libtree_sitter_grammar_repository-8957ba8a3ca7a69a.rlib(67b2c7ab1bd83d61-scanner.o):/rgit/target/debug/build/tree-sitter-grammar-repository-14fff95ca4f47476/out/sources/haskell/src/scanner.c:218: first defined here
          collect2: error: ld returned 1 exit status


error: could not compile `rgit` (bin "rgit") due to 1 previous error
[root@8fb99810e72c rgit]# vi tree-sitter-grammar-repository/build.rs
[root@8fb99810e72c rgit]# git --no-pager diff
diff --git a/tree-sitter-grammar-repository/build.rs b/tree-sitter-grammar-repository/build.rs
index 1bca22f..e1e98a0 100644
--- a/tree-sitter-grammar-repository/build.rs
+++ b/tree-sitter-grammar-repository/build.rs
@@ -29,6 +29,13 @@ static BLACKLISTED_MODULES: &[&str] = &[
     "wren",
     // doesn't compile on macos
     "gemini",
+    "purescript",
+    "vue",
+    "rst",
+    "comment",
+    "v",
+    "unison",
+    "llvm",
 ];

 fn main() -> anyhow::Result<()> {
[root@8fb99810e72c rgit]# ./target/debug/rgit --help
A gitweb/cgit-like interface

Usage: rgit [OPTIONS] --db-store <DB_STORE> <BIND_ADDRESS> <SCAN_PATH>

...

@nalply
Copy link
Author

nalply commented Jan 6, 2025

I could compile both with clang and gcc. Thank you!

@w4
Copy link
Owner

w4 commented Jan 6, 2025

No problem, thanks for the report. Let me know if you have any more problems. I'll close this issue for now, please reopen if you're still having issues with your musl build @lusk

@w4 w4 closed this as completed Jan 6, 2025
@lusk
Copy link

lusk commented Jan 6, 2025

I'm able to successfully build the binary against musl now. Thank you both for the time spent on finding the fix!

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

3 participants