about summary refs log tree commit diff
path: root/tests/ui/lto
diff options
context:
space:
mode:
authorWesley Wiser <wwiser@gmail.com>2025-02-06 04:50:17 +0000
committerWesley Wiser <wwiser@gmail.com>2025-02-08 16:33:36 +0000
commitbbc40e78226c2b4a84b44c717b5ad0983e29944c (patch)
tree338e50b1a8b7be8cee2ac8b613b986ac6d8f71a2 /tests/ui/lto
parentcd3dd5bd230b1d98ed46e3609a64865eb1d5fc58 (diff)
downloadrust-bbc40e78226c2b4a84b44c717b5ad0983e29944c.tar.gz
rust-bbc40e78226c2b4a84b44c717b5ad0983e29944c.zip
Pick the max DWARF version when LTO'ing modules with different versions
Currently, when rustc compiles code with `-Clto` enabled that was built
with different choices for `-Zdwarf-version`, a warning will be
reported. It's very easy to observe this by compiling most anything (eg,
"hello world") and specifying `-Clto -Zdwarf-version=5` since the
standard library is distributed with `-Zdwarf-version=4`.

This behavior isn't actually useful for a few reasons:
- from observation, LLVM chooses to pick the highest DWARF version
  anyway after issuing the warning
- Clang specifies that in this case, the max version should be picked
  without a warning and as a general principle, we want to support
  x-lang LTO with Clang which implies using the same module flag merge
  behaviors
- Debuggers need to be able to handle a variety of versions withing the
  same debugging session as you can easily have some parts of a binary
  (or some dynamic libraries within an application) all compiled with
  different DWARF versions

This commit changes the module flag merge behavior to match Clang and
use the highest version of DWARF. It also adds a test to ensure this
behavior is respected in the case of two crates being LTO'd together and
updates the test added in the previous commit to ensure no warning is
printed.
Diffstat (limited to 'tests/ui/lto')
-rw-r--r--tests/ui/lto/dwarf-mixed-versions-lto.stderr4
1 files changed, 0 insertions, 4 deletions
diff --git a/tests/ui/lto/dwarf-mixed-versions-lto.stderr b/tests/ui/lto/dwarf-mixed-versions-lto.stderr
deleted file mode 100644
index 15988383c29..00000000000
--- a/tests/ui/lto/dwarf-mixed-versions-lto.stderr
+++ /dev/null
@@ -1,4 +0,0 @@
-warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 4' from  with 'i32 5' from dwarf_mixed_versions_lto.7f4a44b55cf2f174-cgu.0)
-
-warning: 1 warning emitted
-