Skip to content

Katei working branch#7

Closed
kateinoigakukun wants to merge 69 commits intoswiftwasmfrom
katei/swiftwasm
Closed

Katei working branch#7
kateinoigakukun wants to merge 69 commits intoswiftwasmfrom
katei/swiftwasm

Conversation

@kateinoigakukun
Copy link
Copy Markdown
Owner

WIP

WebAssembly doesn't have __builtin_return_address.
This matches what Clang does.

This doesn't check that the target is Wasm; will need to do that.

Patcheng's port seems to have working? atomics, so it's probably possible
to get atomics working, but this is fine for now.

This still doesn't get the stdlib to compile, but at least the error now matches
what I get when I run clang on the -emit-ir LLVM IR output.
This doesn't take care of all the PC relative relocations in constant builder yet.

This still breaks on

`((.Lgot.$sSTMp.656-($ss18EnumeratedSequenceVMn))-56)+1`

Which sits in rodata. Not sure where that's generated yet
This removes the PCRel reloc in \01l_type_metadata_table but nowhere else
This at least seems to get rid of all the PCRel relocations emitted.

Now it crashes in:

(($sSTMp)+48)-8
The expr type is 0
expression kind not supported

yay?!
WebAssembly doesn't have support for the DWARF5 features yet.

It's probably not too hard to add (just add the sections), but I
decided to just disable it out of caution since I have no idea
if other changes are needed.

This doesn't test for the WebAssembly platform yet; will do that later
Swift's importer won't import error constants from WASI,
because the constants are wrapped in UINT16_C(),
which Swift doesn't support.
LLVM doesn't support generating DWARF5 debugging data for WebAssembly,
and support for atomics is currently very limited.

Set LLVM target options to avoid generating DWARF5 debug data and lower
atomics to regular load/stores when building for WebAssembly.

This shouldn't affect existing platforms.
zhuowei and others added 24 commits October 22, 2019 13:08
Previous commits changed a bunch of relative pointers to absolute
in the metadata; at the time I didn't add support for adding tag
bits, which signifies if the pointers point to the .got section
(and thus needs an extra layer of indirection.)

This broke _isCImportedTagType on $ss7UnicodeO5ASCIIOMn,
so this commit adds back tag support for metadata pointers.
Don't need the logging anymore.

This reverts commit 7d35644ca7bfa027505f09b9232d34b8191bd42d.
Don't need logging anymore.

This reverts commit 065ab6f61c80c2573d72e1572c751914d42f7a61.
When I build swift code as debuggable, I got the following error:

```
error: couldn't allocate input reg for constraint 'r'
```

This means we can't use `InlineAsm` with registers because WASM doesn't have registers.
Swift uses `InlineAsm` to extend lifetime of variable for debugging. So I changed to avoid to use it.

After this change, we can build swift standard library as debuggable via `./utils/build-script --debug`.

## References
- https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html#Simple-Constraints
Changed to make thunk to convert thin-to-thick and non-throws-to-throws,
We needs it on WebAssembly host because WASM checks number of
arguments strictly for indirect function call.
…ly (#9)

`LIBC_INCLUDE_DIRECTORY` is used to generate `glibc.modulemap`.
Currently the directory is set `/usr/include` but it's system header path and we should use `wasi-sdk` version.
* Add simple GitHub Actions config for macOS
* Add brew install to the macOS GH action
* Add update-checkout call to macOS GH action
* Export sourcedir shell variable in macOS GH action
* [WASM] Use prebuilt llvm-ar only on Linux
* [WASM] Added new Object format WASM to distinguish from ELF
* [WASM] Separate SwiftRT from ELF
* [WASM] Add preprocessor condition for wasm32 to track latest upstream
* Add wasi-sdk and icu install steps to the script
* [WASM] Set LIBC_INCLUDE_DIRECTORY without CACHE attribute to force new value
* [WASM] Adding share path to point correct directory
* [WASM] Add Linux CI job
* [WASM] Checkout branch after checking out Swift repos
* [WASM] Use release build to reduce artifact size
* [WASM] Use SWIFT_PRIMARY_VARIANT_SDK instead of HOST_SDK
In this case, SWIFT_PRIMARY_VARIANT_ARCH is used but host SDK was
not PRIMARY_SDK.
* [WASM] Remove ICU_STATICLIB on Linux
* [WASM] Output build log verbose
* [WASM] Set ICU lib directory instead of archive
* [WASM] Sort build options
* Revert "[WASM] Use SWIFT_PRIMARY_VARIANT_SDK instead of HOST_SDK"
ImageInspectionShared was built only if host OS is Linux. But it's
necessary when primary sdk is WASM.
Specify ar binary through extra-cmake-options
Because WASM doesn't support relative pointer, compiler emit direct
address instead of offset from current address.
kateinoigakukun pushed a commit that referenced this pull request Oct 1, 2021
typelayout_based_value_witness.swift failed on iphoneos-arm64e due to an extra
line of IR that gets generated. That meant the swift_release line had '#7'
instead of '#6'. The test shouldn't be checking for '#6' anyways, so removed
that check which causes the test to now pass.
kateinoigakukun pushed a commit that referenced this pull request Jul 6, 2024
and RefElementAddr_getDecl.

Fixes:
Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h

While running pass swiftlang#224 SILFunctionTransform "LifetimeDependenceDiagnostics"
 #7 0x0000000102d3efcc decltype(auto) llvm::cast<swift::DebugValueInst, swift::SILInstruction>(swift::SILInstruction*)
 #8 0x0000000102d01e24 swift::DebugValueInst* BridgedInstruction::getAs<swift::DebugValueInst>() const
 #9 0x0000000102d01ee4 BridgedInstruction::GlobalAddr_getDecl() const
kateinoigakukun pushed a commit that referenced this pull request Jul 18, 2024
This inserts a suitably named function into the stack trace whenever
a dynamic cast failure involves a NULL source or target type.
Very often, crash logs include backtraces with function names but
no log output; with this change, such a backtrace might look like
the following -- note `TARGET_TYPE_NULL` in the function name
here to mark the missing type information:

```
 frame #0: __pthread_kill + 8
 frame #1: pthread_kill + 288
 frame #2: abort + 128
 frame #3: swift::fatalErrorv()
 frame #4: swift::fatalError()
 frame #5: swift_dynamicCastFailure_TARGET_TYPE_NULL()
 frame #6: swift::swift_dynamicCastFailure()
 frame #7: ::swift_dynamicCast()
```

Resolves rdar://130630157
kateinoigakukun pushed a commit that referenced this pull request Mar 23, 2026
When the host compiler is built with assertions, 'swiftc -parse -'
hits an assertion failure, which fails the capability checks.

```
Assertion failed: [&]() -> bool { if (FrontendOptions::shouldActionOnlyParse(Action)) { return llvm::all_of( opts.InputsAndOutputs.getAllInputs(), [](const InputFile &IF) { const auto kind = IF.getType(); return kind == file_types::TY_Swift || kind == file_types::TY_SwiftModuleInterfaceFile; }); } return true; }() && "Only supports parsing .swift files", file C:\Users\swift-ci\jenkins\workspace\swift-main-windows-toolchain\swift\lib\FrontendTool\FrontendTool.cpp, line 1737
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: S:\\b\\toolchains\\DEVELOPMENT-SNAPSHOT-2025-12-01-a\\LocalApp\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\bin\\swift-frontend.exe -frontend -parse -primary-file - -target x86_64-unknown-windows-msvc -disable-objc-interop -no-color-diagnostics -Xcc -fno-color-diagnostics -disable-implicit-string-processing-module-import -empty-abi-descriptor -no-auto-bridging-header-chaining -module-name main -in-process-plugin-server-path S:\\b\\toolchains\\DEVELOPMENT-SNAPSHOT-2025-12-01-a\\LocalApp\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\bin\\SwiftInProcPluginServer.dll -plugin-path S:\\b\\toolchains\\DEVELOPMENT-SNAPSHOT-2025-12-01-a\\LocalApp\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\bin -plugin-path S:\\b\\toolchains\\DEVELOPMENT-SNAPSHOT-2025-12-01-a\\LocalApp\\Programs\\Swift\\Toolchains\\0.0.0+Asserts\\usr\\local\\bin -autolink-library oldnames -autolink-library msvcrt -Xcc -D_MT -Xcc -D_DLL
1.      Swift version 6.3-dev (LLVM 35f48306184cd25, Swift a69dbb3)
2.      Compiling with effective version 5.10
Exception Code: 0x80000003
 #0 0x00007ff7a6efdda5 (S:\b\toolchains\DEVELOPMENT-SNAPSHOT-2025-12-01-a\LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin\swift-frontend.exe+0x722dda5)
 #1 0x00007ff94d8b1989 (C:\WINDOWS\System32\ucrtbase.dll+0xc1989)
 #2 0x00007ff94d894ab1 (C:\WINDOWS\System32\ucrtbase.dll+0xa4ab1)
 #3 0x00007ff94d8b2986 (C:\WINDOWS\System32\ucrtbase.dll+0xc2986)
 #4 0x00007ff94d8b2b61 (C:\WINDOWS\System32\ucrtbase.dll+0xc2b61)
 #5 0x00007ff7a02d944d (S:\b\toolchains\DEVELOPMENT-SNAPSHOT-2025-12-01-a\LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin\swift-frontend.exe+0x60944d)
 #6 0x00007ff7a02db914 (S:\b\toolchains\DEVELOPMENT-SNAPSHOT-2025-12-01-a\LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin\swift-frontend.exe+0x60b914)
 #7 0x00007ff7a011b19e (S:\b\toolchains\DEVELOPMENT-SNAPSHOT-2025-12-01-a\LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin\swift-frontend.exe+0x44b19e)
 #8 0x00007ff7a011ad57 (S:\b\toolchains\DEVELOPMENT-SNAPSHOT-2025-12-01-a\LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin\swift-frontend.exe+0x44ad57)
 #9 0x00007ff7a6f667d0 (S:\b\toolchains\DEVELOPMENT-SNAPSHOT-2025-12-01-a\LocalApp\Programs\Swift\Toolchains\0.0.0+Asserts\usr\bin\swift-frontend.exe+0x72967d0)
#10 0x00007ff94e6be8d7 (C:\WINDOWS\System32\KERNEL32.DLL+0x2e8d7)
#11 0x00007ff94fe2c40c (C:\WINDOWS\SYSTEM32\ntdll.dll+0x8c40c)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants