-
Notifications
You must be signed in to change notification settings - Fork 30
Build Foundation and enable its test suite #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like without #658 and #647 a very significant chunk of CoreFoundation and Foundation needs to be disabled. This is exacerbated by a lack of proper filesystem APIs. After spending a lot of time on it, I don't think I'm very close to fixing this, even simple APIs like This probably can be revisited after WASI supports threading and dynamic linking properly. |
I've got simple things like The stacktrace I got with
|
@MaxDesiatov Awesome! I think the out of bounds error is due to thin ICU data. Could you try to build ICU disabling https://github.com/swiftwasm/icu4c-wasi/pull/1/files |
Do I need to rebuild the whole SDK with this ICU? Or do you think that swapping ICU |
Yes, it would work because libicudata only has data section. |
That didn't work unfortunately, I've copied It doesn't even seem to be linking with
The only thing I have in import Foundation
print("\(Date())") I also build with {
"version": 1,
"target": "wasm32-unknown-wasi",
"sdk": "/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-05-11-a/usr/share/wasi-sysroot",
"toolchain-bin-dir": "/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-05-11-a/usr/bin/",
"extra-cc-flags": [],
"extra-swiftc-flags": [
"-I", "/Users/maxd/.swiftenv/versions/wasm-DEVELOPMENT-SNAPSHOT-2020-05-11-a/usr/lib/swift/wasi/wasm32",
"-Xlinker", "-lCoreFoundation",
"-Xlinker", "-lBlocksRuntime",
"-Xlinker", "-licui18n",
"-Xlinker", "-luuid"
],
"extra-cpp-flags": []
} I've manually copied Foundation and CoreFoundation libraries to the toolchain directories like But you probably shouldn't spend time on reproducing it in this state, there are too many manual steps here. I'll try to submit a PR soon that copies Foundation into our installable distribution so that this issue could be reproduced more easily. |
Seems like that issue was only reproducible after attempting to call static inline void __CFRuntimeSetValue(CFTypeRef cf, uint8_t n1, uint8_t n2, uint8_t x) {
printf("start of the call to __CFRuntimeSetValue\n");
__CFInfoType info = atomic_load(&(((CFRuntimeBase *)cf)->_cfinfoa));
__CFInfoType newInfo;
__CFInfoType mask = __CFInfoMask(n1, n2);
printf("previous value between bits %d and %d on %p was %d\n", n1, n2, cf, info);
#if !TARGET_OS_WASI
do {
#endif
// maybe don't need to do the negation part because the right side promises that we are not going to touch the rest of the word
newInfo = (info & ~mask) | ((x << n2) & mask);
printf("going to set value between bits %d and %d to %d on %p\n", n1, n2, newInfo, cf);
#if !TARGET_OS_WASI
} while (!atomic_compare_exchange_weak(&(((CFRuntimeBase *)cf)->_cfinfoa), &info, newInfo));
#else
((CFRuntimeBase *)cf)->_cfinfoa = newInfo;
#endif
} When
This is mind-boggling, |
The issues is fixed now here, just a one-liner fix, but took ages to diagnose... 😰
#if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI
static void __CFInitialize(void) __attribute__ ((constructor));
static
#endif We still need to wait for upstream snapshots to be updated as current nightly swift.org snapshots are much older than upstream Or we need to update the CI builds to become multi-stage, which is going to take some time too. We actually have to do that at some point anyway before everything is upstreamed. |
Starting with |
What's the next step with Foundation? Importing it with Curious to know if there's a small project related to Foundation that I could tackle. |
There are still some special flags that you need to pass to link with Foundation, but the There are still many areas of Foundation that aren't supported currently, probably |
Closing this as superseded by #1714. |
We haven't verified how much of the
Foundation
module works on WASI. At a glance there don't seem to be any obvious blockers that prevent something likeFoundationXML
from working, but it's clear thatFoundationNetworking
would have to look quite differently. This needs to be verified by enabling the test suite and checking which of the tests fail.The text was updated successfully, but these errors were encountered: