File tree Expand file tree Collapse file tree 5 files changed +74
-1
lines changed Expand file tree Collapse file tree 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 22# Copy to ../build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin
33exec /home/zhuowei/wasi-sdk/bin/wasm-ld --error-limit=0 -o hello.wasm \
44 /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 \
57 hello.o \
68 -L../lib/swift_static/wasm/wasm32 \
79 -L../lib/swift/wasm/wasm32 \
@@ -10,4 +12,6 @@ exec /home/zhuowei/wasi-sdk/bin/wasm-ld --error-limit=0 -o hello.wasm \
1012 -lswiftCore \
1113 -lc -lc++ -lc++abi -lswiftImageInspectionShared \
1214 -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{};
4343
4444__attribute__ ((__constructor__))
4545static void swift_image_constructor() {
46+ #ifndef __wasm__
4647#define SWIFT_SECTION_RANGE (name ) \
4748 { reinterpret_cast <uintptr_t >(&__start_##name), \
4849 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
4956
5057 sections = {
5158 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