Commit Graph

83 Commits

Author SHA1 Message Date
John McCall
6c16cfaa14 Implement a basic dynamic-enforcement runtime and teach IRGen to use it. 2017-04-18 11:23:43 -04:00
eeckstein
3db4630dfe Merge pull request #8013 from eeckstein/demangler-cmake
libraries: instead of including all demangler sources into a single C++ source file,
2017-03-10 08:27:25 -08:00
Erik Eckstein
b398098dcb libraries: instead of including all demangler sources into a single C++ source file, list them in the cmake file 2017-03-09 19:56:40 -08:00
Arnold Schwaighofer
49b3377101 Pass down the SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS flag to the runtime build. 2017-03-09 17:22:35 -08:00
Gonzalo Larralde
443e7614e4 Fixes on linker executable variables per target.
* `prefix` should be `sdk` in runtime cmake list file
* typo on variable existence checking
2017-03-07 10:00:58 -03:00
Saleem Abdulrasool
125e882c8c build: permit overriding the linker
When cross-compiling for android ARM, it is possible that the system
linker does not support the target.  However, in order to cross-compile
the target runtime, we need to adjust the linker to the target linker.
If one is not specified, fall back to the current behaviour of using the
system linker.
2017-02-26 11:25:07 -08:00
Greg Parker
ae1c984920 New refcount representation (#5282)
New refcount representation and weak variable implementation. See SwiftShims/RefCount.h for details.
2017-02-24 14:19:11 -08: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
Doug Coleman
40e092b308 Merge pull request #7468 from spevans/pr_lowercase
Remove misspelt CMakefile variable
2017-02-14 20:47:36 -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
Simon Evans
11a71912e8 Remove misspelt CMakefile variable
- ${lowercase} was used instead of ${lowercase_sdk} so evaluated to ''
  but wasnt required anyway.
2017-02-14 17:34:13 +00:00
Saleem Abdulrasool
1466a5e6e1 Merge pull request #7147 from spevans/pr_link_args
Add dependancy for Linux static-stdlib link argument files
2017-02-05 16:48:45 -08:00
Saleem Abdulrasool
b80553b9a1 build: use CMAKE_LINKER rather than hardcoding the linker
This breaks the build on exherbo, which uses target tripled linker
names.  Furthermore, the default name on unix-ish systems for the linker
is `ld`.  This can be a symlink to a specific implementation, usually
named as ld.<name> (e.g. `ld.bfd` or `ld.gold`).  Use the cmake variable
for the linker rather than hardcoding the name.
2017-02-05 13:27:15 -08:00
Simon Evans
86596a469e Add dependancy for Linux link argument files 2017-01-30 18:17:28 +00:00
Simon Evans
5c993b45db [runtime] Remove swift_addNewDSOImage() call from static ELF binaries
- Create separate swift_begin.o/swift_end.o for lib/swift and
  lib/swift_static. The static swift_begin.o does not call
  swift_addNewDSOImage() at startup.

- Update ToolChains.cpp to use the correct swift_begin.o/swift_end.o
  files for the `-static-stdlib` and `-static-executable` options.
2017-01-27 14:04:58 +00:00
Simon Evans
30436f4077 [runtime] ELF DSO binary section fixes
- Rename swift::addNewDSOImage() to swift_addNewDSOImage() and
  export using SWIFT_RUNTIME_EXPORT.

- Move ELF specific parts of ImageInspection.h into
  ImageInspectionELF.h.
2017-01-27 14:04:54 +00:00
Simon Evans
e07c0d21c2 [runtime] Binary section data loading for extra ELF images
- For ELF targets, keep track of shared objects as they are
  dynamically loaded so that section data can be added to
  the protocol conformance and type metadata caches after
  initialisation (rdar://problem/19045112).
2017-01-27 10:28:46 +00:00
practicalswift
a9d6d8938c [gardening] Fix recently introduced typos 2017-01-22 20:40:45 +01:00
Simon Evans
22b5e6d57b [runtime] Implement lookupSymbol() for ELF static executables 2017-01-09 10:56:29 +00:00
practicalswift
16d6dce62e [gardening] Fix recently introduced typos. 2016-12-16 21:42:09 +01:00
Saleem Abdulrasool
c67a33fbc7 build: remove TARGET_SDKS from the runtime
The runtime and stubs are built for ALL targets, not specific ones.  This allows
us to configure when cross-compiling to Windows again.  Collapse the dual
addition of the swiftRuntime into a single build.  This unifies the runtime
build for the apple and non-Apple SDKs.  The difference here was the ObjC
interop sources.  In order to deal with that unification add a CPP macro to
indicate whether the interop sources should be included or not.
2016-12-03 17:02:44 -08:00
Simon Evans
1daa3ee1f8 [SR-648] Add option to create statically linked binaries
- Add ImageInspectionStatic.cpp to lookup protocol conformance
  and metadata sections in static binaries

- For Linux, build libswiftImageInspectionShared.a and
  libswiftImageInspectionStatic.a for linking with libswiftCore.a.
  This allows static binaries to be built without linking to
  libdl. libswiftImageInspectionShared (ImageInspectionELF.cpp) is
  automatically compiled into libswiftCore.so

- Adds -static-executable option to swiftc to use along with
  -emit-executable that uses linker arguments in
  static-executable-args.lnk. This also requires a libicu
  to be compiled using the --libicu which has configure options
  that dont require libdl for accessing ICU datafiles

- Static binaries only work on Linux at this time
2016-11-29 13:36:19 +00:00
Joe Groff
87b27c6451 Runtime: Refactor platform-dependent image inspection code.
The code we use to interface with the platform dynamic linker is turning into a rat's nest of conditionals that's hard to maintain and extend. Since ELF, Mach-O, and PE platforms have pretty fundamentally different dynamic linker interfaces and capabilities, it makes sense to factor that code into a separate file per-platform, instead of trying to conditionalize the logic in-line. This patch factors out a much simpler portable interface for lazily kicking off the protocol conformance and type metadata lookup caches, and factors the guts out into separate MachO, ELF, and Win32 backends. This should also be a much cleaner interface to interface static binary behavior into, assisting #5349.
2016-11-17 16:50:04 -08:00
Brian Gesiak
341d022ba7 [runtime] Update CMake to use TARGET_SDKS (NFC)
The `add_swift_library` CMake function takes an optional `TARGET_SDKS`
parameter. When used, only CMake targets for the specified SDKs are added.

Refactor `stdlib/public/runtime` to use this parameter. This also eliminates
logic that determines additional flags or source files to include based on
`SWIFT_HOST_VARIANT`, which makes it easier for hosts to add targets for
different platforms.
2016-09-24 22:40:57 -04:00
Doug Gregor
e1545a7d5a [Type checker/runtime] Move default implementation of Error._code into the runtime.
Rather than having Sema provide a default implementation of
Error._code when needed, introduce a runtime function to extract the
default code, so that we can provide a default implementation via a
protocol extension in the standard library.
2016-08-25 16:00:19 -07:00
Dmitri Gribenko
990350e068 runtime: expose the layout of SwiftError to LLDB through global constants 2016-08-10 16:10:52 -07:00
Dmitri Gribenko
b162f60070 runtime: make _SwiftNativeNSError use the Hashable conformance, if available
If the Swift error wrapped in a _SwiftNativeNSError box conforms to
Hashable, the box now uses the Swift's conformance to Hashable.

Part of rdar://problem/27574348.
2016-08-09 00:49:20 -07: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
Joe Groff
bc8433f186 Runtime: Implement an opaque 'SwiftValue' ObjC class to hold bridged values.
If there's no better mapping for a Swift value into an Objective-C object for bridging purposes, we can fall back to boxing the value in a class. This class doesn't have any public interface beyond being `NSObject`-conforming in Objective-C, but is recognized by the Swift runtime so that it can be dynamically cast back to the boxed type.
2016-07-15 15:56:25 -07:00
Saleem Abdulrasool
3d174c372a stdlib: be more DLL friendly on Windows
When the standard library is built dynamically on COFF targets, the public
interfaces must be decorated in order to generate a proper DLL which can be
confused by the dependent libraries.  When the exported interface is used, it
must be indirectly addressed.  This can be done manually in code or the MS
extension of `__declspec(dllimport)` may be used to indicate to the compiler
that this symbol be addressed indirectly.  This permits building more pieces of
the standard library dynamically on Windows.
2016-07-06 17:51:31 -07:00
Saleem Abdulrasool
d9ba70a595 runtime: tweak the compilation
Always include all the sources as we cannot include object libraries to be
subsumed.  This allows us to conditionally build the swift runtime for foreign
hosts simultaneously (e.g. cross compile for Linux and Windows simultaneously).
2016-06-22 21:38:15 -07:00
Saleem Abdulrasool
d771054c7b build: use the new object format property
Simplify the ELF checks based on review comments from Dimitri Gribenko.
2016-06-22 09:37:56 -07:00
Saleem Abdulrasool
bbb82d4fe4 build: build the section_magic libraries for ELFish targets
Build the section_magic libraries for all the ELFish SDKs that have been
configured.  This allows us to build for SDKs which dont match the object format
at the same time (e.g. Linux and Windows).
2016-06-21 23:01:52 -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
Dmitri Gribenko
6a507d6311 Runtime: give each source file a unique basename
CMake Xcode generator does not seem to build libraries properly if we
have both a Foo.cpp and a Foo.mm in one library.
2016-06-02 01:13:40 -07:00
Han Sangjin
be815aabbb [stdlib/msvc] Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build this port.
This is the approved subpatch of a large patch.
2016-06-02 08:10:40 +09:00
Dmitri Gribenko
d227aeb64d CMake: use object libraries instead of repacking static archives 2016-06-01 03:06:33 -06:00
John McCall
b1983621d3 Fix the declaration of shim visibility on ELF platforms.
Declarations with protected visibility are assumed to be defined
within the current linkage unit, so we have to use default visibility
if we don't know that we're building that.  Teach the shim
visibility header to only use protected visibility when the
__SWIFT_CURRENT_DYLIB macro is defined, and define it when building
the standard library.  Eventually we should change
SWIFT_RUNTIME_STDLIB_INTERFACE and SWIFT_RUNTIME_EXPORT to be
parameterized by the defining dylib so that this works for all the
overlay stubs, too; for now, special-casing swiftCore is necessary
to fix the LInux build.
2016-05-19 14:38:34 -06:00
Rintaro Ishizaki
93b4ed151a [Runtime] Don't install libsection_magic_{begin,end}.a 2016-04-29 01:45:06 +09:00
Rintaro Ishizaki
9114293af7 [Runtime] Correct add_custom_command_target usage in CMakeLists.txt
- COMMAND arguments must immediately follow dependency_out_var_name.
- Use generated target name instead of output file names.
- Unify 2 file copy COMMAND into 1 add_custom_command_target.
2016-04-29 01:44:51 +09:00
Greg Parker
590d41c00a [runtime] enhanced and refactored recently added Mutex abstraction (Merge pull request #1950 from shawnce/SR-946_rw)
[runtime] enhanced and refactored recently added Mutex abstraction
2016-04-26 16:18:12 -07:00
Greg Parker
86faf7c15d [runtime] Don't install libswiftRuntime.a
libswiftRuntime.a is an internal object file. Its contents are incorporated
into libswiftCore.dylib and libswiftCore.a.

rdar://25353757
2016-04-15 19:15:27 -07:00
Anna Zaks
eac72f078c [runtime] Add implementation of _swift_strlcpy
This safer function is missing on Linux.
2016-04-14 11:01:57 -07:00
Zhuowei Zhang
7c502b6344 Port to Android
This adds an Android target for the stdlib. It is also the first
example of cross-compiling outside of Darwin.

Mailing list discussions:

1. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000171.html
2. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000492.html

The Android variant of Swift may be built using the following `build-script`
invocation:

```
$ utils/build-script \
  -R \                                           # Build in ReleaseAssert mode.
  --android \                                    # Build for Android.
  --android-ndk ~/android-ndk-r10e \             # Path to an Android NDK.
  --android-ndk-version 21 \
  --android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
  --android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
  --android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
  --android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/
```

Android builds have the following dependencies, as can be seen in
the build script invocation:

1. An Android NDK of version 21 or greater, available to download
   here: http://developer.android.com/ndk/downloads/index.html.
2. A libicu compatible with android-armv7.
2016-04-12 19:26:21 -04:00
Shawn Erickson
a0452be947 [runtime] enhanced and refactored recently added Mutex abstraction
- added read / write lock support
- added non-fatal error support to allow use of mutex in fatal error reporting pathway
- isolated pthread implementation to it own header/cpp file pair
- expanded unit tests to cover new code as well as better test existing mutex
- removed a layer of complexity that added no real value
2016-04-06 13:02:37 -07:00
Shawn Erickson
2f84220712 [runtime] added Mutex, Condition, and Scoped locks for use by Swift runtime (see SR-946) 2016-03-20 22:56:24 -07:00
Roman Levenstein
adb5c7347b Auto-generate global symbols for those run-time functions that require it.
Generate global symbols which are function pointers to the actual implementations of runtime entry points.
This is done only for entry points using the new calling convention or for those entry points which explicitly require it.
2016-02-25 05:30:59 -08:00
Han Sangjin
8c829eef36 Moved LLVM_OPTIONAL_SOURCES 2016-02-23 07:52:43 +09:00
Han Sangjin
f0e10a281c Merged LLVM_OPTION_SOURCES in runtime CMakeLists.txt 2016-02-22 20:46:28 +09:00
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00