File tree 5 files changed +74
-1
lines changed 5 files changed +74
-1
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -e
3
+ /home/zhuowei/wasi-sdk/bin/clang++ -c swift_start.cpp
4
+ /home/zhuowei/wasi-sdk/bin/clang++ -c swift_end.cpp
Original file line number Diff line number Diff line change 2
2
# Copy to ../build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin
3
3
exec /home/zhuowei/wasi-sdk/bin/wasm-ld --error-limit=0 -o hello.wasm \
4
4
/home/zhuowei/wasi-sdk/share/sysroot/lib/wasm32-wasi/crt1.o \
5
+ /home/zhuowei/swift-source/swift/swift_start.o \
6
+ ../lib/swift_static/wasm/wasm32/swiftrt.o \
5
7
hello.o \
6
8
-L../lib/swift_static/wasm/wasm32 \
7
9
-L../lib/swift/wasm/wasm32 \
@@ -10,4 +12,6 @@ exec /home/zhuowei/wasi-sdk/bin/wasm-ld --error-limit=0 -o hello.wasm \
10
12
-lswiftCore \
11
13
-lc -lc++ -lc++abi -lswiftImageInspectionShared \
12
14
-licuuc -licudata \
13
- /home/zhuowei/wasi-sdk/lib/clang/8.0.0/lib/wasi/libclang_rt.builtins-wasm32.a /home/zhuowei/Documents/FakePthread/* .o --verbose
15
+ /home/zhuowei/wasi-sdk/lib/clang/8.0.0/lib/wasi/libclang_rt.builtins-wasm32.a /home/zhuowei/Documents/FakePthread/* .o \
16
+ /home/zhuowei/swift-source/swift/swift_end.o \
17
+ --verbose --no-gc-sections
Original file line number Diff line number Diff line change @@ -43,9 +43,16 @@ static swift::MetadataSections sections{};
43
43
44
44
__attribute__ ((__constructor__))
45
45
static void swift_image_constructor() {
46
+ #ifndef __wasm__
46
47
#define SWIFT_SECTION_RANGE (name ) \
47
48
{ reinterpret_cast <uintptr_t >(&__start_##name), \
48
49
static_cast <uintptr_t >(&__stop_##name - &__start_##name) }
50
+ #else
51
+ // WebAssembly hack: ok this should really go in its own file
52
+ #define SWIFT_SECTION_RANGE (name ) \
53
+ { reinterpret_cast <uintptr_t >(&__start_##name) + sizeof (void *), \
54
+ static_cast <uintptr_t >(&__stop_##name - &__start_##name) }
55
+ #endif
49
56
50
57
sections = {
51
58
swift::CurrentSectionMetadataVersion,
Original file line number Diff line number Diff line change
1
+ // ===--- SwiftRT-ELF.cpp --------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See https://swift.org/LICENSE.txt for license information
9
+ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ // ===----------------------------------------------------------------------===//
12
+
13
+ #include < cstddef>
14
+
15
+ // We synthesize the start/stop symbols ourselves.
16
+ #define DECLARE_SWIFT_SECTION (name ) \
17
+ __attribute__ ((__section__(#name),__visibility__(" hidden" ),__aligned__(1 ))) const void* __stop_##name = (void *)0xfacefeed ; \
18
+
19
+ extern " C" {
20
+ DECLARE_SWIFT_SECTION (swift5_protocols)
21
+ DECLARE_SWIFT_SECTION(swift5_protocol_conformances)
22
+ DECLARE_SWIFT_SECTION(swift5_type_metadata)
23
+
24
+ DECLARE_SWIFT_SECTION(swift5_typeref)
25
+ DECLARE_SWIFT_SECTION(swift5_reflstr)
26
+ DECLARE_SWIFT_SECTION(swift5_fieldmd)
27
+ DECLARE_SWIFT_SECTION(swift5_assocty)
28
+ DECLARE_SWIFT_SECTION(swift5_replace)
29
+ }
Original file line number Diff line number Diff line change
1
+ // ===--- SwiftRT-ELF.cpp --------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See https://swift.org/LICENSE.txt for license information
9
+ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ // ===----------------------------------------------------------------------===//
12
+
13
+ #include < cstddef>
14
+
15
+ // We synthesize the start/stop symbols ourselves.
16
+ #define DECLARE_SWIFT_SECTION (name ) \
17
+ __attribute__ ((__section__(#name),__visibility__(" hidden" ),__aligned__(1 ))) const void* __start_##name = (void *)0xdeadbeef ; \
18
+
19
+ extern " C" {
20
+ DECLARE_SWIFT_SECTION (swift5_protocols)
21
+ DECLARE_SWIFT_SECTION(swift5_protocol_conformances)
22
+ DECLARE_SWIFT_SECTION(swift5_type_metadata)
23
+
24
+ DECLARE_SWIFT_SECTION(swift5_typeref)
25
+ DECLARE_SWIFT_SECTION(swift5_reflstr)
26
+ DECLARE_SWIFT_SECTION(swift5_fieldmd)
27
+ DECLARE_SWIFT_SECTION(swift5_assocty)
28
+ DECLARE_SWIFT_SECTION(swift5_replace)
29
+ }
You can’t perform that action at this time.
0 commit comments