SwiftAndroid / swift

Port of Apple's reference Swift toolchain to Android; doesn't quite work yet
Apache License 2.0
720 stars 32 forks source link

find public domain/LLVM code to replace current third-party code #3

Closed zhuowei closed 8 years ago

zhuowei commented 8 years ago

Hopefully I can get around to doing this before someone tries to use this for crypto...

zhuowei commented 8 years ago

A Posix_spawn implementation from FreeBSD (modified to use fork instead of vfork (which is too sketchy)) worked fine.

Looks like the lack of random number generation is being caught in the unit test: test/1_stdlib/ReflectionHashing.swift aborts probably because of missing random.

zhuowei commented 8 years ago

Need to replace the existing getline, posix_spawn, and SunSoft libm stuff with either public domain or LLVM code - https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151221/000547.html

modocache commented 8 years ago

I'd like to work on documenting a list of SwiftAndroid's dependencies, and which of those use incompatible licenses. I'd also like to consider sacrificing some dependencies/Swift features (see https://github.com/SwiftAndroid/swift/commit/1dde6bdfcda2332cda7365e3a3debfd5d80f5709 for an example) in favor of merging this fork upstream. What do you all think?

modocache commented 8 years ago

Is that right?

modocache commented 8 years ago

Is it possible to just tear out the FreeBSD posix_spawn implementation, and instead simply have that functionality unavailable on Android? I guess it isn't, since stdlib/private/SwiftPrivateDarwinExtras/Subprocess.swift and the test suite rely on it so heavily. Hmm...

zhuowei commented 8 years ago

That should be it. The test suite doesn't require a whole lot of functionality from posix_spawn - just redirect file descriptors, if I recall; it might be possible to just rewrite it

modocache commented 8 years ago

I'm looking at https://github.com/apple/swift/blob/e094e9f10ca4a63e195295e74dc852e5dd5a3234/lib/Basic/Unix/TaskQueue.inc#L133, and I bet we could do something similar for the unit tests--using posix_spawn if available, and fork if not.

jckarter commented 8 years ago

posix_spawn is more efficient on Darwin and Win32 (and fork doesn't exist at all in mobile Darwin variants), so we'd prefer that posix_spawn still be used when available.

modocache commented 8 years ago

@jckarter Absolutely. This will just be a fallback for platforms for which posix_spawn is unavailable. :+1:

By the way, I notice swift/lib/Basic/Unix/TaskQueue.inc uses a macro HAVE_POSIX_SPAWN. I don't suppose you know of anything similar I can use in the Swift file swift/stdlib/private/SwiftPrivateDarwinExtras/Subprocess.swift? For the time being I'm using #if os(Android).

modocache commented 8 years ago

This has mostly been taken care of upstream, through a combination of raising the minimum API level and implementing custom workarounds for StdlibUnittest. Still some room for improvement, though: https://bugs.swift.org/browse/SR-1746