rust-lang / rust-lang/rust-analyzer

proc-macro server exited with signal: 6 (SIGABRT) on MacOS when LTO is enabled

Open
#19,135 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

uname -a
Darwin Davids-Mac-mini-398.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 arm64

rust-analyzer --version
rust-analyzer 1.84.1 (e71f9a9a 2025-01-27)

rustc --version
rustc 1.84.1 (e71f9a9a9 2025-01-27)

See example demonstrating the issue: https://github.com/dave-fl/ra_ex_project

if LTO is enabled on MacOS (and possibly other operating systems). Then Rust Analyzer will SIGABRT.

Using rustflags = ["-C", "linker-plugin-lto", "-C", "link-arg=-fuse-ld=lld"] is problematic while rustflags = ["-C", "link-arg=-fuse-ld=lld"] is fine.

See example repo. If I turn off LTO via config.toml then there is no issue.

This is my linker script which is not in the repo.

#!/bin/sh
# wrapper to adapt ld64 to gnu style arguments
declare -a args=()
for arg in "$@"
do
   if [[ $arg == "-Wl,"* ]]; then
       IFS=',' read -r -a options <<< "${arg#-Wl,}"
       for option in "${options[@]}"
       do
           if [[ $option == "-plugin="* ]] || [[ $option == "-plugin-opt=mcpu="* ]]; then
               :
           elif [[ $option == "-plugin-opt=O"* ]]; then
               args[${#args[@]}]="-Wl,--lto-CGO${option#-plugin-opt=O}"
           else
               args[${#args[@]}]="-Wl,$option"
           fi
       done
   else
       args[${#args[@]}]="$arg"
   fi
done

exec ${CXX:-/opt/homebrew/opt/llvm/bin/clang++} "${args[@]}"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked ra_ex_project on macOS and reproduce the failure using rustflags with linker-plugin-lto, then compare it with the configuration that only uses -fuse-ld=lld. Inspect the proc-macro server path involved in the SIGABRT; done means the LTO configuration no longer aborts while the non-LTO behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.