Skip to content

Build is broken when optimization is turned off #836

@marijnh

Description

@marijnh
Contributor

While building stage1/lib/libstd.so:

rustc: /home/marijn/prog/llvm/include/llvm/Support/Casting.h:194: typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X = llvm::FrameIndexSDNode, Y = llvm::SDNode*, typename llvm::cast_retty<To, From>::ret_type = llvm::FrameIndexSDNode*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Stack dump:
0.  Running pass 'Function Pass Manager' on module 'rust_out'.
1.  Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN3int6to_strE'
Aborted
make: *** [stage1/lib/libstd.so] Error 134
make: Target `all' not remade because of errors.
make: Leaving directory `/home/marijn/src/rust'

Activity

msullivan

msullivan commented on Aug 18, 2011

@msullivan
Contributor

Bisecting.

msullivan

msullivan commented on Aug 18, 2011

@msullivan
Contributor

117d21d is the commit that broke it.

pcwalton

pcwalton commented on Aug 18, 2011

@pcwalton
Contributor

Taking this; I believe I have an LLVM fix for it.

pcwalton

pcwalton commented on Aug 19, 2011

@pcwalton
Contributor

LLVM patch:

Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp    (revision 137913)
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp    (working copy)
@@ -4957,11 +4957,16 @@
   }
   case Intrinsic::gcroot:
     if (GFI) {
-      const Value *Alloca = I.getArgOperand(0);
-      const Constant *TypeMap = cast<Constant>(I.getArgOperand(1));
+      const Value *Alloca = I.getArgOperand(0)->stripPointerCasts();
+      assert(isa<AllocaInst>(Alloca) && "First argument to gcroot() must be "
+             "an alloca or a bitcast of one!");

+      const Value *TypeMap = I.getArgOperand(1);
+      assert(isa<Constant>(TypeMap) && "Second argument to gcroot() must be "
+             "a constant!");
+
       FrameIndexSDNode *FI = cast<FrameIndexSDNode>(getValue(Alloca).getNode());
-      GFI->addStackRoot(FI->getIndex(), TypeMap);
+      GFI->addStackRoot(FI->getIndex(), cast<Constant>(TypeMap));
     }
     return 0;
   case Intrinsic::gcread:
pcwalton

pcwalton commented on Aug 21, 2011

@pcwalton
Contributor

Fix has been sent to espindola; leaving this open until it's upstreamed, but this isn't breaking the build any longer.

marijnh

marijnh commented on Aug 30, 2011

@marijnh
ContributorAuthor

This seems to have landed (I removed the patch when updating LLVM this week, and I can still build without optimize)

added a commit that references this issue on Apr 10, 2015
added a commit that references this issue on Dec 12, 2017
added a commit that references this issue on Oct 26, 2020
c74b306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @marijnh@pcwalton@msullivan

      Issue actions

        Build is broken when optimization is turned off · Issue #836 · rust-lang/rust