Skip to content

Commit

Permalink
Merge pull request apple#123 from swiftwasm/merge/7952f051a3401494655…
Browse files Browse the repository at this point in the history
…c09aa785a058a7c997c31
  • Loading branch information
MaxDesiatov committed Feb 11, 2020
2 parents c6ba966 + 2c84189 commit a99ef00
Show file tree
Hide file tree
Showing 500 changed files with 17,145 additions and 4,838 deletions.
102 changes: 71 additions & 31 deletions .flake8
@@ -1,32 +1,72 @@
[flake8]
ignore = W291 W504
filename = *.py,
./utils/80+-check,
./utils/backtrace-check,
./benchmark/scripts/Benchmark_Driver,
./benchmark/scripts/Benchmark_DTrace.in,
./benchmark/scripts/Benchmark_GuardMalloc.in,
./benchmark/scripts/Benchmark_RuntimeLeaksRunner.in,
./utils/build-script,
./utils/check-incremental,
./test/Driver/Inputs/fake-toolchain/clang++,
./utils/coverage/coverage-build-db,
./utils/coverage/coverage-generate-data,
./utils/coverage/coverage-query-db,
./utils/coverage/coverage-touch-tests,
./utils/gyb,
./test/Driver/Inputs/fake-toolchain/ld,
./utils/line-directive,
./utils/swift_build_support/tests/mock-distcc,
./docs/scripts/ns-html2rst,
./utils/PathSanitizingFileCheck,
./utils/recursive-lipo,
./utils/round-trip-syntax-test,
./utils/rth,
./utils/run-remote,
./utils/run-test,
./utils/scale-test,
./utils/submit-benchmark-results,
./utils/update-checkout,
./utils/viewcfg,
./utils/symbolicate-linux-fatal,

filename =
*.py,

./benchmark/scripts/Benchmark_Driver,
./benchmark/scripts/Benchmark_DTrace.in,
./benchmark/scripts/Benchmark_GuardMalloc.in,
./benchmark/scripts/Benchmark_RuntimeLeaksRunner.in,

./docs/scripts/ns-html2rst,

./test/Driver/Inputs/fake-toolchain/clang++,
./test/Driver/Inputs/fake-toolchain/ld,

./utils/80+-check,
./utils/backtrace-check,
./utils/build-parser-lib,
./utils/build-script,
./utils/check-incremental,
./utils/coverage/coverage-build-db,
./utils/coverage/coverage-generate-data,
./utils/coverage/coverage-query-db,
./utils/coverage/coverage-touch-tests,
./utils/dev-scripts/blockifyasm,
./utils/dev-scripts/split-cmdline,
./utils/gyb,
./utils/line-directive,
./utils/PathSanitizingFileCheck,
./utils/recursive-lipo,
./utils/round-trip-syntax-test,
./utils/rth,
./utils/run-remote,
./utils/run-test,
./utils/scale-test,
./utils/submit-benchmark-results,
./utils/swift_build_support/tests/mock-distcc,
./utils/symbolicate-linux-fatal,
./utils/update-checkout,
./utils/viewcfg,

# TODO: We should be linting the lit configs.
#lit.cfg,

exclude =
.git,
__pycache__,

ignore =
# The black tool treats slices consistently, the E203 warning is not PEP8
# compliant (https://github.com/psf/black#slices).
E203,

# FIXME: We should not have trailing whitespace.
W291,

# Line breaks before binary operators are not explicitly disallowed in
# PEP8, rather it should be consistent throughout the project. The black
# tool puts them on new lines which is to be considered a best practice
# in the future.
W503,

# Similarly ignore line break after binary operators.
W504,

# TODO: Ignore Bugbear lints for now, but we should enable these in the
# future.
B,

# 10% larger than the standard 80 character limit. Conforms to the black
# standard and Bugbear's B950.
max-line-length = 88
18 changes: 18 additions & 0 deletions CHANGELOG.md
Expand Up @@ -193,6 +193,23 @@ Swift 5.2
* `mutating func callAsFunction` is supported.
* `func callAsFunction` works with `throws` and `rethrows`.
* `func callAsFunction` works with trailing closures.

* [SE-0249][]:

A `\Root.value` key path expression is now allowed wherever a `(Root) -> Value`
function is allowed. Such an expression is implicitly converted to a key path
application of `{ $0[keyPath: \Root.value] }`.

For example:

```swift
struct User {
let email: String
let isAdmin: Bool
}

users.map(\.email) // this is equivalent to: users.map { $0[keyPath: \User.email] }
```

* [SR-4206][]:

Expand Down Expand Up @@ -7880,6 +7897,7 @@ Swift 1.0
[SE-0242]: <https://github.com/apple/swift-evolution/blob/master/proposals/0242-default-values-memberwise.md>
[SE-0244]: <https://github.com/apple/swift-evolution/blob/master/proposals/0244-opaque-result-types.md>
[SE-0245]: <https://github.com/apple/swift-evolution/blob/master/proposals/0245-array-uninitialized-initializer.md>
[SE-0249]: <https://github.com/apple/swift-evolution/blob/master/proposals/0249-key-path-literal-function-expressions.md>
[SE-0252]: <https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md>
[SE-0253]: <https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md>
[SE-0254]: <https://github.com/apple/swift-evolution/blob/master/proposals/0254-static-subscripts.md>
Expand Down
4 changes: 4 additions & 0 deletions benchmark/CMakeLists.txt
Expand Up @@ -248,6 +248,10 @@ option(SWIFT_BENCHMARK_GENERATE_OPT_VIEW
set(SWIFT_BENCHMARK_OPT_VIEWER "" CACHE FILEPATH
"Path to opt-viewer")

option(SWIFT_BENCHMARK_GENERATE_DEBUG_INFO
"Produce debug info for benchmarks"
TRUE)

if(SWIFT_BENCHMARK_OPT_VIEWER)
# If the path to the opt-viewer was specified manually and we have no access
# to the LLVM tree, assume we have the modules for the opt-viewer installed.
Expand Down
3 changes: 3 additions & 0 deletions benchmark/README.md
Expand Up @@ -67,6 +67,9 @@ The following build options are available:
* Enable this option to link the benchmark binaries against the target
machine's Swift standard library and runtime installed with the OS.
(default: OFF)
* `-DSWIFT_BENCHMARK_GENERATE_DEBUG_INFO`
* Enable this option to compile benchmark binaries with debug info.
(default: ON)

The following build targets are available:

Expand Down
8 changes: 8 additions & 0 deletions benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Expand Up @@ -355,6 +355,10 @@ function (swift_benchmark_compile_archopts)
"-target" "${target}"
"-${BENCH_COMPILE_ARCHOPTS_OPT}" ${PAGE_ALIGNMENT_OPTION})

if(SWIFT_BENCHMARK_GENERATE_DEBUG_INFO)
list(APPEND common_options "-g")
endif()

if (is_darwin)
list(APPEND common_options
"-I" "${srcdir}/utils/ObjectiveCTests"
Expand Down Expand Up @@ -384,6 +388,10 @@ function (swift_benchmark_compile_archopts)
"-target" "${target}"
"-${driver_opt}")

if(SWIFT_BENCHMARK_GENERATE_DEBUG_INFO)
list(APPEND common_options_driver "-g")
endif()

if (is_darwin)
list(APPEND common_options_driver
"-sdk" "${sdk}"
Expand Down
44 changes: 31 additions & 13 deletions cmake/modules/AddSwift.cmake
Expand Up @@ -1416,10 +1416,27 @@ function(_add_swift_library_single target name)
# Include LLVM Bitcode slices for iOS, Watch OS, and Apple TV OS device libraries.
if(SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE)
if(${SWIFTLIB_SINGLE_SDK} MATCHES "(I|TV|WATCH)OS")
target_link_options(${target} PRIVATE
"LINKER:-bitcode_bundle"
$<$<BOOL:SWIFT_EMBED_BITCODE_SECTION_HIDE_SYMBOLS>:"LINKER:-bitcode_hide_symbols">
"LINKER:-lto_library,${LLVM_LIBRARY_DIR}/libLTO.dylib")
# The two branches of this if statement accomplish the same end result
# We are simply accounting for the fact that on CMake < 3.16
# using a generator expression to
# specify a LINKER: argument does not work,
# since that seems not to allow the LINKER: prefix to be
# evaluated (i.e. it will be added as-is to the linker parameters)
if(CMAKE_VERSION VERSION_LESS 3.16)
target_link_options(${target} PRIVATE
"LINKER:-bitcode_bundle"
"LINKER:-lto_library,${LLVM_LIBRARY_DIR}/libLTO.dylib")

if(SWIFT_EMBED_BITCODE_SECTION_HIDE_SYMBOLS)
target_link_options(${target} PRIVATE
"LINKER:-bitcode_hide_symbols")
endif()
else()
target_link_options(${target} PRIVATE
"LINKER:-bitcode_bundle"
$<$<BOOL:SWIFT_EMBED_BITCODE_SECTION_HIDE_SYMBOLS>:"LINKER:-bitcode_hide_symbols">
"LINKER:-lto_library,${LLVM_LIBRARY_DIR}/libLTO.dylib")
endif()
endif()
endif()
endif()
Expand Down Expand Up @@ -1554,6 +1571,9 @@ function(add_swift_host_library name)
if(ASHL_DEPENDS)
message(SEND_ERROR "library ${name} is using DEPENDS parameter which is deprecated. Please use add_dependencies instead")
endif()
if(ASHL_FILE_DEPENDS)
message(SEND_ERROR "library ${name} is using FILE_DEPENDS parameter which is deprecated.")
endif()
if(ASHL_LINK_LIBRARIES)
message(SEND_ERROR "library ${name} is using LINK_LIBRARIES parameter which is deprecated. Please use target_link_libraries instead")
endif()
Expand All @@ -1573,7 +1593,6 @@ function(add_swift_host_library name)
SDK ${SWIFT_HOST_VARIANT_SDK}
ARCHITECTURE ${SWIFT_HOST_VARIANT_ARCH}
LLVM_LINK_COMPONENTS ${ASHL_LLVM_LINK_COMPONENTS}
FILE_DEPENDS ${ASHL_FILE_DEPENDS}
INSTALL_IN_COMPONENT "dev"
)

Expand Down Expand Up @@ -2153,7 +2172,10 @@ function(add_swift_target_library name)

list(APPEND swiftlib_swift_compile_flags_all "-Fsystem" "${ios_support_frameworks_path}")
list(APPEND swiftlib_c_compile_flags_all "-iframework" "${ios_support_frameworks_path}")
list(APPEND swiftlib_link_flags_all "-F" "${ios_support_frameworks_path}")
# We collate -F with the framework path to avoid unwanted deduplication
# of options by target_compile_options -- this way no undesired
# side effects are introduced should a new search path be added.
list(APPEND swiftlib_link_flags_all "-F${ios_support_frameworks_path}")
endif()

if(sdk IN_LIST SWIFT_APPLE_PLATFORMS AND SWIFTLIB_IS_SDK_OVERLAY)
Expand Down Expand Up @@ -2523,6 +2545,9 @@ function(_add_swift_executable_single name)
if(SWIFTEXE_SINGLE_EXCLUDE_FROM_ALL)
message(SEND_ERROR "${name} is using EXCLUDE_FROM_ALL option which is deprecated.")
endif()
if(SWIFTEXE_SINGLE_LINK_LIBRARIES)
message(SEND_ERROR "${name} is using LINK_LIBRARIES parameter which is deprecated. Please use target_link_libraries instead")
endif()

# Check arguments.
precondition(SWIFTEXE_SINGLE_SDK MESSAGE "Should specify an SDK")
Expand Down Expand Up @@ -2557,12 +2582,6 @@ function(_add_swift_executable_single name)
LINK_LIBRARIES_VAR_NAME link_libraries
LIBRARY_SEARCH_DIRECTORIES_VAR_NAME library_search_directories)

_list_add_string_suffix(
"${SWIFTEXE_SINGLE_LINK_LIBRARIES}"
"-${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}-${SWIFTEXE_SINGLE_ARCHITECTURE}"
SWIFTEXE_SINGLE_LINK_LIBRARIES_TARGETS)
set(SWIFTEXE_SINGLE_LINK_LIBRARIES ${SWIFTEXE_SINGLE_LINK_LIBRARIES_TARGETS})

handle_swift_sources(
dependency_target
unused_module_dependency_target
Expand Down Expand Up @@ -2626,7 +2645,6 @@ function(_add_swift_executable_single name)
BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})

target_link_libraries("${name}" PRIVATE ${SWIFTEXE_SINGLE_LINK_LIBRARIES})
swift_common_llvm_config("${name}" ${SWIFTEXE_SINGLE_LLVM_LINK_COMPONENTS})

# NOTE(compnerd) use the C linker language to invoke `clang` rather than
Expand Down
7 changes: 1 addition & 6 deletions cmake/modules/SwiftSource.cmake
Expand Up @@ -355,13 +355,9 @@ function(_compile_swift_files
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS OR
SWIFTFILE_SDK STREQUAL "MACCATALYST")
set(specific_module_dir "${module_base}.swiftmodule")
set(specific_module_project_dir "${specific_module_dir}/Project")
set(source_info_file "${specific_module_project_dir}/${SWIFTFILE_ARCHITECTURE}.swiftsourceinfo")
set(module_base "${module_base}.swiftmodule/${SWIFTFILE_ARCHITECTURE}")
else()
set(specific_module_dir)
set(specific_module_project_dir)
set(source_info_file "${module_base}.swiftsourceinfo")
endif()
set(module_file "${module_base}.swiftmodule")
set(module_doc_file "${module_base}.swiftdoc")
Expand Down Expand Up @@ -622,11 +618,10 @@ function(_compile_swift_files
COMMAND
"${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir}
${specific_module_dir}
${specific_module_project_dir}
COMMAND
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}"
"-emit-module-source-info-path" "${source_info_file}"
"-avoid-emit-module-source-info"
${swift_flags} ${swift_module_flags} "@${file_path}"
${command_touch_module_outputs}
OUTPUT ${module_outputs}
Expand Down

0 comments on commit a99ef00

Please sign in to comment.