Skip to content

Commit d11bb64

Browse files
authored
---
yaml --- r: 278011 b: refs/heads/swift-5.1-old-llvm-branch c: b52472b h: refs/heads/master i: 278009: 604beb5 278007: f058b5d
1 parent 1fe3e22 commit d11bb64

File tree

64 files changed

+634
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+634
-330
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-01-24-a: b6f62823aa5010b2ae53f15f72a57
12411241
refs/heads/marcrasi-astverifier-disable: 3fac766a23a77ebd0640296bfd7fc116ea60a4e0
12421242
refs/heads/revert-22227-a-tall-white-fountain-played: adfce60b2eaa54903ea189bed8a783bca609fa53
12431243
refs/heads/revert-22300-revert-22227-a-tall-white-fountain-played: 5f92040224df7dd4e618fdfb367349df64d8acad
1244-
refs/heads/swift-5.1-old-llvm-branch: 9c860b2dc2e48f5e4729dc8cc68c2eda815e686e
1244+
refs/heads/swift-5.1-old-llvm-branch: b52472bac28db2e704c6b1cffb0ccc153384068a
12451245
refs/heads/swift-5.1-branch: 8060872acb4105d9655e020fe047e1ebcd77d0fb
12461246
refs/tags/swift-4.2.2-RELEASE: e429d1f1aaf59e69d38207a96e56265c7f6fccec
12471247
refs/tags/swift-5.0-DEVELOPMENT-SNAPSHOT-2019-02-02-a: 3e5a03d32ff3b1e9af90d6c1198c14f938379a6e

branches/swift-5.1-old-llvm-branch/cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ endfunction()
3030
# Compute the library subdirectory to use for the given sdk and
3131
# architecture, placing the result in 'result_var_name'.
3232
function(compute_library_subdir result_var_name sdk arch)
33-
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}" PARENT_SCOPE)
33+
if(sdk IN_LIST SWIFT_APPLE_PLATFORMS)
34+
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}" PARENT_SCOPE)
35+
else()
36+
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}" PARENT_SCOPE)
37+
endif()
3438
endfunction()
3539

3640
function(_compute_lto_flag option out_var)
@@ -1156,6 +1160,8 @@ function(_add_swift_library_single target name)
11561160
# Don't set PROPERTY COMPILE_FLAGS or LINK_FLAGS directly.
11571161
set(c_compile_flags ${SWIFTLIB_SINGLE_C_COMPILE_FLAGS})
11581162
set(link_flags ${SWIFTLIB_SINGLE_LINK_FLAGS})
1163+
1164+
set(library_search_subdir "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
11591165
set(library_search_directories
11601166
"${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
11611167
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"
@@ -1300,6 +1306,7 @@ function(_add_swift_library_single target name)
13001306
if(target_static)
13011307
set_property(TARGET "${target_static}" APPEND_STRING PROPERTY
13021308
COMPILE_FLAGS " ${c_compile_flags}")
1309+
# FIXME: The fallback paths here are going to be dynamic libraries.
13031310
set(library_search_directories
13041311
"${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
13051312
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"

branches/swift-5.1-old-llvm-branch/cmake/modules/SwiftSource.cmake

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ function(handle_swift_sources
6161
endif()
6262

6363
if(swift_sources)
64-
compute_library_subdir(SWIFTSOURCES_LIBRARY_SUBDIR
65-
"${SWIFTSOURCES_SDK}" "${SWIFTSOURCES_ARCHITECTURE}")
66-
set(objsubdir "/${SWIFTSOURCES_LIBRARY_SUBDIR}")
64+
set(objsubdir "/${SWIFTSOURCES_SDK}/${SWIFTSOURCES_ARCHITECTURE}")
6765

6866
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}${objsubdir}")
6967

@@ -255,6 +253,8 @@ function(_compile_swift_files
255253
"-nostdimport" "-parse-stdlib" "-module-name" "Swift")
256254
list(APPEND swift_flags "-Xfrontend" "-group-info-path"
257255
"-Xfrontend" "${GROUP_INFO_JSON_FILE}")
256+
else()
257+
list(APPEND swift_flags "-module-name" "${SWIFTFILE_MODULE_NAME}")
258258
endif()
259259

260260
# Force swift 5 mode for Standard Library.
@@ -313,19 +313,32 @@ function(_compile_swift_files
313313
list(APPEND swift_flags "-parse-as-library")
314314

315315
set(module_base "${module_dir}/${SWIFTFILE_MODULE_NAME}")
316+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
317+
set(specific_module_dir "${module_base}.swiftmodule")
318+
set(module_base "${module_base}.swiftmodule/${SWIFTFILE_ARCHITECTURE}")
319+
endif()
316320
set(module_file "${module_base}.swiftmodule")
321+
set(module_doc_file "${module_base}.swiftdoc")
322+
323+
# FIXME: These don't really belong inside the swiftmodule, but there's not
324+
# an obvious alternate place to put them.
317325
set(sib_file "${module_base}.Onone.sib")
318326
set(sibopt_file "${module_base}.O.sib")
319327
set(sibgen_file "${module_base}.sibgen")
320-
set(module_doc_file "${module_base}.swiftdoc")
321328

322329
if(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES)
323330
set(interface_file "${module_base}.swiftinterface")
324-
list(APPEND swift_flags "-emit-parseable-module-interface")
331+
list(APPEND swift_flags
332+
"-emit-parseable-module-interface-path" "${interface_file}")
325333
endif()
326334

327-
list(APPEND command_create_dirs
328-
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
335+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
336+
list(APPEND command_create_dirs
337+
COMMAND "${CMAKE_COMMAND}" -E make_directory "${specific_module_dir}")
338+
else()
339+
list(APPEND command_create_dirs
340+
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
341+
endif()
329342

330343
# If we have extra regexp flags, check if we match any of the regexps. If so
331344
# add the relevant flags to our swift_flags.
@@ -349,10 +362,15 @@ function(_compile_swift_files
349362
set(optional_arg "OPTIONAL")
350363
endif()
351364

352-
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
353-
FILES ${module_outputs}
354-
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}"
355-
"${optional_arg}")
365+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
366+
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
367+
DIRECTORY "${specific_module_dir}"
368+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}")
369+
else()
370+
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
371+
FILES ${module_outputs}
372+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}")
373+
endif()
356374

357375
set(line_directive_tool "${SWIFT_SOURCE_DIR}/utils/line-directive")
358376
set(swift_compiler_tool "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc")

branches/swift-5.1-old-llvm-branch/docs/SIL.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,7 @@ is_escaping_closure
29372937
```````````````````
29382938

29392939
::
2940+
29402941
sil-instruction ::= 'is_escaping_closure' sil-operand
29412942

29422943
%1 = is_escaping_closure %0 : $@callee_guaranteed () -> ()
@@ -2948,6 +2949,7 @@ true if it is.
29482949

29492950
copy_block
29502951
``````````
2952+
29512953
::
29522954

29532955
sil-instruction :: 'copy_block' sil-operand
@@ -2960,6 +2962,7 @@ if the block is copied from the stack to the heap.
29602962

29612963
copy_block_without_escaping
29622964
```````````````````````````
2965+
29632966
::
29642967

29652968
sil-instruction :: 'copy_block_without_escaping' sil-operand 'withoutEscaping' sil-operand

branches/swift-5.1-old-llvm-branch/include/swift/FrontendTool/FrontendTool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class FrontendObserver {
4444
virtual void configuredCompiler(CompilerInstance &instance);
4545
};
4646

47+
namespace frontend {
48+
namespace utils {
49+
StringRef escapeForMake(StringRef raw, llvm::SmallVectorImpl<char> &buffer);
50+
}
51+
}
52+
4753
/// Perform all the operations of the frontend, exactly as if invoked
4854
/// with -frontend.
4955
///

branches/swift-5.1-old-llvm-branch/lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static void updateRuntimeLibraryPath(SearchPathOptions &SearchPathOpts,
4949
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
5050
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
5151

52-
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
52+
if (!Triple.isOSDarwin())
53+
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
5354
SearchPathOpts.RuntimeLibraryImportPath = LibPath.str();
5455
}
5556

branches/swift-5.1-old-llvm-branch/lib/FrontendTool/FrontendTool.cpp

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,40 @@ static std::string displayName(StringRef MainExecutablePath) {
9999
return Name;
100100
}
101101

102+
StringRef
103+
swift::frontend::utils::escapeForMake(StringRef raw,
104+
llvm::SmallVectorImpl<char> &buffer) {
105+
buffer.clear();
106+
107+
// The escaping rules for GNU make are complicated due to the various
108+
// subsitutions and use of the tab in the leading position for recipes.
109+
// Various symbols have significance in different contexts. It is not
110+
// possible to correctly quote all characters in Make (as of 3.7). Match
111+
// gcc and clang's behaviour for the escaping which covers only a subset of
112+
// characters.
113+
for (unsigned I = 0, E = raw.size(); I != E; ++I) {
114+
switch (raw[I]) {
115+
case '#': // Handle '#' the broken GCC way
116+
buffer.push_back('\\');
117+
break;
118+
119+
case ' ':
120+
for (unsigned J = I; J && raw[J - 1] == '\\'; --J)
121+
buffer.push_back('\\');
122+
buffer.push_back('\\');
123+
break;
124+
125+
case '$': // $ is escaped by $
126+
buffer.push_back('$');
127+
break;
128+
}
129+
buffer.push_back(raw[I]);
130+
}
131+
buffer.push_back('\0');
132+
133+
return buffer.data();
134+
}
135+
102136
/// Emits a Make-style dependencies file.
103137
static bool emitMakeDependenciesIfNeeded(DiagnosticEngine &diags,
104138
DependencyTracker *depTracker,
@@ -118,39 +152,21 @@ static bool emitMakeDependenciesIfNeeded(DiagnosticEngine &diags,
118152
return true;
119153
}
120154

121-
// Declare a helper for escaping file names for use in Makefiles.
122-
llvm::SmallString<256> pathBuf;
123-
auto escape = [&](StringRef raw) -> StringRef {
124-
pathBuf.clear();
125-
126-
static const char badChars[] = " $#:\n";
127-
size_t prev = 0;
128-
for (auto index = raw.find_first_of(badChars); index != StringRef::npos;
129-
index = raw.find_first_of(badChars, index+1)) {
130-
pathBuf.append(raw.slice(prev, index));
131-
if (raw[index] == '$')
132-
pathBuf.push_back('$');
133-
else
134-
pathBuf.push_back('\\');
135-
prev = index;
136-
}
137-
pathBuf.append(raw.substr(prev));
138-
return pathBuf;
139-
};
155+
llvm::SmallString<256> buffer;
140156

141157
// FIXME: Xcode can't currently handle multiple targets in a single
142158
// dependency line.
143159
opts.forAllOutputPaths(input, [&](const StringRef targetName) {
144-
out << escape(targetName) << " :";
160+
out << swift::frontend::utils::escapeForMake(targetName, buffer) << " :";
145161
// First include all other files in the module. Make-style dependencies
146162
// need to be conservative!
147163
for (auto const &path :
148164
reversePathSortedFilenames(opts.InputsAndOutputs.getInputFilenames()))
149-
out << ' ' << escape(path);
165+
out << ' ' << swift::frontend::utils::escapeForMake(path, buffer);
150166
// Then print dependencies we've picked up during compilation.
151167
for (auto const &path :
152168
reversePathSortedFilenames(depTracker->getDependencies()))
153-
out << ' ' << escape(path);
169+
out << ' ' << swift::frontend::utils::escapeForMake(path, buffer);
154170
out << '\n';
155171
});
156172

0 commit comments

Comments
 (0)