Skip to content

Commit bc0604a

Browse files
authored
Merge pull request #3904 from swiftwasm/main
2 parents 5404469 + 8a7ca32 commit bc0604a

File tree

460 files changed

+86625
-3849
lines changed

Some content is hidden

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

460 files changed

+86625
-3849
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang)
499499
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror=gnu>)
500500
endif()
501501

502+
# Make some warnings errors as they are commonly occurring and flood the build
503+
# with unnecessary noise.
504+
if(CMAKE_C_COMPILER_ID MATCHES Clang)
505+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=c++98-compat-extra-semi>)
506+
endif()
507+
502508
# Use dispatch as the system scheduler by default.
503509
# For convenience, we set this to false when concurrency is disabled.
504510
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)

cmake/caches/Linux-x86_64.cmake

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
set(LLVM_ENABLE_PROJECTS
2+
clang
3+
clang-tools-extra
4+
lld
5+
lldb
6+
CACHE STRING "")
7+
8+
set(LLVM_EXTERNAL_PROJECTS
9+
cmark
10+
swift
11+
CACHE STRING "")
12+
13+
set(LLVM_ENABLE_RUNTIMES
14+
compiler-rt
15+
CACHE STRING "")
16+
17+
# NOTE(compnerd) always enable assertions, the toolchain will not provide enough
18+
# context to resolve issues otherwise and may silently generate invalid output.
19+
set(LLVM_ENABLE_ASSERTIONS YES CACHE BOOL "")
20+
21+
set(ENABLE_X86_RELAX_RELOCATIONS YES CACHE BOOL "")
22+
23+
# NOTE(compnerd) we can hardcode the default target triple since the cache files
24+
# are target dependent.
25+
set(LLVM_DEFAULT_TARGET_TRIPLE x86_64-unknown-linux-gnu CACHE STRING "")
26+
27+
set(LLVM_APPEND_VC_REV NO CACHE BOOL "")
28+
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "")
29+
set(LLVM_ENABLE_PYTHON YES CACHE BOOL "")
30+
set(LLVM_BUILTIN_TARGETS
31+
x86_64-unknown-linux-gnu
32+
CACHE STRING "")
33+
foreach(target ${LLVM_RUNTIME_TARGETS})
34+
set(BUILTINS_${target}_LLVM_ENABLE_RUNTIMES
35+
compiler-rt
36+
CACHE STRING "")
37+
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
38+
set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
39+
set(BUILTINS_${target}_COMPILER_RT_BUILD_CRT NO CACHE BOOL "")
40+
set(BUILTINS_${target}_COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "")
41+
set(BUILTINS_${target}_COMPILER_RT_BUILD_PROFILE YES CACHE BOOL "")
42+
set(BUILTINS_${target}_COMPILER_RT_BUILD_SANITIZERS NO CACHE BOOL "")
43+
set(BUILTINS_${target}_COMPILER_RT_BUILD_XRAY NO CACHE BOOL "")
44+
set(BUILTINS_${target}_COMPILER_RT_DEFAULT_TARGET_ONLY YES CACHE BOOL "")
45+
set(BUILTINS_${target}_COMPILER_RT_INCLUDE_TESTS NO CACHE BOOL "")
46+
endforeach()
47+
48+
set(LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "")
49+
50+
# Disable certain targets to reduce the configure time or to avoid configuration
51+
# differences (and in some cases weird build errors on a complete build).
52+
set(LLVM_BUILD_LLVM_DYLIB NO CACHE BOOL "")
53+
set(LLVM_BUILD_LLVM_C_DYLIB NO CACHE BOOL "")
54+
set(LLVM_ENABLE_LIBEDIT NO CACHE BOOL "")
55+
set(LLVM_ENABLE_LIBXML2 NO CACHE BOOL "")
56+
set(LLVM_ENABLE_OCAMLDOC NO CACHE BOOL "")
57+
set(LLVM_ENABLE_TERMINFO NO CACHE BOOL "")
58+
set(LLVM_ENABLE_Z3_SOLVER NO CACHE BOOL "")
59+
set(LLVM_ENABLE_ZLIB NO CACHE BOOL "")
60+
set(LLVM_INCLUDE_BENCHMARKS NO CACHE BOOL "")
61+
set(LLVM_INCLUDE_DOCS NO CACHE BOOL "")
62+
set(LLVM_INCLUDE_EXAMPLES NO CACHE BOOL "")
63+
set(LLVM_INCLUDE_GO_TESTS NO CACHE BOOL "")
64+
set(LLVM_TOOL_GOLD_BUILD NO CACHE BOOL "")
65+
set(LLVM_TOOL_LLVM_SHLIB_BUILD NO CACHE BOOL "")
66+
67+
# Avoid swig dependency for lldb
68+
set(LLDB_ALLOW_STATIC_BINDINGS YES CACHE BOOL "")
69+
set(LLDB_USE_STATIC_BINDINGS YES CACHE BOOL "")
70+
71+
# This requires perl which may not be available on Windows
72+
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")
73+
set(SWIFT_BUILD_ENABLE_PARSER_LIB YES CACHE BOOL "")
74+
# static linking is not supported on Windows yet
75+
set(SWIFT_BUILD_STATIC_STDLIB NO CACHE BOOL "")
76+
set(SWIFT_BUILD_STATIC_SDK_OVERLAY NO CACHE BOOL "")
77+
78+
set(LLVM_INSTALL_BINUTILS_SYMLINKS YES CACHE BOOL "")
79+
set(LLVM_INSTALL_TOOLCHAIN_ONLY YES CACHE BOOL "")
80+
set(LLVM_TOOLCHAIN_TOOLS
81+
addr2line
82+
ar
83+
c++filt
84+
dsymutil
85+
dwp
86+
# lipo
87+
llvm-ar
88+
llvm-cov
89+
llvm-cvtres
90+
llvm-cxxfilt
91+
llvm-dlltool
92+
llvm-dwarfdump
93+
llvm-dwp
94+
llvm-lib
95+
llvm-lipo
96+
llvm-mt
97+
llvm-nm
98+
llvm-objcopy
99+
llvm-objdump
100+
llvm-pdbutil
101+
llvm-profdata
102+
llvm-ranlib
103+
llvm-rc
104+
llvm-readelf
105+
llvm-readobj
106+
llvm-size
107+
llvm-strings
108+
llvm-strip
109+
llvm-symbolizer
110+
llvm-undname
111+
nm
112+
objcopy
113+
objdump
114+
ranlib
115+
readelf
116+
size
117+
strings
118+
CACHE STRING "")
119+
120+
set(CLANG_TOOLS
121+
clang
122+
clangd
123+
clang-format
124+
clang-resource-headers
125+
clang-tidy
126+
CACHE STRING "")
127+
128+
set(LLD_TOOLS
129+
lld
130+
CACHE STRING "")
131+
132+
set(LLDB_TOOLS
133+
liblldb
134+
lldb
135+
lldb-argdumper
136+
lldb-python-scripts
137+
lldb-server
138+
lldb-vscode
139+
repl_swift
140+
CACHE STRING "")
141+
142+
set(SWIFT_INSTALL_COMPONENTS
143+
autolink-driver
144+
compiler
145+
clang-builtin-headers
146+
editor-integration
147+
tools
148+
sourcekit-inproc
149+
swift-remote-mirror
150+
swift-remote-mirror-headers
151+
parser-lib
152+
CACHE STRING "")
153+
154+
set(LLVM_DISTRIBUTION_COMPONENTS
155+
IndexStore
156+
libclang
157+
libclang-headers
158+
LTO
159+
runtimes
160+
${LLVM_TOOLCHAIN_TOOLS}
161+
${CLANG_TOOLS}
162+
${LLD_TOOLS}
163+
${LLDB_TOOLS}
164+
${SWIFT_INSTALL_COMPONENTS}
165+
CACHE STRING "")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
set(SWIFT_HOST_VARIANT_SDK LINUX CACHE STRING "")
3+
set(SWIFT_HOST_VARIANT_ARCH x86_64 CACHE STRING "")
4+
5+
# NOTE(compnerd) disable the tools, we are trying to build just the standard
6+
# library.
7+
set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "")
8+
9+
# NOTE(compnerd) cannot build tests since the tests require the toolchain
10+
set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "")
11+
12+
# NOTE(compnerd) cannot build docs since that requires perl
13+
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")
14+
15+
# NOTE(compnerd) these are part of the toolchain, not the runtime.
16+
set(SWIFT_BUILD_SYNTAXPARSERLIB NO CACHE BOOL "")
17+
set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "")
18+
19+
# NOTE(compnerd) build with the compiler specified, not a just built compiler.
20+
set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "")

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function(_add_host_variant_swift_sanitizer_flags target)
9696
# Not supported
9797
elseif(LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
9898
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
99-
set(_Swift_SANITIZER_FLAGS "-sanitize=address -sanitize=undefined")
99+
set(_Swift_SANITIZER_FLAGS "-sanitize=address" "-sanitize=undefined")
100100
elseif(LLVM_USE_SANITIZER STREQUAL "Leaks")
101101
# Not supported
102102
else()

cmake/modules/StandaloneOverlay.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ option(SWIFT_ENABLE_MODULE_INTERFACES
7373
set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
7474
"Build type for the Swift standard library and SDK overlays.")
7575

76+
file(STRINGS "../../utils/availability-macros.def" SWIFT_STDLIB_AVAILABILITY_DEFINITIONS)
77+
list(FILTER SWIFT_STDLIB_AVAILABILITY_DEFINITIONS EXCLUDE REGEX "^\\s*(#.*)?$")
78+
7679
set(SWIFT_DARWIN_SUPPORTED_ARCHS "" CACHE STRING
7780
"Semicolon-separated list of architectures to configure on Darwin platforms. \
7881
If left empty all default architectures are configured.")

docs/DebuggingTheCompiler.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,13 @@ reducing SIL test cases by:
822822
For more information and a high level example, see:
823823
./swift/utils/bug_reducer/README.md.
824824

825+
### Syncing branches during bisects
826+
827+
When bisecting it might be necessary to run the `update-checkout` script
828+
each time you change shas. To do this you can pass `--match-timestamp`
829+
to automatically checkout match the timestamp of the `apple/swift` repo
830+
across the other repos.
831+
825832
# Debugging the Compiler Build
826833

827834
## Build Dry Run

include/swift/ABI/Task.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class AsyncTask : public Job {
250250
: Job(flags, run, metadata, captureCurrentVoucher),
251251
ResumeContext(initialContext) {
252252
assert(flags.isAsyncTask());
253-
Id = getNextTaskId();
253+
setTaskId();
254254
}
255255

256256
/// Create a task with "immortal" reference counts.
@@ -265,11 +265,14 @@ class AsyncTask : public Job {
265265
: Job(flags, run, metadata, immortal, captureCurrentVoucher),
266266
ResumeContext(initialContext) {
267267
assert(flags.isAsyncTask());
268-
Id = getNextTaskId();
268+
setTaskId();
269269
}
270270

271271
~AsyncTask();
272272

273+
/// Set the task's ID field to the next task ID.
274+
void setTaskId();
275+
273276
/// Given that we've already fully established the job context
274277
/// in the current thread, start running this task. To establish
275278
/// the job context correctly, call swift_job_run or
@@ -566,14 +569,6 @@ class AsyncTask : public Job {
566569
return reinterpret_cast<AsyncTask *&>(
567570
SchedulerPrivate[NextWaitingTaskIndex]);
568571
}
569-
570-
/// Get the next non-zero Task ID.
571-
uint32_t getNextTaskId() {
572-
static std::atomic<uint32_t> Id(1);
573-
uint32_t Next = Id.fetch_add(1, std::memory_order_relaxed);
574-
if (Next == 0) Next = Id.fetch_add(1, std::memory_order_relaxed);
575-
return Next;
576-
}
577572
};
578573

579574
// The compiler will eventually assume these.

include/swift/AST/ASTMangler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class ASTMangler : public Mangler {
6767
/// If enabled, marker protocols can be encoded in the mangled name.
6868
bool AllowMarkerProtocols = true;
6969

70+
/// Whether the mangling predates concurrency, and therefore shouldn't
71+
/// include concurrency features such as global actors or @Sendable
72+
/// function types.
73+
bool PredatesConcurrency = false;
74+
7075
public:
7176
using SymbolicReferent = llvm::PointerUnion<const NominalTypeDecl *,
7277
const OpaqueTypeDecl *>;

include/swift/AST/ArgumentList.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class Argument final {
8383
/// Whether the argument is \c inout, denoted with the '&' prefix.
8484
bool isInOut() const;
8585

86+
/// Whether the argument is a compile-time constant value.
87+
bool isConst() const;
88+
8689
bool operator==(const Argument &other) {
8790
return LabelLoc == other.LabelLoc && Label == other.Label &&
8891
ArgExpr == other.ArgExpr;

include/swift/AST/Attr.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,11 @@ SIMPLE_DECL_ATTR(_predatesConcurrency, PredatesConcurrency,
694694
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
695695
125)
696696

697+
CONTEXTUAL_SIMPLE_DECL_ATTR(_const, CompileTimeConst,
698+
DeclModifier | OnParam | OnVar |
699+
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
700+
126)
701+
697702
// If you're adding a new underscored attribute here, please document it in
698703
// docs/ReferenceGuides/UnderscoredAttributes.md.
699704

include/swift/AST/Builtins.def

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,24 @@ BUILTIN_MISC_OPERATION(Move, "move", "", Special)
820820
/// the SILVerifier.
821821
BUILTIN_MISC_OPERATION(Copy, "copy", "", Special)
822822

823+
/// Unchecked pointer alignment assertion. Allows the compiler to assume
824+
/// alignment of the pointer to emit more efficient code.
825+
///
826+
/// %alignedPtr = builtin "assumeAlignment" (%ptr : $Builtin.RawPointer,
827+
/// %alignment : $Builtin.Int)
828+
/// : $Builtin.RawPointer
829+
/// %address = pointer_to_address %alignedPtr
830+
/// : $Builtin.RawPointer to [align=1] $*Int
831+
/// %val = load %address : $*Int
832+
///
833+
/// With compile-time knowledge of the value of `%alignment` the compiler can
834+
/// optimize any downstream 'pointer_to_address' instruction by refining its
835+
/// '[align=]' flag . That `[align=]` flag can be used by IRGen to refine the
836+
/// alignment on LLVM load instructions that use the resulting address.
837+
///
838+
/// (Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer
839+
BUILTIN_MISC_OPERATION(AssumeAlignment, "assumeAlignment", "n", Special)
840+
823841
// BUILTIN_MISC_OPERATION_WITH_SILGEN - Miscellaneous operations that are
824842
// specially emitted during SIL generation.
825843
//

0 commit comments

Comments
 (0)