[PATCH] D134165: [llvm] prefix linker flag on non-MSVC compilers with `-Wl,`

Ashay Rane via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 19 13:48:04 PDT 2022


ashay-github added a comment.

> just to make sure I'm understanding the issue, this occurs when building with clang, not clang-cl correct?

@beanz It looks like the problem exists in both `clang` and `clang-cl`.

  >clang-cl build\tools\lto\LTO.def
  build\tools\lto\LTO.def : fatal error LNK1107: invalid or corrupt file: cannot read at 0x9DC
  clang-cl: error: linker command failed with exit code 1107 (use -v to see invocation)
  
  >clang build\tools\lto\LTO.def
  build\tools\lto\LTO.def : fatal error LNK1107: invalid or corrupt file: cannot read at 0x9DC
  clang: error: linker command failed with exit code 1107 (use -v to see invocation)
  
  >cl build\tools\lto\LTO.def
  Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  Microsoft (R) Incremental Linker Version 14.33.31630.0
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  /out:LTO.exe
  /def:build\tools\lto\LTO.def

Thanks for the tip about the clang-cl driver, I'll look there.



================
Comment at: llvm/cmake/modules/AddLLVM.cmake:133
       set(export_file_linker_flag "/DEF:\"${export_file_linker_flag}\"")
+    elseif(WIN32)
+      # If we're compiling on Windows and the compiler is not Visual Studio,
----------------
beanz wrote:
> Does the same issue occur if you use compilers other than clang? I'm wondering if this change should be clang-specific.
Since both gcc and clang use `-Wl` to pass flags to the linker, I imagine that this problem is not clang specific. Unfortunately, I don't have gcc/MinGW setup to try this out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134165/new/

https://reviews.llvm.org/D134165



More information about the llvm-commits mailing list