Commit Graph

83 Commits

Author SHA1 Message Date
swift-ci
577b2722f7 Merge pull request #13140 from troughton/windows-cross-compile-fixes 2018-04-18 10:56:06 -07:00
Mike Ash
ce0ef072f7 Merge pull request #15395 from mikeash/remotemirror-hide-reflection-sections
[RemoteMirrors] Interop header fixes and library lookup caching.
2018-03-21 14:43:43 -07:00
Kuba (Brecka) Mracek
84e71b8d7a Change the RemoteMirror API to have extensible data layout callback (#15291)
* Change the RemoteMirror API to have extensible data layout callback

* Use DLQ_Get prefix on DataLayoutQueryType enum values

* Simplify MemoryReaderImpl and synthesize minimalDataLayoutQueryFunction
2018-03-16 14:54:04 -07:00
Mike Ash
ac026128d1 [RemoteMirrors] Provide interop function for converting a raw metadata pointer into a swift_metadata_interop_t.
rdar://problem/37538580
2018-03-08 13:25:09 -05:00
Mike Ash
a2d973dbbd Merge branch 'master' into remotemirror-hide-reflection-sections 2018-03-05 09:48:58 -05:00
Saleem Abdulrasool
fbf646aa2c SwiftRemoteMirror: annotate public interfaces
Mark the public interfaces with the appropriate visibility/dll storage.
This fixes an issue with the Windows build which keeps the
SwiftRemoteMirror.dll out of date constantly as no import library is
created.  That occurs due to the fact that the library does not export
any interfaces.

Take the opportunity to move the public interfaces to protected
visibility on ELF.
2018-03-02 10:28:56 -08:00
Mike Ash
1434fce417 [RemoteMirrors] Switch #ifdef __APPLE__ to #if defined(__APPLE__) && defined(__MACH__) to be more specific about the fact that this code is for MachO. 2018-03-02 11:03:45 -05:00
Mike Ash
83837ccd12 [RemoteMirrors] Clean up some documentation, comments and macros. Add an assert for pointer sizes that don't match what SwiftRemoteMirror.cpp was built with. 2018-03-01 15:39:14 -05:00
Mike Ash
4864e2c4dc [RemoteMirrors] Don't #include the interop header in SwiftRemoteMirror.cpp. 2018-02-28 16:36:31 -05:00
Mike Ash
c059ff2a5c [RemoteMirrors] Fix the ownership check for legacy libraries. The working implementation requires a non-legacy library to be present. Fall back to always saying "yes" otherwise. 2018-02-27 17:06:37 -05:00
Mike Ash
71f1c391ab [RemoteMirrors] Move FreeBytesFunction from an out-parameter on ReadBytesFunction to a function pointer passed in when creating a reflection context. 2018-02-27 12:51:04 -05:00
Mike Ash
7d01c79f57 [RemoteMirrors] Remove a cast from swift_addr_t to uint64_t that didn't compile. 2018-02-27 10:33:39 -05:00
Mike Ash
e4564087af [RemoteMirrors] Move ownsObject into ReflectionContext. 2018-02-27 10:32:32 -05:00
Davide Italiano
7d4b3ae372 [RemoteMirrors] Remove now unused code. 2018-02-26 17:42:29 -08:00
Davide Italiano
ec39bbb08c [RemoteMirrors] Move addImage from stdlib to Reflection. 2018-02-26 17:41:08 -08:00
Mike Ash
6f887475a3 [Reflection] Lots of smaller fixes and API changes due to testing the interop code.
* Remove getPointerSize and getSizeSize functions, replace with a single PointerSize value.
* Remove imageLength parameter from addImage, calculate it internally instead.
* Check remote mirrors libraries' metadata version and reject them if it's too old.
* Shim GetStringLength and GetSymbolAddress for the legacy library since we don't pass the caller's context pointer through directly.
* Actually set the IsLegacy flag in the Library struct.
* Implement ownsObject by tracking each added image's data segment and checking metadata pointers against them. The previous approach didn't work.
2018-02-26 16:56:54 -05:00
Mike Ash
4c7d203574 [Reflection] Implement more interop API calls.
rdar://problem/37538580
2018-02-23 11:47:24 -05:00
Mike Ash
29beaa3126 [Reflection] Track the memory returned from readBytes calls in addImage and free it when destroying the context.
rdar://problem/37538580
2018-02-22 17:17:48 -05:00
Mike Ash
04f2fa8dd7 [Reflection] Minor cleanup of SwiftRemoteMirror files.
rdar://problem/37538580
2018-02-22 12:06:59 -05:00
Mike Ash
1dcdd939ca [Reflection] Implement swift_reflection_addImage which takes care of looking up reflection info on behalf of the client.
rdar://problem/37538580
2018-02-20 16:47:07 -05:00
Joe Groff
953dddd5d3 IRGen/Runtime: Allow mangled type refs to embed "symbolic references" to type context descriptors.
This makes resolving mangled names to nominal types in the same module more efficient, and for eventual secrecy improvements, also allows types in the same module to be referenced from mangled typerefs without encoding any source-level name information about them.
2018-02-10 10:43:47 -08:00
Thomas Roughton
7c2230bc56 Fix cross-compilation for the Windows stdlib
Disable SwiftPrivate, remove -Wl,-z,defs, and use the VFS overlay for compiling the runtime.
2018-02-01 22:08:18 +13:00
Joe Groff
a7a3b17597 Replace nominal type descriptors with a hierarchy of context descriptors.
This new format more efficiently represents existing information, while
more accurately encoding important information about nested generic
contexts with same-type and layout constraints that need to be evaluated
at runtime. It's also designed with an eye to forward- and
backward-compatible expansion for ABI stability with future Swift
versions.
2018-01-29 16:19:25 -08:00
Saleem Abdulrasool
899103cfa8 COFF: restructure metadata registration
Restructure the COFF metadata handling to use the linker section
grouping to emit section start/stop markers in the appropriate location.
This allows us to lookup the sections statically without having to the
walk the entire image structure.

Introduce a constructor for PE/COFF binaries.  This will ensure that the
registration occurs for all modules appropriately.  This should resolve
rdar://problem/19045112.  The registration should occur prior to
`DllMain` being invoked from `DllMainCRTStartup`.
2017-12-08 16:15:07 -08:00
David Zarzycki
986beb7522 [CMake] Localize a build hack
The '-Wl,-z,defs' flag is useful, so let's disable it only where needed.
2017-11-13 07:40:54 -05:00
Michael Gottesman
8437819b5a [CMake] Revert recent changes.
These changes caused a number of issues:

1. No debug info is emitted when a release-debug info compiler is built.
2. OS X deployment target specification is broken.
3. Swift options were broken without any attempt any recreating that
functionality. The specific option in question is --force-optimized-typechecker.

Such refactorings should be done in a fashion that does not break existing
users and use cases.

This reverts commit e6ce2ff388.
This reverts commit e8645f3750.
This reverts commit 89b038ea7e.
This reverts commit 497cac64d9.
This reverts commit 953ad094da.
This reverts commit e096d1c033.

rdar://30549345
2017-02-15 22:26:06 -08:00
Chris Bieneman
e096d1c033 [CMake] Simplify add_swift_library
This patch splits add_swift_library into two functions one which handles
the simple case of adding a library that is part of the compiler being
built and the second handling the more complicated case of "target"
libraries, which may need to build for one or more targets.

The new add_swift_library is built using llvm_add_library, which re-uses
LLVM's CMake modules. In adapting to use LLVM's modules some of
add_swift_library's named parameters have been removed and
LINK_LIBRARIES has changed to LINK_LIBS, and LLVM_LINK_COMPONENTS
changed to LINK_COMPONENTS.

This patch also cleans up libswiftBasic's handling of UUID library and
headers, and how it interfaces with gyb sources.

add_swift_library also no longer has the FILE_DEPENDS parameter, which
doesn't matter because llvm_add_library's DEPENDS parameter has the same
behavior.
2017-02-14 14:28:10 -08:00
Hugh Bellamy
818099ecbe Rename swift_unreachable to swift_runtime_unreachable 2017-01-26 15:31:34 +00:00
Hugh Bellamy
5a59971b95 Move Unreachable.h from include/Basic to include/Runtime 2017-01-26 15:31:33 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Saleem Abdulrasool
ac6edab22e Merge pull request #6025 from hughbe/remote-msvc
Port swift/remote to Windows and MSVC
2016-12-10 12:54:35 -08:00
Hugh Bellamy
53744b9b5a Fix errors and warnings building swift/remote on Windows using MSVC 2016-12-10 16:05:01 +00:00
practicalswift
76f0fdd670 [gardening] NULL → nullptr 2016-12-09 23:17:54 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Michael Gottesman
06a70d3942 [cmake] Add cmake support for only applying tsan to the swift stdlib/runtime. 2016-08-03 17:53:57 -07:00
David Farler
941ec1e043 SwiftRemoteMirror: Add reflection metadata version query API
rdar://problem/27251582
2016-07-08 14:12:59 -07:00
David Farler
c96f4721a2 Add Remote Mirror build presets
This allows us to build just the OS-specific presets for integration
and testing.

rdar://problem/27085666
2016-07-07 14:02:32 -07:00
David Farler
ff45b5a065 Merge pull request #3263 from bitjammer/separate-remote-mirror-target
Separate remote mirror target
2016-07-07 10:28:08 -07:00
Slava Pestov
95bc009e3e Reflection: Multi-payload enum layout
The approach here is to split this into two cases:

- If all case payloads have a fixed size, spare bits may be
  potentially used to differentiate between cases, and the
  remote reflection library does not have enough information to
  compute the layout itself.

  However, the total size must be fixed, so IRGen just emits a
  builtin type descriptor (which I need to rename to 'fixed type
  descriptor' since these are also used for imported value types,
  and now, certain enums).

- If at least one case has a size that depends on a generic
  parameter or is a resilient type, IRGen does not know the size,
  but this means fancy tricks with spare bits cannot be used either.
  The remote reflection library uses the same approach as the
  runtime, basically taking the maximum of the payload size and
  alignment, and adding a tag byte.

As with single-payload enums, we produce a new kind of
RecordTypeInfo, this time with a field for every enum case.
All cases start at offset zero (but of course this might change,
if for example we put the enum tag before the address point).

Also, just as with single-payload enums, there is no remote
'project case index' operation on ReflectionContext yet.

So the the main benefit from this change is that we don't entirely
give up when doing layout of class instances containing enums;
however, tools still cannot look inside the enum values themselves,
except in the simplest cases involving optionals.

Notably, the remote reflection library finally understands all
of the standard library's collection types -- Array, Character,
Dictionary, Set, and String.
2016-07-01 01:31:25 -07:00
Slava Pestov
48c928938a Reflection: Single-payload enum layout
Attempt to lay out single-payload enums, using knowledge of extra
inhabitants where possible.

- The extra inhabitants of an aggregate are the extra inhabitants of
  the first field. If the first field is empty, there are no extra
  inhabitants, and subsequent fields do not affect anything.

- Function pointers and metatypes have different extra inhabitants
  than Builtin.RawPointer, so have IRGen emit distinct builtin type
  descriptors for those.

- Opaque existentials do not have extra inhabitants.

- Weak references do not have extra inhabitants.

Also, fix IRGen to emit more accurate enum reflection metadata in
these two cases:

- We now record whether enum cases are indirect or not. An indirect
  case is the same as a payload case with Builtin.NativeObject.

- We now record whether a case is empty or not using the same logic
  as the rest of IRGen. Previously, we would incorrectly emit a
  payload type for a case with a payload that is an empty struct,
  for example.

At this point we don't have a way to get the currently inhabited
enum case from a value. However, this is still an improvement because
we can still reflect other fields of aggregates containing enums,
instead of just giving up.

Finally make some methods on TypeCoverter private, and use 'friend'
to allow them to be accessed from other internal classes, making the
public API simpler.
2016-06-30 12:57:14 -06:00
David Farler
42e1cb786c Break SwiftRemoteMirror into its own target.
We want to be able to build a target with just the platform-specific
libswiftRemoteMirror library. This should be a change in build logic
for existing presets but allows for a separate preset to be defined
that just builds the library if/when it's necessary.

- Add --build-swift-remote-mirror option to build-script-impl
- Add swift-remote-mirror known install component.
- Only add SwiftRemoteMirror targets if SWIFT_BUILD_REMOTE_MIRROR is on.
- Move libswiftRemoteMirror into the swift-remote-mirror install component.
- Add swift-remote-mirror install components to existing presets.

rdar://problem/27085666
2016-06-29 15:02:41 -07:00
Brian Gesiak
f12a1323ce [SR-1738] Allow *only* static libraries to be built
This splits the `--build-swift-stdlib` and `--build-swift-sdk-overlay`
arguments into `dynamic` and `static` variants, which makes the
following build command possible:

```
utils/build-script -- \
  --build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0 \
  --build-swift-static-stdlib=1 --build-swift-static-sdk-overlay=0
```

This command produces *only* static libraries for the stdlib, and no
SDK overlay libraries at all. Many other finely-grained build options
are now possible.
2016-06-24 09:18:24 -07:00
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
Slava Pestov
da40b5e566 Merge pull request #2285 from tinysun212/pr-portability-1
[SwiftRemoteMirror] Renamed addr_t to swift_addr_t
2016-06-02 10:59:46 -07:00
David Farler
12ec07f4b2 Don't embed bitcode in libSwiftRemoteMirror.dylib
It's not necessary and contributes to bloat in the dylib.

rdar://problem/26396488
2016-05-23 23:50:03 -07:00
David Farler
f3500e4a3c lib/SwiftReflection shouldn't link libswiftCore
Although this is a target library, it does not need to link against
the standard library, because it doesn't have any Swift content in
it. We need to add a separate build flag for having CMake content
because saying a library "IS_STDLIB" isn't correct for this case.

rdar://problem/26399625
2016-05-20 17:28:25 -07:00
Slava Pestov
710d7ede71 Reflection: Break out SWIFT_RAW_POINTER vs SWIFT_BUILTIN in the C API
Also, use "opaque existential" consistently to refer to non-class
existentials, and clean up some other random bits.
2016-05-12 18:27:35 -07:00
David Farler
9dddc6492b SwiftRemoteMirror: Project error existentials
Error existentials have a kind of special heap layout and can also
be compatible as NSError instances, too.
2016-05-10 12:50:31 -07:00
Han Sangjin
675de4048d [SwiftRemoteMirror] Renamed addr_t to swift_addr_t
They would think the type 'addr_t' is defined in the standard library
because it has the same name format with the types in <cstdint>. In
addition, the definition conflicts in Cygwin which defines it differently
in the system library.
2016-05-11 04:02:11 +09:00
David Farler
2fd0b39751 SwiftRemoteMirror: move dump APIs to print to stdout instead of stderr
Rather than move file descriptors around in the tools, just tell the
underlying ::dump methods to print to stdout instead.
2016-05-09 14:29:33 -07:00