Rust ESP32-S3 build problem: could not compile `xtensa-lx-rt` (lib)

When compiling a Rust project for ESP32-S3 you may encounter the following error:

cargo build --release
   Compiling xtensa-lx-rt v0.16.0
   Compiling esp-hal-common v0.14.1
LLVM ERROR: Global variable 'save_context' has an invalid section specifier '.rwtext': mach-o section specifier requires a segment and section separated by a comma.
error: could not compile `xtensa-lx-rt` (lib)
warning: build failed, waiting for other jobs to finish...
error: invalid instruction mnemonic 'rsr.ccount'
  --> /Users/georgik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xtensa-lx-0.8.0/src/timer.rs:81:20
   |
81 |     unsafe { asm!("rsr.ccount {0}", out(reg) x, options(nostack)) };

While Rust is very helpful with error messages, it’s quite hard to determine what is going wrong.

Basically this problem occurs when you’re building a project for ESP32-S3 which is using Xtensa target and the project is missing the following file: .cargo/config.toml

[target.'cfg(target_arch = "xtensa")']
runner = "espflash flash --monitor"
rustflags = [
  "-C", "link-arg=-Tlinkall.x",
  "-C", "link-arg=-nostartfiles",
]

[build]
target = "xtensa-esp32s3-none-elf"

[unstable]
build-std = [ "core", "alloc" ]