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

proc macro Deserialize not expanded: Cannot create expander for libserde_derive: UnsupportedABI #13589

Closed
msvi opened this issue Nov 9, 2022 · 19 comments · Fixed by #13635
Closed

Comments

@msvi
Copy link

msvi commented Nov 9, 2022

rust-analyzer version: 0.3.1277-standalone

rustc version: 1.65.0 (897e37553 2022-11-02)

relevant settings: --

rustup show:

Default host: x86_64-unknown-linux-gnu
rustup home:  $HOME/.rustup

stable-x86_64-unknown-linux-gnu (default)
rustc 1.65.0 (897e37553 2022-11-02)

I'm getting the following error message with serde:

proc macro `Deserialize` not expanded: Cannot create expander for <project>/target/debug/deps/libserde_derive-a150df8d26d00fd1.so: UnsupportedABI

I've already cleaned and recompiled the project. Building and cargo check works fine.

@lnicola
Copy link
Member

lnicola commented Nov 9, 2022

Strange, do you have ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/libexec/rust-analyzer-proc-macro-srv? Does your project have a rust-toolchain file?

@bjorn3
Copy link
Member

bjorn3 commented Nov 9, 2022

And what does readelf --hex-dump .rustc <project>/target/debug/deps/libserde_derive-a150df8d26d00fd1.so | head show?

@Veykril
Copy link
Member

Veykril commented Nov 9, 2022

I think we should try and make that error message more helpful by printing expected abi vs found one etc.

@msvi
Copy link
Author

msvi commented Nov 9, 2022

Strange, do you have ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/libexec/rust-analyzer-proc-macro-srv? Does your project have a rust-toolchain file?

Yes, that file exists. I don't have a rust-toolchain file in my project.

And what does readelf --hex-dump .rustc <project>/target/debug/deps/libserde_derive-a150df8d26d00fd1.so | head show?

Hex dump of section '.rustc':
  0x00000000 72757374 00000006 ff060000 734e6150 rust........sNaP
  0x00000010 705900ed 1d004c9c 489f8080 04307275 pY....L.H....0ru
  0x00000020 73740000 00060002 2cf62901 0d506320 st......,.)..Pc 
  0x00000030 312e3635 2e302028 41726368 204c696e 1.65.0 (Arch Lin
  0x00000040 75782001 19082031 3a091a70 2d3129c1 ux ... 1:..p-1).
  0x00000050 00000001 00060010 64657269 76655f73 ........derive_s
  0x00000060 65726961 6c697a65 c1051700 120d1704 erialize........
  0x00000070 64651d19 c00000e9 09ea0900 00008018 de..............

@bjorn3
Copy link
Member

bjorn3 commented Nov 9, 2022

Looks like your project is compiled with a rustc installed from the arch linux package repos. This version is incompatible with a rustc from rustup. Does /usr/libexec/rust-analyzer-proc-macro-srv exist? If so rust-analyzer probably gets confused and thinks it needs to load the rust-analyzer-proc-macro-srv from rustup. If not rust-analyzer may have picked the right rustc, but fails anyway as arch linux doesn't ship the proc macro server. In either case compiling using the rustup distributed version of rustc (by putting ~/.cargo/bin before /usr/bin in your PATH or by removing the arch linux installed rustc) should solve your issues.

@lnicola
Copy link
Member

lnicola commented Nov 9, 2022

Arch has /usr/lib/rust-analyzer-proc-macro-srv. But indeed, you should uninstall the Arch rust package.

@bjorn3
Copy link
Member

bjorn3 commented Nov 9, 2022

This is the issue: https://github.com/archlinux/svntogit-packages/blob/packages/rust/trunk/0001-bootstrap-Change-libexec-dir.patch Arch linux decided to move rust-analyzer-proc-macro-srv from libexec to lib, breaking rust-analyzer. @heftig why does arch linux change libexec to lib for rust-analyzer-proc-macro-srv?

@lnicola
Copy link
Member

lnicola commented Nov 9, 2022

Arch doesn't have a /usr/libexec at all.

@msvi
Copy link
Author

msvi commented Nov 9, 2022

Thank you very much everyone for your help. After removing the system rustc installation the issue is resolved.

However, I had ~/.cargo/bin as highest priority in my PATH (set in ~/.zshenv) and /usr/lib/rust-analyzer-proc-macro-srv did exist.

@lnicola
Copy link
Member

lnicola commented Nov 9, 2022

and /usr/lib/rust-analyzer-proc-macro-srv did exist

We build the path to that executable by appending libexec to the output of rustc --print sysroot. The latter is /usr on Arch.

@heftig
Copy link

heftig commented Nov 9, 2022

@heftig why does arch linux change libexec to lib for rust-analyzer-proc-macro-srv?

Arch Linux never had /usr/libexec/ and to install files there is a packaging error. Binaries that should be in PATH are installed into /usr/bin/ and those that don't are installed into /usr/lib/. All packages use /usr/lib/ or a subdirectory as the libexecdir.

@lnicola
Copy link
Member

lnicola commented Nov 9, 2022

I'd be in favour of us trying both libexec and lib for better compatibility.

@bjorn3
Copy link
Member

bjorn3 commented Nov 9, 2022

@heftig I see. I guess we could move it to lib/rustlib/x86_64-unknown-linux-gnu/libexec (or .../bin). In any case it would have been nice if you informed us about the incompatibility with the arch linux packaging rules. The sole purpose of rust-analyzer-proc-macro-srv is to make any (recent) rust-analyzer version (including those distributed in the vscode extension) work with with any (recent) rustc version independent of who built it. This requires at a minimum a well known location that is independent of the entity packaging rust or rust-analyzer. Had we known that arch linux doesn't allow /usr/libexec, I'm sure we would have chosen a location that does work for everyone involved.

@nozwock
Copy link

nozwock commented Nov 11, 2022

#13589 (comment)
Thanks, I resolved the issue by removing the Arch rust pkg.

by putting ~/.cargo/bin before /usr/bin in your PATH or by removing the arch linux installed rustc

I already had ~/.cargo/bin before /usr/bin in my PATH, but still encountered this issue, weird?

btw I was sure I had rust pkg removed before, maybe some AUR pkg installed it for builds and I didn't pay attention.

@bjorn3
Copy link
Member

bjorn3 commented Nov 11, 2022

Is it also this way for your editor? (you can use cat /proc/<editor pid>/environ | tr '\0' '\n' to show all env vars set for your editor) ~/.zshenv is only read by zsh afaik and not when logging in on a graphical system. And as such your editor likely doesn't inherit the env vars set in ~/.zshenv. ~/.profile is the shell script that runs when logging in.

@nozwock
Copy link

nozwock commented Nov 11, 2022

~/.zshenv is only read by zsh afaik and not when logging in on a graphical system. And as such your editor likely doesn't inherit the env vars set in ~/.zshenv. ~/.profile is the shell script that runs when logging in.

Ah yes, that makes sense, I forgot that I only have the PATH modified for my shell.
Sorry about that.

you can use cat /proc/<editor pid>/environ | tr '\0' '\n' to show all env vars set for your editor

Ya I did that and as expected ~/.cargo/bin was not included in the PATH

bors added a commit that referenced this issue Nov 11, 2022
internal: Add version info to unsupported proc macro abi error

cc #13589 (comment)
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Nov 14, 2022
Thanks to Akatsuki Rui (akiirui) for the bug report and patch.

Fixes FS#76568
Upstream issue: rust-lang/rust-analyzer#13589

git-svn-id: file:///srv/repos/svn-community/svn@1347533 9fca08f4-af9d-4005-b8df-a31f2cc04f65
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Nov 14, 2022
Thanks to Akatsuki Rui (akiirui) for the bug report and patch.

Fixes FS#76568
Upstream issue: rust-lang/rust-analyzer#13589


git-svn-id: file:///srv/repos/svn-community/svn@1347533 9fca08f4-af9d-4005-b8df-a31f2cc04f65
@polyzen
Copy link
Contributor

polyzen commented Nov 14, 2022

Applied Akatsuki Rui (akiirui)'s patch to use /usr/lib to Arch's rust-analyzer package:
https://bugs.archlinux.org/task/76568
archlinux/svntogit-community@53ae631

@heftig
Copy link

heftig commented Nov 15, 2022

I'd be in favour of us trying both libexec and lib for better compatibility.

Wouldn't this do it, then (untested)? It would be simple to add "bin" as well. The code should probably be deduplicated, though.

diff --git c/crates/rust-analyzer/src/cli/load_cargo.rs i/crates/rust-analyzer/src/cli/load_cargo.rs
index 5dba545b8..c9faeaa6b 100644
--- c/crates/rust-analyzer/src/cli/load_cargo.rs
+++ i/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -69,10 +69,13 @@ pub fn load_workspace(
             if let Some(sysroot) = sysroot.as_ref() {
                 let standalone_server_name =
                     format!("rust-analyzer-proc-macro-srv{}", std::env::consts::EXE_SUFFIX);
-                let server_path = sysroot.root().join("libexec").join(&standalone_server_name);
-                if std::fs::metadata(&server_path).is_ok() {
-                    path = server_path;
-                    args = vec![];
+                for dir in ["libexec", "lib"] {
+                    let server_path = sysroot.root().join(dir).join(&standalone_server_name);
+                    if std::fs::metadata(&server_path).is_ok() {
+                        path = server_path;
+                        args = vec![];
+                        break;
+                    }
                 }
             }
         }
diff --git c/crates/rust-analyzer/src/reload.rs i/crates/rust-analyzer/src/reload.rs
index aa0510a4e..d7cf69c3a 100644
--- c/crates/rust-analyzer/src/reload.rs
+++ i/crates/rust-analyzer/src/reload.rs
@@ -327,21 +327,22 @@ impl GlobalState {
                             | ProjectWorkspace::Json { sysroot, .. } = ws
                             {
                                 if let Some(sysroot) = sysroot.as_ref() {
-                                    let server_path = sysroot
-                                        .root()
-                                        .join("libexec")
-                                        .join(&standalone_server_name);
-                                    if std::fs::metadata(&server_path).is_ok() {
-                                        tracing::debug!(
-                                            "Sysroot proc-macro server exists at {}",
-                                            server_path.display()
-                                        );
-                                        sysroot_server = Some(server_path);
-                                    } else {
-                                        tracing::debug!(
-                                            "Sysroot proc-macro server does not exist at {}",
-                                            server_path.display()
-                                        );
+                                    for dir in ["libexec", "lib"] {
+                                        let server_path =
+                                            sysroot.root().join(dir).join(&standalone_server_name);
+                                        if std::fs::metadata(&server_path).is_ok() {
+                                            tracing::debug!(
+                                                "Sysroot proc-macro server exists at {}",
+                                                server_path.display()
+                                            );
+                                            sysroot_server = Some(server_path);
+                                            break;
+                                        } else {
+                                            tracing::debug!(
+                                                "Sysroot proc-macro server does not exist at {}",
+                                                server_path.display()
+                                            );
+                                        }
                                     }
                                 }
                             }

archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Nov 15, 2022
…ib and libexec

Thanks to @heftig for the new patch and Akatsuki Rui (akiirui) for their testing.

Fixes FS#76568
Upstream issue: rust-lang/rust-analyzer#13589


git-svn-id: file:///srv/repos/svn-community/svn@1348996 9fca08f4-af9d-4005-b8df-a31f2cc04f65
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Nov 15, 2022
…ib and libexec

Thanks to @heftig for the new patch and Akatsuki Rui (akiirui) for their testing.

Fixes FS#76568
Upstream issue: rust-lang/rust-analyzer#13589

git-svn-id: file:///srv/repos/svn-community/svn@1348996 9fca08f4-af9d-4005-b8df-a31f2cc04f65
@polyzen
Copy link
Contributor

polyzen commented Nov 15, 2022

Applied @heftig's patch to support both lib and libexec:
archlinux/svntogit-community@e60584b

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

Successfully merging a pull request may close this issue.

7 participants