[llvm-bugs] [Bug 36552] New: Regression: "fatal error: error in backend: invalid llvm.linker.options" when using clang-cl PCH flags with --target flag

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 28 11:58:05 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36552

            Bug ID: 36552
           Summary: Regression: "fatal error: error in backend: invalid
                    llvm.linker.options" when using clang-cl PCH flags
                    with --target flag
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org

I have this test locally at tools/clang/test/Driver/cl-pch-build.c:

$ cat ../llvm-rw/tools/clang/test/Driver/cl-pch-build.c 
// Note: %s and %S must be preceded by --, otherwise it may be interpreted as a
// command-line option, e.g. on Mac where %s is commonly under /Users.

// REQUIRES: x86-registered-target
// Regression test for PR30195.
// RUN: %clang_cl -Werror --target=x86_64 /Yc%S/Inputs/pchfile.h
/FI%S/Inputs/pchfile.h /c /Fo%t.obj /Fp%t.pch -- %s


It used to pass, but today it fails:

$ bin/llvm-lit ../llvm-rw/tools/clang/test/Driver/cl-pch-build.c -v -v
llvm-lit:
/usr/local/google/home/thakis/src/llvm-rw/utils/lit/lit/llvm/config.py:334:
note: using clang: /usr/local/google/home/thakis/src/llvm-build-goma/bin/clang
-- Testing: 1 tests, 1 threads --
FAIL: Clang :: Driver/cl-pch-build.c (1 of 1)
******************** TEST 'Clang :: Driver/cl-pch-build.c' FAILED
********************
Script:
--
/usr/local/google/home/thakis/src/llvm-build-goma/bin/clang --driver-mode=cl
-Werror --target=x86_64
/Yc/usr/local/google/home/thakis/src/llvm-rw/tools/clang/test/Driver/Inputs/pchfile.h
/FI/usr/local/google/home/thakis/src/llvm-rw/tools/clang/test/Driver/Inputs/pchfile.h
/c
/Fo/usr/local/google/home/thakis/src/llvm-build-goma/tools/clang/test/Driver/Output/cl-pch-build.c.tmp.obj
/Fp/usr/local/google/home/thakis/src/llvm-build-goma/tools/clang/test/Driver/Output/cl-pch-build.c.tmp.pch
--
/usr/local/google/home/thakis/src/llvm-rw/tools/clang/test/Driver/cl-pch-build.c
--
Exit Code: 70

Command Output (stderr):
--
fatal error: error in backend: invalid llvm.linker.options


I added a debug printf:
$ svn diff
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp        (revision 326353)
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp        (working copy)
@@ -102,6 +102,9 @@
     Streamer.SwitchSection(S);

     for (const auto &Operand : LinkerOptions->operands()) {
+      for (const auto &Option : cast<MDNode>(Operand)->operands()) {
+        fprintf(stderr, "foo %s\n",
cast<MDString>(Option)->getString().str().c_str());
+      }
       if (cast<MDNode>(Operand)->getNumOperands() != 2)
         report_fatal_error("invalid llvm.linker.options");
       for (const auto &Option : cast<MDNode>(Operand)->operands()) {

It prints:

foo -llibcmt


I don't know if this has been broken since the assert was added in
https://reviews.llvm.org/D40849. Without the --target= flag, the test passes
(which is the form used in test/Driver/cl-pch.c).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180228/268dbe48/attachment-0001.html>


More information about the llvm-bugs mailing list