[all-commits] [llvm/llvm-project] 74e4a8: [LinkerWrapper] Fix -fsave-optimization-record def...

Joel E. Denny via All-commits all-commits at lists.llvm.org
Wed Jul 30 07:26:00 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 74e4a8645da91247dc8dc502771c2cc4d46f1f91
      https://github.com/llvm/llvm-project/commit/74e4a8645da91247dc8dc502771c2cc4d46f1f91
  Author: Joel E. Denny <jdenny.ornl at gmail.com>
  Date:   2025-07-30 (Wed, 30 Jul 2025)

  Changed paths:
    M clang/lib/Driver/ToolChains/CommonArgs.cpp
    M clang/test/Driver/linker-wrapper-libs.c
    M clang/test/Driver/linker-wrapper.c
    M clang/test/Driver/lto-dwo.c
    M clang/test/Driver/opt-record.c
    M clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

  Log Message:
  -----------
  [LinkerWrapper] Fix -fsave-optimization-record default file (#149003)

As discussed in PR #145603, the following command seems to fail to
produce a YAML remarks file for offload LTO passes and thus for
kernel-info:

```
clang -O2 -g -fopenmp --offload-arch=native test.c -foffload-lto \
  -Rpass=kernel-info -fsave-optimization-record
```

The problem is that, in clang-linker-wrapper's clang call, clang names
the file based on clang's main output file (from `-o`). That is a
temporary file, so the YAML file becomes a temporary file, which the
user never sees.

This patch:
- Makes clang honor `-dumpdir` for the default YAML remarks file in the
case of LTO.
- Extends clang-linker-wrapper to specify that option to clang.

To demonstrate the appeal of the generality of `-dumpdir` (as opposed to
a one-off `-fsave-optimization-record` solution in
clang-linker-wrapper), this patch also fixes `-gsplit-dwarf`. Without
this patch, when using `-gsplit-dwarf` and later debugging using rocgdb,
the dwo directory for offload is a temporary file, so temporary file
cleanup causes rocgdb to lose debug symbols for offload code.

WARNING: The clang driver passes `-dumpdir` to various clang frontend
calls. For LTO, that was previously being ignored, and now it's not.
That changes some auxiliary file names, as revealed by changes in some
existing tests' expected output: `clang/test/Driver/opt-record.c` and
`clang/test/Driver/lto-dwo.c`. Hopefully this change does not introduce
a backward compatibility issue for users.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list