Commit Graph

1122 Commits

Author SHA1 Message Date
Saleem Abdulrasool
7514adf66a Driver: introduce new -libc option for Windows
On Windows, there are multiple variants of the C runtime that must be
explicitly specified and consistently used from the runtime to the
application.  The new `-libc` option allows us to control the linking
phase by correctly embedding the requested library to be linked.  It is
made into a required parameter on Windows and will add in the
appropriate flags for the imported C headers as well.  This ensures that
the C library is not incorrectly linked.
2019-05-16 21:01:47 -07:00
Adrian Prantl
e63caa4d45 Debug Info: Mark variables without source location as artificial.
rdar://problem/50349713
2019-05-01 15:18:15 -07:00
Nathan Lanza
f837a9eeef Fix bug where inlined scopes where being inlined twice for codeview
A workaround in codeview debuginfo generation was to declare a condfail
instruction as inlined to avoid using 0 as an artificial line location.

However, this was done without accounting for scopes that were already
legitimately inlined. So we'd end up with a condfail inlined from
function B into function A and then the IRGen for the condfail was
being given a debugloc claiming to have been inlined again. This was
causing a sitaution where we'd have debug info forfunctionA owning an
instruction which claimed it was owned by a different function.

Fix this by first checking if the `LastScope` was already inlined and,
if so, just used that scope instead.
2019-04-23 12:40:48 -07:00
adrian-prantl
f75dea49df Merge pull request #23910 from adrian-prantl/49751363
Record parseable interface imports in the debug info.
2019-04-19 14:23:57 -07:00
Erik Eckstein
b8c226cb08 DebugInfo: fix debugging on SIL level
The fix is to set the DebugCompilationDir when -gsil is used.
Otherwise no debug info is generated if the source file name does not contain a path.

rdar://problem/49796695
2019-04-12 16:12:17 -07:00
Adrian Prantl
8d03cb7a61 Record parseable interface imports in the debug info.
When a Swift module built with debug info imports a library without
debug info from a textual interface, the textual interface is
necessary to reconstruct types defined in the library's interface.  By
recording the Swift interface files in DWARF dsymutil can collect them
and LLDB can find them.

rdar://problem/49751363
2019-04-11 14:50:07 -07:00
swift-ci
8fc305c03e Merge pull request #23779 from adrian-prantl/48827784 2019-04-04 11:09:11 -07:00
Saleem Abdulrasool
1b812a2b12 test: make DebugInfo.debug_prefix_map pass on Windows
The separator that is inserted is the native type, so permit both types
of path separators.
2019-04-04 09:07:46 -07:00
Adrian Prantl
4a23512068 Add an option to disable DWARF skeleton CU breadcrumbs for Clang
module imports. This is useful when building redistributable static
archives, since any pointers into the CLang module cache won't be
portable.

When using this option the Clang type fallback path in LLDB will be
less useful since DWARF type information from those modules will not
be available unless another object file compiled without the option
imported the same modules.

rdar://problem/48827784
2019-04-03 15:45:11 -07:00
swift-ci
a533081226 Merge pull request #23628 from DavidGoldman/master 2019-04-03 11:07:39 -07:00
Adrian Prantl
b8de883ca3 Remove the -resilience-bypass flag and functionality.
LLDB no longer depends on it.

rdar://problem/48018240
2019-03-29 13:56:17 -07:00
David Goldman
3b2c5a9703 Swap to use %target-swiftc_driver for test 2019-03-29 10:39:43 -04:00
David Goldman
7b3db6f9ef Add test 2019-03-28 15:32:58 -04:00
adrian-prantl
d4149db878 Merge pull request #23425 from adrian-prantl/48409386
Remove Resilience workarounds and describe fixed-size global reslient
2019-03-28 08:25:02 -07:00
Adrian Prantl
0b8fc3d405 Remove Resilience workarounds and describe fixed-size global resilient
variables in DWARF.

rdar://problem/48409386
2019-03-27 10:51:16 -07:00
Saleem Abdulrasool
d3f9410c3b test: make DebugInfo.macro pass on Windows
The path separator on Windows is \ which is encoded as \5C.  Account for
this in the test.
2019-03-27 09:32:32 -07:00
Saleem Abdulrasool
a597038a66 test: loosen restrictions on DebugInfo test
This test does not require ObjectiveC interop.  Enable the test
globally.
2019-03-26 19:18:54 -07:00
Adrian Prantl
6a412bd2f5 Debug Info: Fix a bug when decoding the source file for a Clang Decl
that was defined using a Macro: Use the file of the presumed location,
not of the SourceBuffer.

rdar://problem/49181568
2019-03-26 14:16:11 -07:00
Saleem Abdulrasool
2af7c103a3 DebugInfo: deal with absolute path on Windows
Windows absolute paths are either UNC paths (begin with \\) or are
rooted with a drive letter.  Unfortunately, we cannot conditionalise the
path itself on the OS type.  On Unices // indicates the alternate root
path as per POSIX.  However, Linux does not implement this and // is
treated as /.  Use this to create a path that appears to be absolute on
all the targets.
2019-03-26 11:16:56 -07:00
Saleem Abdulrasool
179be5cb4e DebugInfo: account for quoting on Windows
Windows will quote the temporary path.  Account for it in the test.
2019-03-25 19:29:39 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
adrian-prantl
7035047868 Revert " Stop producing line and file debug information for clang::Decls." 2019-03-05 08:28:17 -08:00
Adrian Prantl
b63ab4534b Stop producing line and file debug information for clang::Decls.
It would be nice to query the clang::SourceManager for the source
location of the clang::Decl in IRGenDebugInfo, but module out-of-date
rebuilds may unload previously loaded clang::Modules and thus also
invalidate source locations pointed to, leading to a use-after-free
here. If this functionality is desired, the source location must be
captured by ClangImporter and stored on the side.

LLDB does not actually make use of this information for non-C++ types
(it is really helpful with debugging the debug info itself, though),
so we can avoid the potential use-after-free and crash by not doing it.

<rdar://problem/48509051>
2019-03-04 14:36:29 -08:00
Slava Pestov
135ce781e2 IRGen: Don't emit debug info for dependent member types
Fixes rdar://40706055
2019-03-02 00:17:15 -05:00
Slava Pestov
d0d5fbdf39 ASTDemangler: Introduce new getTypeDeclForMangling()
This will replace getDeclFromMangledSymbolName().

Progress on <rdar://problem/47819208>.
2019-02-22 16:13:02 -05:00
Adrian Prantl
54af8e461f Debug Info: Encode Archetype names in DWARF
Currently LLDB calls into ide::getDeclFromMangledSymbolName() to get
to this information and we would like to get rid of this call.

rdar://problem/47798056
2019-02-20 16:04:16 -08:00
Mishal Shah
345e9881d1 Merge pull request #22699 from apple/stable-update-5.1
Update Swift:master to work with new stable re-branch from swift-5.1-branch
2019-02-20 12:22:00 -08:00
Jordan Rose
43feb9cbe1 On Apple platforms, use swiftmodule directories for the stdlib (#21797)
This changes the Swift resource directory from looking like

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          x86_64/
            Swift.swiftmodule
            Swift.swiftdoc
            Darwin.swiftmodule
            Darwin.swiftdoc

to

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          Swift.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc
          Darwin.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc

matching the layout we use for multi-architecture swiftmodules
everywhere else (particularly frameworks).

There's no change in this commit to how Linux swiftmodules are
packaged. There's been past interest in going the /opposite/ direction
for Linux, since there's not standard support for fat
(multi-architecture) .so libraries. Moving the .so search path /down/
to an architecture-specific directory on Linux would allow the same
resource directory to be used for both host-compiling and
cross-compiling.

rdar://problem/43545560
2019-02-19 14:47:21 -08:00
Bob Wilson
213efe089c Merge commit '06120c9d9d1a28275a0ecd7466775b1d71716be7' into stable-update-5.1 2019-02-17 10:20:59 -08:00
adrian-prantl
70140a2d0a Merge pull request #22392 from adrian-prantl/DIFiles
Bring the Swift frontend's handling of DIFiles in synch with CFE.
2019-02-14 19:34:40 -08:00
Slava Pestov
68b0d133ad ASTMangler: Fix mangling of type aliases in fully-constrained extensions
We should still mangle these as generic types.

Fixes <rdar://problem/47980487>.
2019-02-13 19:17:27 -05:00
Slava Pestov
d0c7b1547e ASTMangler: Mangle sugared types for the debugger
Fixes <rdar://problem/48004306>.
2019-02-13 19:17:25 -05:00
Slava Pestov
c8effd26b3 Merge pull request #22408 from slavapestov/always-use-legacy-layouts
Always use legacy layouts
2019-02-11 19:10:02 -05:00
Bob Wilson
1b453be929 Update radar number in DebugInfo test
The current radar tracking this disabled test is rdar://problem/47777473
See also the similar change on master-next in
https://github.com/apple/swift/pull/22484
2019-02-08 14:57:51 -08:00
Saleem Abdulrasool
80ce2c3f25 Merge pull request #22387 from xiaobai/fix_modulecache_dbginfo_test
[DebugInfo] Make modulecache test windows-compatible
2019-02-08 14:25:01 -08:00
Bob Wilson
5e16a652b5 master-next: Update DebugInfo tests for llvm r347806
Check for the DISPFlagDefinition flag instead of "isDefinition: true".
2019-02-08 14:22:56 -08:00
Adrian Prantl
0ac9a7dc77 Update tests for upstream LLVM IR assembler changes 2019-02-08 14:22:56 -08:00
Slava Pestov
5680bfde55 IRGen: Always use YAML files for completely fragile class layout
The layouts of resilient value types shipped in the Swift 5 standard library
x and overlays will forever be frozen in time for backward deployment to old
Objective-C runtimes. This PR ensures that even if the layouts of these types
evolve in the future, binaries built to run on the old runtime will continue
to lay out class instances in a manner compatible with Swift 5.

Fixes <rdar://problem/45646886>.
2019-02-08 14:22:00 -05:00
Slava Pestov
b2f0327516 IDE: Remove getTypeFromMangledSymbolname()
There was only one remaining usage other than in testing tools.

Note that when a declaration mangling was passed in, the old entry
point would (try to) return the type of the declaration.

The new entry point no longer has this behavior. I changed the
bridging-header-first test to run lldb-moduleimport-test with
-decl-from-mangled instead of -type-from-mangled-old to preserve
the behavior of the test.

Also, I removed test/DebugInfo/DumpTypeFromMangledName.swift
completely. This test only covered a handful of cases, and a bunch
of them were declaration manglings rather than type manglings.
The new tests in test/TypeDecoder/ are much more comprehensive.
2019-02-08 02:56:05 -05:00
swift-ci
0d6cdd4111 Merge pull request #22456 from adrian-prantl/typdefscopes 2019-02-07 17:29:44 -08:00
Adrian Prantl
711e1f3d14 Debug Info: Emit Clang-imported typedef declarations in the correct scope. 2019-02-07 14:30:07 -08:00
Saleem Abdulrasool
b69bd97ca1 Merge pull request #22397 from compnerd/separate-me-no-more
test: correct paths in DebugInfo/line-directive (NFC)
2019-02-07 12:50:33 -08:00
Adrian Prantl
21f2c3d35b Bring the Swift frontend's handling of DIFiles in synch with CFE.
This applies the same changes from Clang CFE r349065 to the Swift
frontend to unify how filenames, cmpilation directories and absolute
paths in filenames and path remappings are handled.
2019-02-06 09:00:32 -08:00
Saleem Abdulrasool
6fa9000790 Frontend: compare normalised absolute paths for temp
The LLVM API for the temporary paths behaves differently on Windows and Unix.
Windows always returns the absolute path, and on Unix, you get whatever is in
the environment.  Furthermore, windows allows both `\` and `/` as separators.
Normalise the path and make it absolute before doing the comparision to get a
comparable string.
2019-02-05 17:38:46 -08:00
Saleem Abdulrasool
4a2f7c9192 test: correct paths in DebugInfo/line-directive (NFC)
Adjust the test for Windows path separator.
2019-02-05 15:39:25 -08:00
Alex Langford
da79d60ff1 [DebugInfo] Make modulecache test windows-compatible
`file` is not available on windows except through GnuWin32, and that
`file` was identifying the ClangModule as an ACB Archive file instead of
a COFF file.

Instead of using `file`, it is easier and more portable to use
llvm-readobj. I also converted the egrep usage into FileCheck while
adding COFF support.
2019-02-05 14:44:45 -08:00
Adrian Prantl
761e9a0fb2 Cache clang ASTFile information in swift::Module (NFC from the outside).
The loading of additional modules by Sema may trigger an out-of-date
PCM rebuild in the Clang module dependencies of the additional
module. A PCM rebuild causes the ModuleManager to unload previously
loaded ASTFiles. For this reason we must use the cached ASTFile
information here instead of the potentially dangling pointer to the
ASTFile that is stored in the clang::Module object.

This fixes a crash in IRGenDebugInfo when generation DIModule context
chains.

rdar://problem/47600180
2019-02-01 17:34:10 -08:00
Slava Pestov
2b90ad1b4a ASTMangler: Don't optimize protocol names in debugger mangling 2019-01-30 01:28:48 -05:00
Slava Pestov
a14f345c82 lldb-moduleimport-test: Add support for testing Demangle::getTypeForMangling()
The -type-from-mangled flag now uses the new API. The -type-from-mangled-old flag
uses the old API, ide::getTypeFromMangledSymbolname().

For now, just change all existing tests to use the -type-from-mangled-old flag;
I'll be adding new tests for the new API shortly.
2019-01-25 21:44:02 -05:00
Slava Pestov
ed209084f9 AST: Don't use standard substitutions when mangling typealiases
Swift.UnicodeScalar is a typealias now, and for the TypeDecoder
to work correctly we need to mangle it as a typealias and not as
a struct.

However, we still want to demangle old names that used the
substitution, so don't remove it, instead just skip checking for
a substitution when mangling a typealias.

This does not change the ABI; typealiases are only mangled as
part of debug info.
2019-01-25 21:44:02 -05:00