--skip-build
すればよかったの忘れてた。 (edited)getTopLeveDecls -> getTopLevelDecls silModue -> silModule Evaludate -> Evaluate OptioanlPayload -> OptionalPayload confromance -> conformance chcking -> checking settting -> setting tpye -> type resoved -> resolved ahve -> have ? 🤔
utils/build-script -x --skip-build
したら生成されたXcodeプロジェクトの構成が https://qiita.com/rintaro/items/2047a9b88d9249459d9a#xcode-%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%81%AE%E4%BD%9C%E6%88%90 とは全然違うものになってた。cmake version 3.10.1
--skip-build
だと当然.gyb
は未処理なのね。$ git submodule status +2a14f75cef483ab2537f4559d881356e7950236c clang (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +d875488a6a95d5487b7c675f79a8dafef210a65f cmark (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +c6b8e659bd4a561e65f3d206ef10ef5500a3c445 compiler-rt (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +3aabf3431abc2539f0667ff889d7c9e7eec06178 llbuild (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +fcc6492ef1356fe7d66b3589d932aa0575dc2aab lldb (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a-2-gfcc6492ef) +3e9b847792dc205825321269608dc3abee2494ea llvm (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +253e94c1fa511704baeb61cf69995bbf09ba435e ninja (v1.8.2) +4953262288908cbce5a369a5ca43c4ab870e0e53 swift (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a-15-g4953262288) +414ebffa9784b4bd94d821bcab2c03e9bfccf6c3 swift-corelibs-foundation (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +8b72f761a0df76c8d5be00c12bfff9fab182dce7 swift-corelibs-libdispatch (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +732d9533c70dca9ede2c745b64a11f8c7dc7f824 swift-corelibs-xctest (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +01eecd5a83279635823e78101a538132784bc628 swift-integration-tests (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +4a73bf895b6fd9e5f72aad441869ab597e9e3fc3 swift-xcode-playground-support (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a) +495454c155a68d8fa4a40bc423a345385411bac4 swiftpm (swift-DEVELOPMENT-SNAPSHOT-2018-01-17-a-1-g495454c1)
の様にgit-submodule(1)
で管理してたのだけど、しばらくビルドしてない間にclangがサブモジュールになってるとllvmのビルドに失敗する様になってた。 (edited)$ la llvm/tools/clang lrwxrwxrwx 1 norio staff 11B 7 8 2016 llvm/tools/clang@ -> ../../clang
utils/build-script -x
で生成したXcodeプロジェクトでもテストを走らせられるのね。build/Xcode-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64
以下に生成されたテストスクリプトを実行するという手順で。extension Dictionary { func compactMapValues<T>(_ f: Value -> T?) -> [Key: T] }
(edited)static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] { var destination = [String: String]() for (key, nillableValue) in source { if let value: Any = nillableValue { destination[key] = “\(value)” } } return destination }
func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] { return source.reduce(into: [String: String](), { (result, x) in if let value = x.value else { result[x.key] = "\(value)" } }) }
(edited)else
要らない気が。 if let value = x.value else { result[x.key] = "\(value)" }
else
残ったままです。反映されてない???x.value
の後ろの else ですよね。 とにかくキレイになった。Dictionary
を組み立てるときは inout
版の reduce
いいんですよね〜。map
は update
的なやつですか?それはでも inout
reduce
とはちょっと意味合いが違いますよね?filter
や flatMap
は inout
のイメージがわかないです。update
は僕もほしいですね。が、 John McCall がそれ相当のメソッドを WWDC で取り上げてたから、当然そういうもののニーズを Core Team は把握してて、何らかの理由で追加してないんだと勝手に思ってます。filter
のinoutは、クロージャ版のremove
相当になると思うextension Array { mutating func remove(_ f: (Element) throws -> Bool) rethrows -> Void { self = try self.filter { try !f($0) } } }
こうextension MutableCollection { mutating func modifyEach( _ body : (inout Element) -> ()) { for index in self.indices { body(&self[index]) } } }
extension
書いてます。mutating
な flatMap
は自身の型が変わっちゃうから無理じゃないですか? (edited)self
代入するわけで、メモリ節約できるとかないんで普通に外部で some = some.flatMap { ~ }
ってしちゃうので良い気がするんですがどうですかねif let value = x.value { result[x.key] = "\(value)" }
が if let value = x.value { result[x.key] = value }
の方がよさそうです。mapValues
があって compactMapValues
がないのは変だと想うからありなんじゃないかな?reduce(into:)
もだし。update
( modifyEach
) もほしい・・・。[6/1318] Generating Integers.swift from Integers.swift.gyb with ptr size = 8 FAILED: stdlib/public/core/8/Integers.swift cd .../swift/stdlib/public/core && /usr/local/Cellar/cmake/3.10.2/bin/cmake -E make_directory .../build/Ninja-ReleaseAssert/swift-macosx-x86_64/stdlib/public/core/8 && .../.pyenv/versions/3.6.4/bin/python .../swift/utils/gyb -DunicodeGraphemeBreakPropertyFile=.../swift/utils/UnicodeData/GraphemeBreakProperty.txt -DunicodeGraphemeBreakTestFile=.../swift/utils/UnicodeData/GraphemeBreakTest.txt -DCMAKE_SIZEOF_VOID_P=8 -o .../build/Ninja-ReleaseAssert/swift-macosx-x86_64/stdlib/public/core/8/Integers.swift.tmp Integers.swift.gyb && /usr/local/Cellar/cmake/3.10.2/bin/cmake -E copy_if_different .../build/Ninja-ReleaseAssert/swift-macosx-x86_64/stdlib/public/core/8/Integers.swift.tmp .../build/Ninja-ReleaseAssert/swift-macosx-x86_64/stdlib/public/core/8/Integers.swift && /usr/local/Cellar/cmake/3.10.2/bin/cmake -E remove .../build/Ninja-ReleaseAssert/swift-macosx-x86_64/stdlib/public/core/8/Integers.swift.tmp Traceback (most recent call last): File ".../swift/utils/gyb", line 3, in <module> gyb.main() File ".../swift/utils/gyb.py", line 1257, in main args.target.write(execute_template(ast, args.line_directive, **bindings)) File ".../swift/utils/gyb.py", line 1128, in execute_template ast.execute(execution_context) File ".../swift/utils/gyb.py", line 632, in execute x.execute(context) File ".../swift/utils/gyb.py", line 718, in execute result = eval(self.code, context.local_bindings) File ".../swift/stdlib/public/core/Integers.swift.gyb", line 20, in <module> from string import maketrans, capitalize ImportError: cannot import name 'maketrans'
JSONDecoder.KeyDecodingStrategy
に機能追加するPR書いたけど、evolutionプロセスが必要と言われてから放置してしまってるのを思い出した… https://github.com/apple/swift/pull/14039JSONDecoder
自体は割とどうでも良くて、ヘンテコ(に僕には見える)なconvertFromSnakeCase
を関わってるライブラリに移植したくない、というのがモチベーション。 (edited)$ git config --global clangFormat.binary <swift-source>/build/<tool>-<variant>/llvm-<target>/bin/clang-format
3. swiftリポジトリで変更をステージする(uncommit changeはなくす) 4. $ git clang-format
を実行する 情報ありがとう! @rintaro CC: @giginet @kitasuke (edited)Drive-by nit
で検索したら、他にもあったけど、全部同じxwuさんのコメントだから、単に言い回しがそうなっているというだけですかね。 https://github.com/apple/swift/search?q=Drive-by+nit&type=Issues&utf8=✓ (edited)$ git log --committer=norio.nomura --oneline --no-merges|wc -l 18
Make sure we only unwrap at most one layer of optional.
って書いてあるし、意図してる挙動なのかなぁという気もしてきている if (insideOptional == OptionalUnwrapping::None || insideOptional == OptionalUnwrapping::OptionalToOptional) {
ってことですね? (edited)\x5a1
面白いですよねRUN:
は \
で複数行継続できるので、// RUN: cat %s | sed \ // CC 82 is U+0302, invalid for identifier start, valid for identifier body. // RUN: -e 's/'$(echo -ne "\x5a1")'/'$(echo -ne "\xc2")'/g' \ // E2 80 9D is U+201D, right quote. // RUN: -e 's/'$(echo -ne "\x5a2")'/'$(echo -ne "\xe2\x80\x9d")'/g' \ ... // RUN: > %t
とかもできますよ。 (edited)-e
って複数かけるんですね。#if os(...)
のOSXとmacOSはどうやって定義・管理されているのか気になって見ていたらSupportedConditionalCompilation...
ってのを見ると馴染みがあるstatic const StringRef SupportedConditionalCompilationOSs[] = { "OSX", "macOS", "tvOS", "watchOS", "iOS", "Linux", "FreeBSD", "Windows", "Android", "PS4", "Cygwin", "Haiku", };
(edited)test/decl/class/override.swift
雰囲気Optionalとsubclassの組み合わせに関してテストが書かれてないような感じchar
が signed なら動くが unsigned な世界では壊れるコードを書いてしまった(char)0xFE
, (char)0xFF
にしたいな (edited)initialize()
内で処理しちゃってもいいような。それ以外は default に流すで。 (edited)There is definitely non-accidental history behind why we cannot just test subtyping here. We allow overriding Objective-C methods that take unaudited pointer arguments (imported as IUOs) with Swift methods that take non-optional arguments. There may be other reasons as well.
@objc
にしようぜって話になるし。 (edited)Restart:
消せるの気付かなかったの悔しいwtime swift -frontend -parse デカい.swift
ですよ。protocol Animal
, class Cat: Animal
の場合、返り値のcovarianceはOKクラッシュもしない、引数のcontravarianceはコンパイルエラー protocol Animal
, struct Dog: Animal
の場合、両方ダメninja: error: rebuilding 'build.ninja': subcommand failed
このPRでプッシュしてるコミットでこけます... https://github.com/apple/swift/pull/14963build-script
に --clean
つけるとHowever, I don't think we need to worry about this here. While Swift's hash seed is currently global, I plan to switch to per-instance or per-capacity seeds soon. Either of those would perturb element ordering, eliminating the quadratic behavior.
count
を指定するんじゃダメです。HashMap
はもう少し細やかなコントロールができて、 capacity だけじゃなくて load factor も指定できます。 https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html#HashMap-int-float-ninja: error: rebuilding 'build.ninja': subcommand failed
Set and Dictionary currently use a global random seed; we should perturb that seed with something to eliminate this issue. Simply XORing either the storage address or the capacity to the seed would eliminate the O(n^2) behavior. Per-instance seeding with the storage address is generally a good idea, except in cases where we want repeatable results – in test suites and the like. In those environments, we disable random hash seeding, but these operations should still not regress to quadratic performance. So when a hash seed override is in effect, we should still use the storage capacity as the hash seed.
https://bugs.swift.org/browse/SR-3268?focusedCommentId=33436&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-33436Array
を経由することになって遅くないですか?Dictionary
って chaining じゃないのか。 Robin Hood Hashing って初めて知った。use std::collections::hash_set::HashSet; fn main() { println!("populating..."); let mut one = HashSet::new(); for i in 1..5000000 { one.insert(i); } println!("cloning..."); let mut two = HashSet::new(); for v in one { two.insert(v); } }
print("start") var x: Set<Int> = [] for i in 0 ..< 5000000 { x.insert(i) } print("initialized") var y: Set<Int> = [] for j in x { y.insert(j) } print("copied")
これで実感できます。 Expected Passes : 10703 Expected Failures : 26 Unsupported Tests : 347 -- check-swift-validation-macosx-x86_64 finished -- --- Finished tests for swift --- * 6b13f75ee6 (HEAD -> replace-of-builtin-string-with-constant) Define BUILTIN_NAME constant in `Strings.h` * a5268f8d19 (origin/master, origin/HEAD, master) Merge pull request #15189 from huonw/one-unnamed-owned-argument |\ | * e7002b6413 [AST] ParenType needs enough bits to store ValueOwnership::Owned. * | 96b695b55c [Update-checkout] Update the swift-4.2-branch to match clang, llvm, and compiler-rt branches * | 23d65887c5 Merge pull request #15191 from graydon/nonportable-batch-seed-test-shuffle-specific |\ \ | * | 0cfb0b9c84 [BatchMode] Fix non-portable test that relies on std::shuffle implementation. * | | f9b3e14137 [stdlib] Use Swift-native Character iteration for hasPrefix/Suffix (#14390) * | | a5db08643f Merge pull request #15195 from slavapestov/test-19978257 |\ \ \
swift/utils/build-script --benchmark
を実行してるのですが、指定した任意のBenchmarkのみ実行する方法はありますか?build-script
経由でそのオプションはなさそうですね。{builddir}/swift-macosx-x86_64/bin/Benchmark_O --list
でベンチマーク一覧{builddir}/swift-macosx-x86_64/bin/Benchmark_O {ベンチマーク名}
でそのベンチマークだけ実行ASTMangler
, Remangler
, IRGenMangler
等で使われてるやつです。 https://github.com/apple/swift/blob/master/lib/Demangling/Remangler.cpp#L597:L634Strings.h
に定義するのが良いのかな?良い加減太って来たぞw このPRがマージされそうな雰囲気出てるから良いんだろうけど... https://github.com/apple/swift/pull/14963SWIFT_SHIMS_NAME
とかがあったからlib/Demangling
lib/AST/ASTMangler
lib/IRGen/IRGenManger
がそれぞれ何の役割なのかも知らないレベル。char
での switch
で分岐しまくるのが一番速度が出るわけで、定数化するメリットは感じずらいことが多いと思う。 (edited)const char str[] = "B";
switch (...) { case str[0]: ...; }
(edited)pending-proposal
になってるんですけど、この場合、こちらから何かすることありますか? (edited)build-script -x
で生成した xcodeproj の グループ構成が変わったのは CMake のバージョンによるものでは無かったみたいです。 (edited)Sequence
の first(where
の作り方、バグってますよね?forEach
はthrow
しないと途中で止められないから?forEach
は全部for in
で書かれてるぽい?first(where
のちょろっと上にforEachがfor inで実装されてるんですけど...最適化のかかり方が変わるとかですかね?struct Foo : Sequence { struct Iterator : IteratorProtocol { mutating func next() -> Int? { return nil } } func makeIterator() -> Foo.Iterator { return Iterator() } func forEach(_ body: (Int) throws -> Void) rethrows { try body(1) try body(2) try body(3) } } let a = Foo() let b = a.first(where: { $0 == 2 }) print(b)
こういう場合に Iterator
が使われずに forEach
が呼ばれるので、Iterator
のオーバーヘッドを背負う必要がなくなるということですね。So there is no guarantee that the allocated memory is really located on the stack.
のセンテンスが、今はもう嘘だから直さない?って事?If a type is runtime-sized, the compiler must emit code to potentially dynamically allocate memory. So there is no guarantee that the allocated memory is really located on the stack.
DynamicAlloca
とかIGF.createFixedSizeBufferAlloca(name);
から emitDynamicAlloca(IGF, T, isInEntryBlock);
に変わってる。--skip-build-benchmarks
がすごく速く打てるようになってきました。--debug
でも以前はそんなに気にならなかったと。Osize
はそれが導入されてから以降なので最近といえば最近です。Ounchecked
がビルドされていたみたいなので、対して変化はなさそう。sw2.Animal.init
が $S3sw26AnimalCACycfc
になるマングリング理解したAC
のところがやべえわ$lldb expr Type.Dump()
で中途半端に解決しました (edited)p x->dump()
works fine, but what about vectors? For example SmallVectorImpl
doesn’t offer dump()
, and I can’t even get it’s size: error: Couldn't lookup symbols: __ZNK4llvm25SmallVectorTemplateCommonIN5swift11const...import Builtin
がASTPrinterに反映されちゃうんですよね printSILWitnessTables(PrintCtx, getWitnessTableList()); printSILDefaultWitnessTables(PrintCtx, getDefaultWitnessTableList());
/// A mapping from each requirement of a protocol to the SIL-level entity /// satisfying the requirement for a concrete type. class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>, public SILAllocated<SILWitnessTable>
/// A mapping from each requirement of a protocol to the SIL-level entity /// satisfying the requirement for conformances which do not explicitly /// provide a witness. class SILDefaultWitnessTable : public llvm::ilist_node<SILDefaultWitnessTable>, public SILAllocated<SILDefaultWitnessTable>
-enable-resilience
のときに出力される、protocol extension のデフォルト実装のテーブルっていう事なんですが、僕もよく知らないです。public protocol P { func foo() func bar() } extension P { public func foo() {} }
(edited)public protocol P { func foo() func bar() } extension P { public func foo() {} }
swift-4.1.1-RELEASE
<unknown>:0: error: unknown argument: '-frontend' <unknown>:0: error: unknown argument: '-enable-resilience' <unknown>:0: error: option '-emit-sil' is not supported by 'swift'; did you mean to use 'swiftc'?
-frontend
だめか。sil_default_witness_table P { method #P.foo!1: <Self where Self : P> (Self) -> () -> () : @$S4test1PP3fooyyF // test.P.foo() -> () no_default }
swiftc
ではなくswift
なので、-Xfrontend
を使ってください。 @swift-4.1.3 -Xfrontend -enable-resilience -Xfrontend -emit-sil public protocol P { func foo() func bar() } extension P { public func foo() {} }
sil_stage canonical import Builtin import Swift import SwiftShims public protocol P { func foo() func bar() } extension P { public func foo() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // P.foo() sil private [transparent] [thunk] @_T04main1PP3fooyyF : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () { // %0 // user: %2 bb0(%0 : $*τ_0_0): // function_ref P.foo() %1 = function_ref @_T04main1PPAAE3fooyyF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () // user: %2 %2 = apply %1<τ_0_0>(%0) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () %3 = tuple () // user: %4 return %3 : $() // id: %4 } // end sil function '_T04main1PP3fooyyF' // P.foo() sil @_T04main1PPAAE3fooyyF : $@convention(method) <Self where Self : P> (@in_guaranteed Self) -> () { // %0 // user: %1 bb0(%0 : $*Self): debug_value_addr %0 : $*Self, let, name "self", argno 1 // id: %1 %2 = tuple () // user: %3 return %2 : $() // id: %3 } // end sil function '_T04main1PPAAE3fooyyF' sil_default_witness_table P { method #P.foo!1: <Self where Self : P> (Self) -> () -> () : @_T04main1PP3fooyyF // main.P.foo() -> () no_default }
public protocol P { func foo() func bar() } extension P { public func foo() {} }
sil_stage canonical import Builtin import Swift import SwiftShims public protocol P { func foo() func bar() } extension P { public func foo() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // P.foo() sil @_T04main1PPAAE3fooyyF : $@convention(method) <Self where Self : P> (@in_guaranteed Self) -> () { // %0 // user: %1 bb0(%0 : $*Self): debug_value_addr %0 : $*Self, let, name "self", argno 1 // id: %1 %2 = tuple () // user: %3 return %2 : $() // id: %3 } // end sil function '_T04main1PPAAE3fooyyF'
--clean
でもいいですが。(lldb) p argv (llvm::SmallVector<const char *, 256>) $0 = { llvm::SmallVectorImpl<const char *> = { llvm::SmallVectorTemplateBase<const char *, true> = { llvm::SmallVectorTemplateCommon<const char *> = { llvm::SmallVectorBase = (BeginX = 0x00007ffeeadd2d28, EndX = 0x00007ffeeadd2d90, CapacityX = 0x00007ffeeadd3528) FirstEl = { llvm::AlignedCharArray<8, 8> = (buffer = char [8] @ 0x00007fcf3885f218) } } } } Storage = { InlineElts = { [0] = { llvm::AlignedCharArray<8, 8> = (buffer = char [8] @ 0x00007fcf3885f220) } [1] = { llvm::AlignedCharArray<8, 8> = (buffer = char [8] @ 0x00007fcf3885f228) } [2] = { llvm::AlignedCharArray<8, 8> = (buffer = char [8] @ 0x00007fcf3885f230) }
(lldb) command script import /Users/omochi/work/swift-source/llvm/utils/lldbDataFormatters.py (lldb) p argv (llvm::SmallVector<const char *, 256>) $3 = ([0] = "/Users/omochi/work/swift-source/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/bin/swift", [1] = "-frontend", [2] = "-emit-ir", [3] = "-primary-file", [4] = "a.swift", [5] = "-target", [6] = "x86_64-apple-darwin17.6.0", [7] = "-enable-objc-interop", [8] = "-color-diagnostics", [9] = "-module-name", [10] = "a", [11] = "-o", [12] = "-")
StringRef
とかですか?swift/utils/build-script
)終わった。 (edited)--ninja --debug
なので --xcode
の問題っぽいですね。--xcode --debug
付きも試してみる。error: Build input file cannot be found: '/Users/norio/github/swift-dev/build/Xcode-DebugAssert/swift-macosx-x86_64/lib/Syntax/8/Trivia.cpp' ** BUILD FAILED ** The following build commands failed: CompileC /Users/norio/github/swift-dev/build/Xcode-DebugAssert/swift-macosx-x86_64/lib/Syntax/Swift.build/Debug/swiftSyntax.build/Objects-normal/x86_64/Trivia.o /Users/norio/github/swift-dev/build/Xcode-DebugAssert/swift-macosx-x86_64/lib/Syntax/8/Trivia.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (1 failure) swift/utils/build-script: fatal error: command terminated with a non-zero exit status 65, aborting swift/utils/build-script --xcode --debug 318.61s user 85.88s system 10% cpu 1:05:10.49 total
/Users/norio/github/swift-dev/build/Xcode-DebugAssert/swift-macosx-x86_64/lib/Syntax/8/Trivia.cpp
自体は存在してる。clang: error: no such file or directory: '/Users/norio/github/swift-dev/build/Xcode-DebugAssert/swift-macosx-x86_64/stdlib/public/stubs/Swift.build/Debug/swiftStdlibStubs-macosx-x86_64.build/Objects-normal/undefined_arch/dummy.o' ** BUILD FAILED ** The following build commands failed: Ld /Users/norio/github/swift-dev/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/lib/swift/macosx/x86_64/libswiftCore.dylib normal x86_64 (1 failure) swift/utils/build-script: fatal error: command terminated with a non-zero exit status 65, aborting swift/utils/build-script --xcode --debug 33.72s user 6.88s system 1% cpu 40:17.78 total
これでSR-7959とSR-7961の両方をコンプリート。*.o
が見つからないのは僕も踏んだやつです。clang: error: no such file or directory: '/Users/omochi/work/swift-source/build/Xcode-DebugAssert/swift-macosx-x86_64/stdlib/public/runtime/Swift.build/Debug/swiftRuntime-macosx-x86_64.build/Objects-normal/undefined_arch/AnyHashableSupport.o' clang: error: no such file or directory: '/Users/omochi/work/swift-source/build/Xcode-DebugAssert/swift-macosx-x86_64/stdlib/public/runtime/Swift.build/Debug/swiftRuntime-macosx-x86_64.build/Objects-normal/undefined_arch/Array.o' clang: error: no such file or directory: '/Users/omochi/work/swift-source/build/Xcode-DebugAssert/swift-macosx-x86_64/stdlib/public/runtime/Swift.build/Debug/swiftRuntime-macosx-x86_64.build/Objects-normal/undefined_arch/Casting.o'
brew install --HEAD cmake
) https://t.co/u0J4lxbMfNcmake
を更新してbuild-script --xcode --release --clean
通った。 echo Build\ all\ projects Build all projects ** BUILD SUCCEEDED ** [2580.828 sec] swift/utils/build-script --xcode --release --clean 20093.85s user 1040.46s system 312% cpu 1:52:47.09 total
just a heads-up, I will be kicking off the review of your proposal tomorrow, running through the following Monday. It's a pretty non-controversial proposal :) so I don't expect many issues in the review but just wanted to let you know.
(edited)!!
スレよく伸びるよね(lldb) p PrintOptions() error: Couldn't lookup symbols: __ZNSt3__18functionIFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPKN5swift9ValueDeclEEEC1Ev __ZNSt3__18functionIFbPKN5swift13ExtensionDeclEEEC1Ev __ZNSt3__16vectorIN5swift11AnyAttrKindENS_9allocatorIS2_EEEC1Ev __ZNSt3__110shared_ptrIN5swift18ShouldPrintCheckerEEC1Ev
ty->getString()
は lldb で通らないってことなんですよね?(lldb) p type->getString() error: too few arguments to function call, expected 1, have 0 'getString' declared here
xcrun --show-sdk-path
が /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
を返す問題、xcrun --show-sdk-path --sdk macosx
とすればちゃんと/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
を返すことが分かった。swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-21-a
で直ったのを確認した。first(where:)
とかあるぐらいなので、こんなのも通るのかなと思ってるこの頃 extension Sequence { @inlinable public func indices( where predicate: (Element) throws -> Bool ) rethrows -> [Int] { return try self.enumerated().compactMap({ if try predicate($0.element) { return $0.offset } return nil }) } } let array = [1,2,3,4,5,6,7,8] print(array.indices(where: { $0 % 2 == 0})) //[1, 3, 5, 7]
Collection.indices
があります。@d_date さんのこれとは意味合いが違うので混乱しそう。Collection.indices(where:) -> [Self.Index]
のほうが筋がいいと思います。 が、 indices(where:)
だと Index
/Element
どちらに対しての条件なのかわかりにくいので、ネーミングが難しい。Collection.firstIndex(where:)
とか BidirectionalCollection.lastIndex(where:)
の仲間になると思うんですが、それはそうと、 lastIndex(where:)
が Collection
にないのには理由があるのかな。var a = AnyCollection([1,2,3]) let idxs = a.indices print(idxs)
lastIndex(where:)
は Complexity: O(*n*), where *n* is the length of the collection.
で定義されているので 生 Collection でも OK っちゃあ OK なんですけどね。firstIndex(where:)
も O(n)
定義ですよ。firstIndex
が先頭から X% のあたりに存在してることを期待しても O(n) で、先頭から M 個以内に存在することを期待してる場合だけが O(1) な気が。lastIndex(where:)
が Collection
にない理由。Array
には popFirst
はないけど ArraySlice
には popFirst
がある。startIndex
を Array
ではずらせないからか。Sequence
になってるんだけど、 firstIndex(where:)
は Collection
で、 lastIndex(where:)
は BidirectionalCollection
だなーと思ったのがぼくの疑問の発端で。extension Collection { @inlinable public func indices( where predicate: (Element) throws -> Bool ) rethrows -> [Index] { return try indices.filter { try predicate(self[$0]) } } }
enumerated().compactMap { predicate($0.element) ? $0.index : nil }
(edited)Sequence
にはインデックスの概念がないから、 Collection
に生やすのがいいのか。indices.filter
無駄がありそうな気がしたけど、 Array.Indices
は Range<Int>
なのか。enumerated()
で列挙されるタプルの index
は、 Collection
の Index
とは違うのね。pred: (T) -> U?
があるときに、 最初の U
を得るcomapctMap(pred).first
だと効率悪いからfirst(where:)
だと T
を得ちゃうのよなmapFirst
でも普通に lazy.map(...).first
じゃない?compactMap(pred).first
を lazy.compactMap(pred).first
と書けば最適なのはわかるけど、 それが一番良い状態なのかなあという疑問。lazy.
に込められた意味がおもすぎるというかcompactMapFirst(pred)
だったらlazy
の価値は 空間効率の良さのほうが大きいとおもいますね。lazy
じゃない filter
だと空間効率ばかにならない。first
とかでなくても a.filter { $0 % 2 == 0 }.reduce(0, +)
とかでも lazy
入れないと filter
で作られる Array
が使い捨てされて無駄だから lazy
入れた方がお行儀がいいと思う。.lazy
に込めてる気持ちの強さが場合によって結構異なっているのにlazy
状態だしなぁ。無駄があるなら lazy
くらいカジュアルに使ってもいい気が。 (edited)lazy
はちょっと違う様な。Sequence
関係で必要なものを必要なだけ計算させるという意味で同じ役割を果たせるケースが多いと思います。Sequence where Element == Optional<T>
に、の意図ですよね
Optional<T> { func compacted() throws -> T }
というのをイメージしてたんですがerrorに情報ないんで意味がないな… Sequence where Element == Optional<T>
でなら意味あるかもしんないけどOptional
の flatMap
も同じく map
+ flatten
で実装されてないはずですね。 flatten
が作れないので。func compacted() throws -> T
があったとしても、 compactMap
でrethrowsされちゃいけないので、たぶん結局 try?
してOptionalに変換することになるんですよね 何も意味がない 他のユースケースでも大抵そうなりそうswift-DEVELOPMENT-SNAPSHOT-2018-10-19
のLinuxツールチェイン、import Dispatch
でエラーになる/Applications/Xcode.app/Contents/MacOS/Xcode -DVTDefaultToolchainOverrideIdentifer org.swift.42120181030a
で指定のToolchainを使うXcodeのインスタンスを起動できるよ。libxpc.dylib
のAPI内でクラッシュする様になってしまった。Please test with the following pull request apple/swift-corelibs-xctest#240 @swift-ci test
master
はXcode 10.1添付のtoolchainではビルド出来なかった。 (edited)swift-5.0-DEVELOPMENT-SNAPSHOT-2019-01-22-a
でビルド出来た。build-script
ならイケたのだろうか。String.Index.init(encodedOffset:)
のパラメータの意味合いがこっそり変わっているのが原因で、他にも影響を受けているところがありそう。`String.Index.encodedOffset` doesn't necessarily mean UTF16 offset.
とか書いてるな。今までUTF-16オフセットとしてたのが間違いだったのかな?ここにもThe current Swift toolchainとあります
なるほど。import Foundation func printOffset(_ string: String, as name: String) { let offset = string.endIndex.encodedOffset print(""" endIndex.encodedOffset is \(offset) that same with \( offset == string.utf8.distance(from: string.startIndex, to: string.endIndex) ? "utf8" : offset == string.utf16.distance(from: string.startIndex, to: string.endIndex) ? "utf16" : "unknown" ) offset (\(name)) """) } let string = "😀" printOffset(string, as: "String") let nsstring = NSString(data: string.data(using: .utf8)!, encoding: String.Encoding.utf8.rawValue)! as String printOffset(nsstring, as: "String created by NSString API")
(edited)endIndex.encodedOffset is 4 that same with utf8 offset (String) endIndex.encodedOffset is 4 that same with utf8 offset (String created by NSString API)
(edited)endIndex.encodedOffset is 2 that same with utf16 offset (String) endIndex.encodedOffset is 2 that same with utf16 offset (String created by NSString API)
(edited)String.Index.encodedOffset
はUTF-16のオフセット。 Swift 5ではUTF-8とUTF-16が混在し、 Linuxだと(常に?)UTF-8 macOSだとNativeなString
はUTF-8、NSString API
で作ったString
はUTF-16になる。 $ xcrun --toolchain org.swift.5020190122a swift test.swift endIndex.encodedOffset is 4 that same with utf8 offset (String) endIndex.encodedOffset is 2 that same with utf16 offset (String created by NSString API) $ xcrun --toolchain org.swift.42120181030a swift test.swift endIndex.encodedOffset is 2 that same with utf16 offset (String) endIndex.encodedOffset is 2 that same with utf16 offset (String created by NSString API)
(edited)String.UTF8View.Index
とString.UTF16View.Index
のどちらもString.Index
へのtypealias
になってます。var encodedOffset: Int
はUTF-16のオフセットだと決め打ちしてInt
を取り出し、UTF16のオフセットとして計算し、それを使ってString.Index.init(encodedOffset:)
を呼び出していたコードです。var encodedOffset
とかはinternalだから、Swift Foundation内部実装での話ってことですよね?encodedOffset
はpublic
ですよ。extension String.Index { /// Creates a new index at the specified UTF-16 offset. /// /// - Parameter offset: An offset in UTF-16 code units. public init(encodedOffset offset: Int) /// The offset into a string's UTF-16 encoding for this index. public var encodedOffset: Int { get } ...
UTF8Vewi.Index
もUTF16View.Index
もどちらもencodedOffset
は同じ値を返してました。(UTF-16ベース) @swift-4.2.4 @swift-5.0.3
import Foundation let string = "\u{1F600}" print(""" utf8.endIndex.encodedOffset: \(string.utf8.endIndex.encodedOffset) utf16.endIndex.encodedOffset: \(string.utf16.endIndex.encodedOffset) distance in utf8: \(string.utf8.distance(from: string.startIndex, to: string.endIndex)) distance in utf16: \(string.utf16.distance(from: string.startIndex, to: string.endIndex)) """)
(edited)utf8.endIndex.encodedOffset: 2 utf16.endIndex.encodedOffset: 2 distance in utf8: 4 distance in utf16: 2
(edited)utf8 encodedOffset: 4 utf16 encodedOffset: 4 utf8 distance: 4 utf16 distance: 2
(edited)しかも元々UTF-16換算であるとして明記されているのか
表面上見える変化としてはコメントからUTF-16明記が削除されただけで、注意喚起とか何も無い。String
がUTF-8とUTF-16のどちらをencodedOffset
として使っているかは、startIndex
とendIndex
の距離を計算し、それをendIndex.encodedOffset
と比較してみないと分からない。 (edited)NSRange
とか作るときにうっかりencodedOffset
を使っていないか、確認しないとマズイです。utf8.endIndex.encodedOffset: 4 utf16.endIndex.encodedOffset: 4 distance in utf8: 4 distance in utf16: 2
NSString
のAPIがNSRange
で返してきたものをRange<String.Index>
へ変換する際に使われてた。 /// Return an `Index` corresponding to the given offset in our UTF-16 /// representation. func _index(_ utf16Index: Int) -> Index { - return Index(encodedOffset: utf16Index + _substringOffset) + return self.utf16.index(self.utf16.startIndex, offsetBy: utf16Index) }
https://github.com/apple/swift-corelibs-foundation/pull/1841/commits/de8eaceaa0b8c23ade0690f80c094c3304d31667#diff-45748247f2cea16dbd8450b033d6654fR446String.Index
のencodedOffset
についてissue書いた。 https://bugs.swift.org/browse/SR-9749encodedOffset
とinit(encodedOffset:)
を@available(swift, deprecated: 4.2, obsoleted: 5.0,…)
にして、String.Index.utf16CodeUnitOffset(with:)
, String.Index.utf8CodeUnitOffset(with:)
, String.Index.init(utf16CodeUnitOffset:within:)
, String.Index.init(utf16CodeUnitOffset:within:)
を新設するPR来た! https://github.com/apple/swift/pull/22108 (edited)▿ // A closure without a signature. The test will ensure it stays the same after // applying a rewriting pass. let x: () -> Void = {} ▿ data: SwiftSyntax.SyntaxData - parent: nil ▿ absoluteRaw: SwiftSyntax.AbsoluteRawSyntax - raw: // A closure without a signature. The test will ensure it stays the same after // applying a rewriting pass. let x: () -> Void = {} #0 ▿ super: Swift.ManagedBuffer<SwiftSyntax.RawSyntaxBase, Swift.UInt64> ▿ header: SwiftSyntax.RawSyntaxBase ...
This patch improve this result to the following: ▿ SourceFileSyntax ▿ statements: CodeBlockItemListSyntax ▿ 0: CodeBlockItemSyntax ▿ item: VariableDeclSyntax - attributes: nil - modifiers: nil ▿ letOrVarKeyword: TokenSyntax - text: "let" ▿ leadingTrivia: SwiftSyntax.Trivia ▿ pieces: 4 elements ▿ TriviaPiece - lineComment: "// A closure without a signature. The test will ensure it stays the same after" ...
kw_weak
が無い気がするんですが、これって実装するの難しいんですか? SwiftSyntaxで @IBOutlet private weak var button: UIButton!
のweakが identifier
になってたので、この文脈なら weakKeyword
になってほしかった (edited)class View { @IBOutlet private weak var button: UIButton! }
(edited){"id":34,"kind":"SourceFile","layout":[{"id":33,"kind":"CodeBlockItemList","layout":[{"id":30,"kind":"CodeBlockItem","layout":[{"id":29,"kind":"ClassDecl","layout":[null,null,{"id":1,"tokenKind":{"kind":"kw_class"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":2,"tokenKind":{"kind":"identifier","text":"View"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,{"id":28,"kind":"MemberDeclBlock","layout":[{"id":3,"tokenKind":{"kind":"l_brace"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":26,"kind":"MemberDeclList","layout":[{"id":25,"kind":"MemberDeclListItem","layout":[{"id":24,"kind":"VariableDecl","layout":[{"id":7,"kind":"AttributeList","layout":[{"id":6,"kind":"Attribute","layout":[{"id":4,"tokenKind":{"kind":"at_sign"},"leadingTrivia":[{"kind":"Newline","value":1},{"kind":"Space","value":2}],"trailingTrivia":[],"presence":"Present"},{"id":5,"tokenKind":{"kind":"identifier","text":"IBOutlet"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,null],"presence":"Present"}],"presence":"Present"},{"id":12,"kind":"ModifierList","layout":[{"id":9,"kind":"DeclModifier","layout":[{"id":8,"tokenKind":{"kind":"kw_private"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null],"presence":"Present"},{"id":11,"kind":"DeclModifier","layout":[{"id":10,"tokenKind":{"kind":"identifier","text":"weak"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null],"presence":"Present"}],"presence":"Present"},{"id":13,"tokenKind":{"kind":"kw_var"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":23,"kind":"PatternBindingList","layout":[{"id":22,"kind":"PatternBinding","layout":[{"id":15,"kind":"IdentifierPattern","layout":[{"id":14,"tokenKind":{"kind":"identifier","text":"button
(edited)kw_weak
はなかったweak
はcontextual keywordで、場所によってキーワードにならないので、Parser都合でそうなってますね。private
やvar
はどこでもキーワードってことですか?var weak: Int = 0 // var var: Int = 1 // var private: Int = 2
bool isContextualKeyword(StringRef ContextKW) const { return is(tok::identifier) && !isEscapedIdentifier() && Text == ContextKW; }
(edited)CONTEXTUAL_SIMPLE_DECL_ATTR(final, Final, CONTEXTUAL_SIMPLE_DECL_ATTR(required, Required, CONTEXTUAL_SIMPLE_DECL_ATTR(optional, Optional, CONTEXTUAL_SIMPLE_DECL_ATTR(lazy, Lazy, DeclModifier | CONTEXTUAL_SIMPLE_DECL_ATTR(dynamic, Dynamic, CONTEXTUAL_SIMPLE_DECL_ATTR(infix, Infix, CONTEXTUAL_SIMPLE_DECL_ATTR(prefix, Prefix, CONTEXTUAL_SIMPLE_DECL_ATTR(postfix, Postfix, CONTEXTUAL_SIMPLE_DECL_ATTR(__consuming, Consuming, CONTEXTUAL_SIMPLE_DECL_ATTR(mutating, Mutating, CONTEXTUAL_SIMPLE_DECL_ATTR(nonmutating, NonMutating, CONTEXTUAL_SIMPLE_DECL_ATTR(convenience, Convenience, CONTEXTUAL_SIMPLE_DECL_ATTR(override, Override, CONTEXTUAL_DECL_ATTR_ALIAS(open, AccessControl) CONTEXTUAL_DECL_ATTR(weak, ReferenceOwnership, CONTEXTUAL_DECL_ATTR_ALIAS(unowned, ReferenceOwnership) CONTEXTUAL_SIMPLE_DECL_ATTR(indirect, Indirect, DeclModifier |
struct Contextuals { var final: Int? var required: Int? var optional: Int? var lazy: Int? var dynamic: Int? var infix: Int? var prefix: Int? var postfix: Int? var __consuming: Int? var mutating: Int? var nonmutating: Int? var convenience: Int? var override: Int? var open: Int? var weak: Int? var unowned: Int? var indirect: Int? }
...
) token kind 追加したし、やるなら今な気がする。class View { @IBOutlet private(set) var button: UIButton! var number: Int { get { return number } set { number = 1 } } }
{"id":70,"kind":"SourceFile","layout":[{"id":69,"kind":"CodeBlockItemList","layout":[{"id":66,"kind":"CodeBlockItem","layout":[{"id":65,"kind":"ClassDecl","layout":[null,null,{"id":1,"tokenKind":{"kind":"kw_class"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":2,"tokenKind":{"kind":"identifier","text":"View"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,{"id":64,"kind":"MemberDeclBlock","layout":[{"id":3,"tokenKind":{"kind":"l_brace"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":62,"kind":"MemberDeclList","layout":[{"id":26,"kind":"MemberDeclListItem","layout":[{"id":25,"kind":"VariableDecl","layout":[{"id":7,"kind":"AttributeList","layout":[{"id":6,"kind":"Attribute","layout":[{"id":4,"tokenKind":{"kind":"at_sign"},"leadingTrivia":[{"kind":"Newline","value":1},{"kind":"Space","value":4}],"trailingTrivia":[],"presence":"Present"},{"id":5,"tokenKind":{"kind":"identifier","text":"IBOutlet"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,null],"presence":"Present"}],"presence":"Present"},{"id":13,"kind":"ModifierList","layout":[{"id":12,"kind":"DeclModifier","layout":[{"id":8,"tokenKind":{"kind":"kw_private"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":9,"tokenKind":{"kind":"l_paren"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":10,"tokenKind":{"kind":"identifier","text":"set"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":11,"tokenKind":{"kind":"r_paren"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},{"id":14,"tokenKind":{"kind":"kw_var"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":24,"kind":"PatternBindingList","layout":[{"id":23,"kind":"PatternBinding","layout":[{"id":16,"kind":"Iden
XCTAssertEqual failed: ("▿ SwiftSyntax.ReversedTokenSequence ▿ node: SwiftSyntax.ArrayExprSyntax ▿ leftSquare: SwiftSyntax.TokenSyntax - text: "]" ▿ leadingTrivia: SwiftSyntax.Trivia - pieces: 0 elements ▿ trailingTrivia: SwiftSyntax.Trivia - pieces: 0 elements - tokenKind: SwiftSyntax.TokenKind.rightSquareBracket ▿ rightSquare: SwiftSyntax.TokenSyntax - text: "[" ▿ leadingTrivia: SwiftSyntax.Trivia - pieces: 0 elements ▿ trailingTrivia: SwiftSyntax.Trivia - pieces: 0 elements - tokenKind: SwiftSyntax.TokenKind.leftSquareBracket ") is not equal to ("▿ SwiftSyntax.ReversedTokenSequence ▿ node: SwiftSyntax.ArrayExprSyntax ▿ leftSquare: SwiftSyntax.TokenSyntax - text: "[" ▿ leadingTrivia: SwiftSyntax.Trivia - pieces: 0 elements ▿ trailingTrivia: SwiftSyntax.Trivia - pieces: 0 elements - tokenKind: SwiftSyntax.TokenKind.leftSquareBracket - elements: SwiftSyntax.ArrayElementListSyntax ▿ rightSquare: SwiftSyntax.TokenSyntax - text: "]" ▿ leadingTrivia: SwiftSyntax.Trivia - pieces: 0 elements ▿ trailingTrivia: SwiftSyntax.Trivia - pieces: 0 elements - tokenKind: SwiftSyntax.TokenKind.rightSquareBracket ")
utils/build-script --release --foundation --xctest --test --jobs 1
です。最初はハマって、おもちさんの去年のやりとりがなかったら解決できなかった。build/Ninja-ReleaseAssert/foundation-linux-x86_64
にbuild.ninjaができてました。が、そこで、ninja test
とやっても No tests were found!!!
になっちゃいました $ ninja
しなさいって書いてあるんですね う〜む、前やったときは文書通りにいけたと思うんですが・・・--foundation --xctest --test
を渡して実行しても、本体側の?テストケースは実行されるっぽいけど、Foundation側のテストは実行されてないっぽいんですよね。cmake --build ../build/Ninja-ReleaseAssert/foundation-linux-x86_64 -- TestFoundation
とかやってみましたが、 ninja: error: unknown target 'TestFoundation'
ですね。ターゲットってどこで決まるんでしょう。そもそもCMake知らないんですよ。。。if(ENABLE_TESTING)
で括られてるな。set(ENABLE_TESTING YES)
を追加したのち cmake --build ../build/Ninja-ReleaseAssert/foundation-linux-x86_64 -- -j1 TestFoundation
を実行すると、TestFoundationのビルドに入って一歩前進しましたが、 error: no such module 'XCTest'
でエラーになったので、XCTestがビルドされていないか参照する扱いになっていない様子で一歩後退。Skipping Foundation on OS X -- use the Xcode project instead
ENABLE_TESTING
をYESにして、さらに FOUNDATION_PATH_TO_XCTEST_BUILD
にbuild/Ninja-ReleaseAssert/xctest-linux-x86_64 のパスを入れてやったらいけるんじゃないか!と思ってやっているところですが、子供を迎えにいく時間になった。。。やばい。ENABLE_TESTING
を YES
に、 FOUNDATION_PATH_TO_XCTEST_BUILD
に build/Ninja-ReleaseAssert/xctest-linux-x86_64 へのフルパスに、 書き換えて、swift-corelibs-foundationの下で /usr/bin/cmake --build ../build/Ninja-ReleaseAssert/foundation-linux-x86_64 -- -j1 TestFoundation
でテストのビルド、そして /usr/bin/cmake --build ../build/Ninja-ReleaseAssert/foundation-linux-x86_64 -- -j1 test
でテストの実行。テストコケたのと、どこでコケたのかさっぱりわからない点をのぞいて、とりあえずテストを動かしたかった部分は前進しました。CFXML*
系を使ってないんじゃないかな。 (edited)******************** Testing Time: 1232.07s ******************** Failing Tests (4): Swift(linux-x86_64) :: ParseableInterface/ModuleCache/force-module-loading-mode-archs.swift Swift(linux-x86_64) :: Index/Store/output-failure.swift Swift(linux-x86_64) :: ParseableInterface/ModuleCache/force-module-loading-mode-framework.swift Swift(linux-x86_64) :: ParseableInterface/ModuleCache/force-module-loading-mode.swift Expected Passes : 4104 Expected Failures : 22 Unsupported Tests : 1124 Unexpected Failures: 4 2 warning(s) in tests. FAILED: test/CMakeFiles/check-swift-linux-x86_64 cd /root/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/test && /usr/bin/cmake -E remove_directory /root/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/./swift-test-results/x86_64-unknown-linux-gnu && /usr/bin/cmake -E make_directory /root/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/./swift-test-results/x86_64-unknown-linux-gnu && /usr/bin/python /root/swift-source/llvm/utils/lit/lit.py --incremental -sv --xunit-xml-output=/root/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/./swift-test-results/x86_64-unknown-linux-gnu/lit-tests.xml --param swift_test_subset=primary --param swift_test_mode=optimize_none /root/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64 ninja: build stopped: subcommand failed. utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:7:8: error: no such module '_SwiftAppKitOverlayShims' import _SwiftAppKitOverlayShims ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:1:1: error: failed to build module 'AppKit' from its module interface; the compiler that produced it, 'Apple Swift version 5.2 (swiftlang-1103.8.25.8 clang-1103.0.30.20)', may have used features that aren't supported by this compiler, 'Swift version 5.3-dev (LLVM f59d544d626dfee, Swift cc01438bca1bae7)' // swift-interface-format-version: 1.0 ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:7:8: error: no such module '_SwiftAppKitOverlayShims' import _SwiftAppKitOverlayShims ^
/home/buildnode/jenkins/workspace/swift-corelibs-foundation-PR-Linux/swift-corelibs-foundation/Sources/Foundation/NSData.swift:464:30: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions 16:20:59 let createMode = Int(S_IREAD | S_IWRITE | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) 16:20:59 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(edited)let createMode: Int = Int()
って教えてあげないとだめ...?#define
ってSwiftから見て何にインポートされてるんだろう?Int32
になってないのかなC
文法的にそのままインポートされてるならリテラルになっていてInt()
だから Int
の fast pathでいけそうなんだよな#if os(Windows) let createMode = Int(ucrt.S_IREAD | ucrt.S_IWRITE) #else let createMode = Int(S_IREAD | S_IWRITE | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) #endif guard let fh = FileHandle(path: path, flags: flags, createMode: createMode) else {
FileHandle()
がInt
を要求してくるpublic typealias mode_t = __darwin_mode_t public typealias __darwin_mode_t = __uint16_t /* [???] Some file attributes */ public typealias __uint16_t = UInt16
S_IREAD
とかが。#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) #define S_ISTXT S_ISVTX /* sticky bit: not supported */ #define S_IREAD S_IRUSR /* backward compatability */ #define S_IWRITE S_IWUSR /* backward compatability */ #define S_IEXEC S_IXUSR /* backward compatability */ #endif
as Type
を付ければ解決できるパターン?/usr/include/linux/stat.h:#define S_IRUSR 00400
let a = Int(1 | 2 | 3 | 4 | 5 | 6 | 7)
<stdin>:1:9: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions let a = Int(1 | 2 | 3 | 4 | 5 | 6 | 7) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let a: Int = 1 as Int | 2 | 3 | 4 | 5 | 6 | 7
Int(S_IRUSR) | Int(S_IRUSW) | ...
Int()
よりも as Int
の方がいいのかな?off_t
か。Reverts #2851 This breaks on Windows
/home/buildnode/jenkins/workspace/swift-corelibs-foundation-PR-Linux@2/swift-corelibs-foundation/Sources/Foundation/NSData.swift:468:34: error: ambiguous use of 'S_IRUSR' 11:31:40 let createMode = Int(S_IRUSR) | Int(S_IWUSR) | Int(S_IRGRP) | Int(S_IWGRP) | Int(S_IROTH) | Int(S_IWOTH) 11:31:40 ^
100% tests passed, 0 tests failed out of 258
FROM swiftlang/swift:nightly-focal RUN apt-get update && apt-get install -y \ clang \ cmake \ git \ icu-devtools \ libcurl4-openssl-dev \ libedit-dev \ libicu-dev \ libncurses5-dev \ libpython2-dev \ libsqlite3-dev \ libxml2-dev \ ninja-build \ pkg-config \ python \ python-six \ rsync \ swig \ systemtap-sdt-dev \ tzdata \ uuid-dev RUN mkdir -p /build VOLUME /src WORKDIR /build
Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift
のtestSettingLocale
はDate.FormatStyle(timeZone: .gmt)
を入れてやる必要がある。// dateFormatter.date(from: "2021-04-12 15:04:32")!
これがPSTだとGMT-8で同じく4/12 7時だけど、JSTのGMT+9だと4/13 0時になって日付・曜日が変わるから落ちるんですね…… (edited)__SwiftValue.store
で中でNSObjectに変換される時に SwiftFoundation.NSNumber
になってほしいのに __NSCFNumber
になってしまう…… https://github.com/apple/swift-corelibs-foundation/blob/41b71f9ee2deb4065c9e6dd3658253a2f8f85044/Sources/Foundation/Bridging.swift#L180-L186 (edited)__NSCFNumber
になるが、Intから直接AnyObjectにすると SwiftFoundation.NSNumber
になる。愉快だ……