-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
LLVM 21 bump broke defmt strings containing escaped double-quotes #146065
Copy link
Copy link
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesIssue expected to be fixed by the next major LLVM upgrade, or backported fixesregression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Milestone
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesIssue expected to be fixed by the next major LLVM upgrade, or backported fixesregression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The
defmtcrate does deferred formatting. It does this by turningdefmt::info!("Hello!")into astatic SYMBOL: u8with the name{"package":"firmware","tag":"defmt_info","data":"Hello","disambiguator":"16563080428635778541","crate_name":"log"}. Yes, we emit symbol names that are JSON - the GNU linker for our targets of interest doesn't mind.However, as of nightly rust, this is broken.
A
cargo bisect-rustclays the blame at dc0bae1db725fbba8524f195f74f680995fd549e, which is the bump to LLVM 21.In our CI runs, we use to get a symbol called:
{"package":"firmware","tag":"defmt_info","data":"unsafe extern \"C\" fn(i32, i32, i32, i32, i32) -> i32: {}","disambiguator":"16563080428635778541","crate_name":"log"}we now get a symbol called:
{"package":"firmware","tag":"defmt_info","data":"unsafe extern "C" fn(i32, i32, i32, i32, i32) -> i32: {}","disambiguator":"16563080428635778541","crate_name":"log"}Note that the backslashes have gone from around the
extern \"C\"part. This causes the JSON to be invalid. The line of source code that generated this symbol was:On stable, this expands to:
On nightly this expands to the same code, so it's something inside LLVM that has changed how it handles escapes in symbol names.
Is this an expected side-effect? Is this something we can fix, or were we just holding it wrong?
Not fixing this issue will break anyone using
defmtto print strings containing escaped double-quotes, which is going to hurt.This was originally a Zulip thread at #t-compiler > defmt is broken in nightly - LLVM symbol escaping changed? @ 💬, but we think it is indeed a bug.