<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - debugging source and symbols are lost when linking"
   href="https://bugs.llvm.org/show_bug.cgi?id=34910">34910</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>debugging source and symbols are lost when linking
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>COFF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>superjoe30@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is with LLVM/Clang/LLD 5.0.0.


hello.ll
========
; ModuleID = 'hello'
source_filename = "hello"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"

%"[]u8" = type { i8*, i64 }

@link_libc = internal unnamed_addr constant i1 false, align 1
@os = internal unnamed_addr constant i6 15, align 1
@is_windows = internal unnamed_addr constant i1 true, align 1
@want_start_symbol = internal unnamed_addr constant i1 false, align 1
@want_WinMainCRTStartup = internal unnamed_addr constant i1 true, align 1
@user_main_fn = internal unnamed_addr global i16 ()* null, align 8
@0 = internal unnamed_addr constant i8* getelementptr inbounds ([24 x i8], [24
x i8]* @1, i64 0, i64 0), align 8
@1 = internal unnamed_addr constant [24 x i8] c"reached unreachable code",
align 1
@2 = internal unnamed_addr constant { i8*, i64 } { i8* getelementptr inbounds
([24 x i8], [24 x i8]* @1, i64 0, i64 0), i64 24 }, align 8
@3 = internal unnamed_addr constant i16 ()** @user_main_fn, align 8

; Function Attrs: nobuiltin noreturn nounwind
define internal fastcc void @panic(%"[]u8"* byval nonnull readonly)
unnamed_addr #0 !dbg !62 {
Entry:
  call void @llvm.dbg.declare(metadata %"[]u8"* %0, metadata !76, metadata
!77), !dbg !78
  br label %WhileCond, !dbg !79

WhileCond:                                        ; preds = %WhileCond, %Entry
  br label %WhileCond, !dbg !79
}

; Function Attrs: naked nobuiltin noreturn nounwind
define internal void @_start.0() unnamed_addr #1 !dbg !82 {
Entry:
  call fastcc void @panic(%"[]u8"* bitcast ({ i8*, i64 }* @2 to %"[]u8"*)),
!dbg !86
  unreachable, !dbg !86
}

; Function Attrs: nobuiltin noinline noreturn nounwind alignstack(16)
define void @WinMainCRTStartup() #2 !dbg !89 {
Entry:
  %0 = alloca i16, align 2
  store i16 ()* @main.0.1, i16 ()** @user_main_fn, align 8, !dbg !90
  %1 = call fastcc i16 @main.0.1(), !dbg !92
  store i16 %1, i16* %0, align 2, !dbg !92
  %2 = load i16, i16* %0, align 2, !dbg !93
  %3 = icmp ne i16 %2, 0, !dbg !93
  br i1 %3, label %UnwrapErrError, label %UnwrapErrOk, !dbg !93

UnwrapErrError:                                   ; preds = %Entry
  call void @ExitProcess(i32 1), !dbg !94
  unreachable, !dbg !94

UnwrapErrOk:                                      ; preds = %Entry
  %4 = load i16, i16* %0, align 2, !dbg !93
  br label %UnwrapErrEnd, !dbg !93

UnwrapErrEnd:                                     ; preds = %UnwrapErrOk
  call void @ExitProcess(i32 0), !dbg !95
  unreachable, !dbg !95
}

; Function Attrs: nobuiltin nounwind
define internal i32 @main.0(i32, i8** nonnull, i8** nonnull) unnamed_addr #3
!dbg !96 {
Entry:
  %c_argc = alloca i32, align 4
  %c_argv = alloca i8**, align 8
  %c_envp = alloca i8**, align 8
  store i32 %0, i32* %c_argc, align 4
  call void @llvm.dbg.declare(metadata i32* %c_argc, metadata !103, metadata
!77), !dbg !108
  store i8** %1, i8*** %c_argv, align 8
  call void @llvm.dbg.declare(metadata i8*** %c_argv, metadata !104, metadata
!77), !dbg !109
  store i8** %2, i8*** %c_envp, align 8
  call void @llvm.dbg.declare(metadata i8*** %c_envp, metadata !106, metadata
!77), !dbg !110
  call fastcc void @panic(%"[]u8"* bitcast ({ i8*, i64 }* @2 to %"[]u8"*)),
!dbg !111
  unreachable, !dbg !111
}

; Function Attrs: nobuiltin nounwind
define internal fastcc i16 @main.0.1() unnamed_addr #3 !dbg !115 {
Entry:
  call void @llvm.debugtrap(), !dbg !119
  ret i16 0, !dbg !121
}

; Function Attrs: nobuiltin noreturn nounwind
declare void @ExitProcess(i32) #0

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata) #4

; Function Attrs: nounwind
declare void @llvm.debugtrap() #5

; Function Attrs: nounwind
declare void @llvm.stackprotector(i8*, i8**) #5

attributes #0 = { nobuiltin noreturn nounwind "no-frame-pointer-elim"="true"
"no-frame-pointer-elim-non-leaf" }
attributes #1 = { naked nobuiltin noreturn nounwind
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }
attributes #2 = { nobuiltin noinline noreturn nounwind alignstack=16
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }
attributes #3 = { nobuiltin nounwind "no-frame-pointer-elim"="true"
"no-frame-pointer-elim-non-leaf" }
attributes #4 = { nounwind readnone speculatable }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}

!0 = !{i32 2, !"CodeView", i32 1}
!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "zig
0.0.0.15635747", isOptimized: false, runtimeVersion: 0, emissionKind:
FullDebug, enums: !3, globals: !47)
!2 = !DIFile(filename: "hello", directory: ".")
!3 = !{!4, !40}
!4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Os", scope: !5,
file: !5, line: 1, baseType: !6, size: 8, align: 8, elements: !7)
!5 = !DIFile(filename: "builtin.zig", directory:
"C:\5Cmsys64\5Chome\5Candy\5Czig\5Cbuild-msvc\5Czig-cache")
!6 = !DIBasicType(name: "u6", size: 8, encoding: DW_ATE_unsigned)
!7 = !{!8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22,
!23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38,
!39}
!8 = !DIEnumerator(name: "freestanding", value: 0)
!9 = !DIEnumerator(name: "ananas", value: 1)
!10 = !DIEnumerator(name: "cloudabi", value: 2)
!11 = !DIEnumerator(name: "darwin", value: 3)
!12 = !DIEnumerator(name: "dragonfly", value: 4)
!13 = !DIEnumerator(name: "freebsd", value: 5)
!14 = !DIEnumerator(name: "fuchsia", value: 6)
!15 = !DIEnumerator(name: "ios", value: 7)
!16 = !DIEnumerator(name: "kfreebsd", value: 8)
!17 = !DIEnumerator(name: "linux", value: 9)
!18 = !DIEnumerator(name: "lv2", value: 10)
!19 = !DIEnumerator(name: "macosx", value: 11)
!20 = !DIEnumerator(name: "netbsd", value: 12)
!21 = !DIEnumerator(name: "openbsd", value: 13)
!22 = !DIEnumerator(name: "solaris", value: 14)
!23 = !DIEnumerator(name: "windows", value: 15)
!24 = !DIEnumerator(name: "haiku", value: 16)
!25 = !DIEnumerator(name: "minix", value: 17)
!26 = !DIEnumerator(name: "rtems", value: 18)
!27 = !DIEnumerator(name: "nacl", value: 19)
!28 = !DIEnumerator(name: "cnk", value: 20)
!29 = !DIEnumerator(name: "bitrig", value: 21)
!30 = !DIEnumerator(name: "aix", value: 22)
!31 = !DIEnumerator(name: "cuda", value: 23)
!32 = !DIEnumerator(name: "nvcl", value: 24)
!33 = !DIEnumerator(name: "amdhsa", value: 25)
!34 = !DIEnumerator(name: "ps4", value: 26)
!35 = !DIEnumerator(name: "elfiamcu", value: 27)
!36 = !DIEnumerator(name: "tvos", value: 28)
!37 = !DIEnumerator(name: "watchos", value: 29)
!38 = !DIEnumerator(name: "mesa3d", value: 30)
!39 = !DIEnumerator(name: "contiki", value: 31)
!40 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "GlobalLinkage",
scope: !5, file: !5, line: 138, baseType: !41, size: 8, align: 8, elements:
!42)
!41 = !DIBasicType(name: "u3", size: 8, encoding: DW_ATE_unsigned)
!42 = !{!43, !44, !45, !46}
!43 = !DIEnumerator(name: "Internal", value: 0)
!44 = !DIEnumerator(name: "Strong", value: 1)
!45 = !DIEnumerator(name: "Weak", value: 2)
!46 = !DIEnumerator(name: "LinkOnce", value: 3)
!47 = !{!48, !51, !54, !56, !58, !60}
!48 = !DIGlobalVariableExpression(var: !49)
!49 = distinct !DIGlobalVariable(name: "link_libc", linkageName: "link_libc",
scope: !5, file: !5, line: 200, type: !50, isLocal: true, isDefinition: true)
!50 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
!51 = !DIGlobalVariableExpression(var: !52)
!52 = distinct !DIGlobalVariable(name: "want_main_symbol", linkageName:
"want_main_symbol", scope: !53, file: !53, line: 9, type: !50, isLocal: true,
isDefinition: true)
!53 = !DIFile(filename: "bootstrap.zig", directory:
"C:\5Cmsys64\5Chome\5Candy\5Czig\5Cbuild-msvc\5Clib\5Czig\5Cstd\5Cspecial")
!54 = !DIGlobalVariableExpression(var: !55)
!55 = distinct !DIGlobalVariable(name: "os", linkageName: "os", scope: !5,
file: !5, line: 195, type: !4, isLocal: true, isDefinition: true)
!56 = !DIGlobalVariableExpression(var: !57)
!57 = distinct !DIGlobalVariable(name: "is_windows", linkageName: "is_windows",
scope: !53, file: !53, line: 8, type: !50, isLocal: true, isDefinition: true)
!58 = !DIGlobalVariableExpression(var: !59)
!59 = distinct !DIGlobalVariable(name: "want_start_symbol", linkageName:
"want_start_symbol", scope: !53, file: !53, line: 10, type: !50, isLocal: true,
isDefinition: true)
!60 = !DIGlobalVariableExpression(var: !61)
!61 = distinct !DIGlobalVariable(name: "want_WinMainCRTStartup", linkageName:
"want_WinMainCRTStartup", scope: !53, file: !53, line: 11, type: !50, isLocal:
true, isDefinition: true)
!62 = distinct !DISubprogram(name: "panic", scope: !63, file: !63, line: 5,
type: !64, isLocal: true, isDefinition: true, scopeLine: 5, isOptimized: false,
unit: !1, variables: !75)
!63 = !DIFile(filename: "hello.zig", directory:
"C:\5Cmsys64\5Chome\5Candy\5Czig\5Cbuild-msvc")
!64 = !DISubroutineType(types: !65)
!65 = !{!66, !67}
!66 = !DIBasicType(name: "void", encoding: DW_ATE_unsigned)
!67 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&[]const u8", baseType:
!68, size: 64, align: 64)
!68 = !DICompositeType(tag: DW_TAG_structure_type, name: "[]u8", size: 128,
align: 64, elements: !69)
!69 = !{!70, !73}
!70 = !DIDerivedType(tag: DW_TAG_member, name: "ptr", scope: !68, baseType:
!71, size: 64, align: 64)
!71 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&u8", baseType: !72,
size: 64, align: 64)
!72 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned_char)
!73 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !68, baseType:
!74, size: 64, align: 64, offset: 64)
!74 = !DIBasicType(name: "usize", size: 64, encoding: DW_ATE_unsigned)
!75 = !{!76}
!76 = !DILocalVariable(name: "msg", arg: 1, scope: !62, file: !63, line: 5,
type: !68)
!77 = !DIExpression()
!78 = !DILocation(line: 5, column: 14, scope: !62)
!79 = !DILocation(line: 5, column: 45, scope: !80)
!80 = distinct !DILexicalBlock(scope: !81, file: !63, line: 5, column: 43)
!81 = distinct !DILexicalBlock(scope: !62, file: !63, line: 5, column: 14)
!82 = distinct !DISubprogram(name: "_start", scope: !53, file: !53, line: 16,
type: !83, isLocal: true, isDefinition: true, scopeLine: 16, isOptimized:
false, unit: !1, variables: !85)
!83 = !DISubroutineType(types: !84)
!84 = !{!66}
!85 = !{}
!86 = !DILocation(line: 19, column: 9, scope: !87)
!87 = distinct !DILexicalBlock(scope: !88, file: !53, line: 17, column: 29)
!88 = distinct !DILexicalBlock(scope: !82, file: !53, line: 16, column: 40)
!89 = distinct !DISubprogram(name: "WinMainCRTStartup", scope: !53, file: !53,
line: 34, type: !83, isLocal: false, isDefinition: true, scopeLine: 34,
isOptimized: false, unit: !1, variables: !85)
!90 = !DILocation(line: 41, column: 28, scope: !91)
!91 = distinct !DILexicalBlock(scope: !89, file: !53, line: 34, column: 43)
!92 = !DILocation(line: 42, column: 14, scope: !91)
!93 = !DILocation(line: 42, column: 17, scope: !91)
!94 = !DILocation(line: 42, column: 46, scope: !91)
!95 = !DILocation(line: 43, column: 31, scope: !91)
!96 = distinct !DISubprogram(name: "main", scope: !53, file: !53, line: 66,
type: !97, isLocal: true, isDefinition: true, scopeLine: 66, isOptimized:
false, unit: !1, variables: !102)
!97 = !DISubroutineType(types: !98)
!98 = !{!99, !99, !100, !101}
!99 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed)
!100 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&&u8", baseType: !71,
size: 64, align: 64)
!101 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&?&u8", baseType: !71,
size: 64, align: 64)
!102 = !{!103, !104, !106}
!103 = !DILocalVariable(name: "c_argc", arg: 1, scope: !96, file: !53, line:
66, type: !99)
!104 = !DILocalVariable(name: "c_argv", arg: 2, scope: !105, file: !53, line:
66, type: !100)
!105 = distinct !DILexicalBlock(scope: !96, file: !53, line: 66, column: 16)
!106 = !DILocalVariable(name: "c_envp", arg: 3, scope: !107, file: !53, line:
66, type: !101)
!107 = distinct !DILexicalBlock(scope: !105, file: !53, line: 66, column: 29)
!108 = !DILocation(line: 66, column: 16, scope: !96)
!109 = !DILocation(line: 66, column: 29, scope: !105)
!110 = !DILocation(line: 66, column: 43, scope: !107)
!111 = !DILocation(line: 69, column: 9, scope: !112)
!112 = distinct !DILexicalBlock(scope: !113, file: !53, line: 67, column: 28)
!113 = distinct !DILexicalBlock(scope: !114, file: !53, line: 66, column: 65)
!114 = distinct !DILexicalBlock(scope: !107, file: !53, line: 66, column: 43)
!115 = distinct !DISubprogram(name: "main", scope: !63, file: !63, type: !116,
isLocal: true, isDefinition: true, isOptimized: false, unit: !1, variables:
!85)
!116 = !DISubroutineType(types: !117)
!117 = !{!118}
!118 = !DIBasicType(name: "u16", size: 16, encoding: DW_ATE_unsigned)
!119 = !DILocation(line: 2, column: 5, scope: !120)
!120 = distinct !DILexicalBlock(scope: !115, file: !63, line: 1, column: 24)
!121 = !DILocation(line: 1, column: 24, scope: !115)
========


kernel32.def:
=============
LIBRARY kernel32
EXPORTS
ExitProcess
=============

lld -DEF:kernel32.def -OUT:kernel32.lib
clang -o hello.obj -c hello.ll
lld -NOLOGO -DEBUG -MACHINE:X64 /SUBSYSTEM:console -OUT:hello.exe -NODEFAULTLIB
-ENTRY:WinMainCRTStartup hello.obj kernel32.lib

 * Now run hello.exe. It prompts you to debug with MSVC, do so. The callstack
is missing frames,
   there are no symbols, and no source code.

link.exe /NOLOGO /DEBUG /MACHINE:X64 /SUBSYSTEM:console /OUT:hello.exe
/NODEFAULTLIB /ENTRY:WinMainCRTStartup hello.obj kernel32.lib

 * Now run hello.exe.

 It is still missing callstack frames, but there are symbols and source code.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>