-- Exit Code: 134 Command Output (stderr): -- <snip> terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc pure virtual method called terminate called recursively /home/buildnode/disk2/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/ExtractComment/Output/extract_comments.swift.script: line 19: 6097 Aborted (core dumped) /home/buildnode/disk2/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/buildbot_incremental/swift-linux-x86_64/bin/sourcekitd-test -req=extract-comment -pass-as-sourcetext /home/buildnode/disk2/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/swift/test/SourceKit/ExtractComment/Inputs/DocCommentEmptyLine1.swift > /home/buildnode/disk2/workspace/oss-swift-incremental-RA-linux-ubuntu-14_04/buildbot_incremental/swift-linux-x86_64/test-linux-x86_64/SourceKit/ExtractComment/Output/extract_comments.swift.tmp.DocCommentEmptyLine1.response
# test/SourceKit ディレクトリ内だけ全部 $ utils/run-test --build-dir ../build/Ninja-DebugAssert/ test/SourceKit/ # 特定のテストケースだけ $ utils/run-test --build-dir ../build/Ninja-DebugAssert/ test/SourceKit/ExtractComment/extract_comments.swift # verbose出力 $ utils/run-test -v --build-dir ../build/Ninja-DebugAssert/ test/SourceKit/ExtractComment/extract_comments.swift
verbose 出力で実際の実行コマンド群が見えるのでそれをデバッガで見ていく感じです。$ utils/build-script -R --debug-swift
でビルドしてます。その場合は build-dir は ../build/Ninja-ReleaseAssert+swift-DebugAssert
ですね。FAIL: Swift(linux-x86_64) :: SourceKit/CursorInfo/cursor_no_cancel.swift (443 of 9803) ******************** TEST 'Swift(linux-x86_64) :: SourceKit/CursorInfo/cursor_no_cancel.swift' FAILED ******************** Script: -- <省略> -- Exit Code: 1 Command Output (stderr): -- /home/rintaro/Documents/swift-oss/swift/test/SourceKit/CursorInfo/cursor_no_cancel.swift:39:11: error: expected string not found in input // RANGE: source.lang.swift.range.singleexpression ^ <stdin>:1:1: note: scanning from here #0 0x00007f124b02b0e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (BUILD_DIR/lib/libsourcekitdInProc.so+0x9850e8) ^ <stdin>:6:21: note: possible intended match here #5 0x00007f124b07024a SourceKit::SwiftLangSupport::~SwiftLangSupport() (BUILD_DIR/lib/libsourcekitdInProc.so+0x9ca24a) ^ -- ********************
swift-DEVELOPMENT-SNAPSHOT-2017-05-09-a
のLinux版に libsourcekitdInProc.so
がもれなく入っていることを確認。NSDictionary
の比較がLinuxで正しく動いていないことを知って、ガッカリ JSONSerialization
によるJSON文字列作成結果がnondeterministicだったため、オブジェクト化して比較したのがあだになった。Foundation.TimeZone
が /usr/share/zoneinfo
の存在に依存していて、ubuntu だとデフォルトで存在しない場合があるからだった。 https://bugs.swift.org/browse/SR-4921NSArray
に Hashable
でない _ObjectBridgeable
な要素が入ってる時の比較がおかしかった。
swift-DEVELOPMENT-SNAPSHOT-2016-08-18-a
かららしい… (edited)swift/stdlib/public/SDK/(Dispatch|Foundation)/NS*
辺りはLinuxで使えない。 (edited)Dispatch
やFoundation
を実現するのがswift-corelibs-*
。Dispatch
やFoundation
のAPIは、swift
本体でテスト実行されるからまだいい。 (edited)swift
本体では使われていないObjective-Cを真似た機能を使おうとすると、それがテストされていないからmacOSの挙動と異なってたりする。 (edited)swift-corelibs-*
プロジェクトにはフルタイムで見てるAppleの開発者がいないらしくて、その辺り見過ごされて実装されていってしまってるぽい。init
でクラスのself
を置き換える手法を使うことで、swift-corelibs-foundationのNSNumber
をCFNumberCreate()
で作成する様に変更するPRを書いた。 https://github.com/apple/swift-corelibs-foundation/pull/1093 (edited)convenience init
だから その先の self.init
で alloc すればいいはず。po
とか使おうとすると (lldb) po empty warning: Swift error in module YamsPackageTests.xctest. Debug info from this module will be unavailable in the debugger. error: in auto-import: failed to get module 'YamsTests' from AST context
みたいなエラーが出て使えなかったのだけど、 https://bugs.swift.org/browse/SR-5524?focusedCommentId=27038&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-27038 に書かれてるC_INCLUDE_PATH
とCPLUS_INCLUDE_PATH
を設定したら、使える様になった。() -> NSNumber
なクロージャを渡している。init(factory:)
に渡しているクロージャの式が、 () -> Animal
であるゆえに、 コンパイルエラーとなる。 ここは、 self の式の型は Animal ではなく Self なので、 () -> Self
型のクロージャを渡さねばならないからだ。fileprivate let decimal: Decimal
ということは、現状でも convenience init 経由の NSDecimalNumber のコンストラクトで、 メモリがぶっ壊れる可能性がある・・・?func castCFNumber<T>() -> T { return unsafeBitCast(cfnumber, to: T.self) }
slavaはこれを試してみるとこのこと。 NSDecimalNumber(value: true)
このような「バグでコンパイルできてしまう」パターンは、 既存の NSNumber 実装が踏み抜いている。 https://github.com/apple/swift-corelibs-foundation/blob/87466c45462cba5a085d5cd41d785d681016542d/Foundation/NSNumber.swift#L266
僕のcommitですね I have a whole branch that refractors almost ALL of the classes that follow the self replacement pattern.
(edited)NSDecimalNumber の decimal プロパティが初期化されない可能性は解決しないのでは・・・???
NSDecimalNumber
は super.init()
しか使ってないから問題ないと思う。 open override func description(withLocale locale: Locale?) -> String { guard locale == nil else { fatalError("Locale not supported: \(locale!)") } return self.decimal.description }
public convenience init(value: Bool)
は、 NSDecimalNumber
に対しても呼び出せると思う。
$ docker run --privileged -it --rm norionomura/swift:4020170827a swift -I /usr/lib/swift/clang/include Welcome to Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c, Swift 0899bd328a). Type :help for assistance. 1> import Foundation 2> let b = NSDecimalNumber(value: true) error: repl.swift:2:9: error: argument labels '(value:)' do not match any available overloads let b = NSDecimalNumber(value: true) ^ ~~~~~~~~~~~~~ repl.swift:2:9: note: overloads for 'NSDecimalNumber' exist with these partially matching parameter lists: (decimal: Decimal), (string: String?), (coder: NSCoder), (floatLiteral: Double), (booleanLiteral: Bool), (integerLiteral: Int) let b = NSDecimalNumber(value: true) ^ 3>
(edited)class Animal { init() { } convenience init(init0 int: Int) { self.init() } } class Cat : Animal { override init() { } convenience init(init1 int: Int) { self.init() } } // Animal の convenience init が呼び出せる Cat.init(init0: 3)
swift -I /usr/lib/swift/clang/include
で。public
だからかな?[omochi@omochi-iMac temp]$ docker run --privileged -it --rm norionomura/swift:4020170827a swift -I /usr/lib/swift/clang/include Welcome to Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c, Swift 0899bd328a). Type :help for assistance. 1> public class Animal 2. { 3. public init() {} 4. public convenience init(init0 int: Int) { self.init() } 5. } 6> public class Cat : Animal { 7. public override init() {} 8. } 9> Cat.init(init0: 33) $R0: Cat = { __lldb_expr_1.Animal = {} }
Open access applies only to classes and class members, and it differs from public access as follows: - Classes with public access, or any more restrictive access level, can be subclassed only within the module where they’re defined. - Class members with public access, or any more restrictive access level, can be overridden by subclasses only within the module where they’re defined. - Open classes can be subclassed within the module where they’re defined, and within any module that imports the module where they’re defined. - Open class members can be overridden by subclasses within the module where they’re defined, and within any module that imports the module where they’re defined.
(edited)### public Apply this modifier to a declaration to indicate the declaration can be accessed and subclassed by code in the same module as the declaration. Declarations marked with the public access-level modifier can also be accessed (but not subclassed) by code in a module that imports the module that contains that declaration.
(edited)open class NSValue2 {} protocol Factory {} extension Factory { init(factory: () -> Self) { self = factory() } } extension NSValue2: Factory {} open class NSNumber2: NSValue2 { private override init() {} private convenience init(private: Int) { self.init(factory: { NSNumber2() }) } public convenience init(init0: Int) { self.init(private: init0) } } open class NSDecimalNumber2: NSNumber2 {}
これでモジュール外の NSDecimalNumber2(init0:0)
がビルドエラー error: 'NSDecimalNumber2' cannot be constructed because it has no accessible initializers
になる。import Foundation internal protocol _Factory { init(factory: () -> Self) } extension _Factory { init(factory: () -> Self) { self = factory() } } open class NSValue2: _Factory { internal init() {} } open class NSNumber2: NSValue2 { internal override init() { super.init() } public convenience init(value: Bool) { self.init(factory: { NSNumber2() }) } } open class NSDecimalNumber2: NSNumber2 { // override init() { super.init() } // この行を復元するとビルドが通る。 public init(decimal dcm: Decimal) { super.init() } }
これでモジュール外の NSDecimalNumber2(value: true)
がビルドエラー error: incorrect argument label in call (have 'value:', expected 'decimal:')
になる。 (edited)NSDecimalNumber2
にoverride init() { super.init() }
を足すと通る様になる。Rule 1 If your subclass doesn’t define any designated initializers, it automatically inherits all of its superclass designated initializers. Rule 2 If your subclass provides an implementation of all of its superclass designated initializers—either by inheriting them as per rule 1, or by providing a custom implementation as part of its definition—then it automatically inherits all of the superclass convenience initializers.
open class NSNumber2 { public init() { } public convenience init(value: Bool) { self.init() } } open class NSDecimalNumber2: NSNumber2 { // A // public override init() {} // B public init(decimal dcm: Decimal) { super.init() } }
swift-4.1-DEVELOPMENT-SNAPSHOT-2017-10-25-a
を試したら、REPL起動時に-I/usr/lib/swift/clang/include
を渡さなくてもimport Foundation
でエラーにならなくなってた func testNSStringPath1() throws { let actual = NSString(string: "").appendingPathComponent("*.txt") let expected = "*.txt" XCTAssertEqual(actual, expected) }
/*.txt
になってしまう。TestResources └── globstar ├── a │ ├── b │ │ ├── c │ │ │ ├── d0.txt │ │ │ └── d1.md │ │ ├── c0.txt │ │ └── c1.md │ ├── b0.txt │ └── b1.md ├── a0.txt └── a1.md
substSubpathStrs = try fm.subpathsOfDirectory(atPath: path) dump(substSubpathStrs)
Test Case 'GlobTest.testExpandGlobStar1' started at 2017-11-11 07:57:51.502 ▿ 3 elements - "a" - "a0.txt" - "a1.md"
$ swift --version
が同じならこの手の挙動は同じですよね?[subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] enter [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] entryName=. [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] entryName=.. [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] entryName=a [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] entryType=0 (DT_DIR=4) [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] entryName=a0.txt [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] entryType=0 (DT_DIR=4) [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] entryName=a1.md [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] entryType=0 (DT_DIR=4) [subpathsOfDirectoryCompat(/home/travis/build/omochi/gysb/TestResources/globstar)] exit
if tempEntryType == Int32(DT_DIR) { let subPath: String = path + "/" + entryName let entries = try subpathsOfDirectory(atPath: subPath) contents.append(contentsOf: entries.map({file in "\(entryName)/\(file)"})) }
How do I contribute? We welcome contributions to Foundation! Please see the known issues page if you are looking for an area where we need help. We are also standing by on the mailing lists to answer questions about what is most important to do and what we will accept into the project.
enumerator(atPath:)
とかはどうだろうlibblocksruntime0
が入ってない。swift(>=)
による検査は演算子が使えません。#if swift(>=4.0) #elseif swift(>=3.2) #else #endif
みたいにするしかないと思います。#else
ブロック以外は Swift3.0 ではパースされないので、その中であれば swift(>=4.0.2)
など使えると思います。self.token = self.notificationCenter.addObserver(forName:object:queue:using:)(nil, nil, nil) { ... }
っていう手もあり。#if swift(>=4.0) #if swift(>=4.0.2) #else extension NotificationCenter { func addObserver(forName name: NSNotification.Name?, object obj: Any?, queue: OperationQueue?, using block: @escaping (Notification) -> Void) -> NSObjectProtocol { ... } } #endif #endif
みたいにメソッド生やすともうちょっとマシにできそうな気がしてきましたw (edited)import Dispatch func fib(_ i: Int) -> Int { switch i { case 0, 1: return 1 default: return fib(i-1) + fib(i-2) } } DispatchQueue.concurrentPerform(iterations: 30) { i in fib(i) }
これ実行したら確率的に死んでしまう…… swift-DEVELOPMENT-SNAPSHOT-2018-01-29-a-ubuntu16.04にてDispatch
のバグかもしれないけどimport Foundation import Dispatch for i in 0..<30 { DispatchQueue.global().async { print(i) sleep(1) _ = i } } sleep(10)
(edited)print
は一個も出ずに死にますね。さらにsleepを入れることで死亡率100%にDispatchQueue
を個別に生成した場合死なないのでconcurrent queueの問題みたいですdocker run --privileged -it --rm norionomura/swift:swift-4.1-branch swift -I/usr/lib/swift/clang/include
norionomura/swift:swift-4.1-branch
が最新のスナップショット。/usr/lib
に置かれたライブラリ、swiftcだとリンクされるけど、REPLだとerror: Couldn't lookup symbols:
になってしまう。swift -I/usr/lib/swift/clang/include -L /usr/lib
で起動したREPLだとエラーにならないので、REPLはld
とは違う仕組みでライブラリを検索するぽい?:type lookup
だと型の情報が出るのに、使おうとするとunresolved identifierになる $ docker run --privileged -it --rm norionomura/swift:40 swift -I/usr/lib/swift/clang/include Welcome to Swift version 4.0 (swift-4.0-RELEASE). Type :help for assistance. 1> import Foundation 2> :type lookup DBL_DECIMAL_DIG var DBL_DECIMAL_DIG: Swift.Int32 { get {} } 2> print(DBL_DECIMAL_DIG) error: repl.swift:2:7: error: use of unresolved identifier 'DBL_DECIMAL_DIG' print(DBL_DECIMAL_DIG) ^~~~~~~~~~~~~~~
(edited)llvm-symbolizer
にもオプションが増えてるなあ。 (edited)libunwind
.Thread.callStackSymbols
)とほぼ同じ出力が得られます。SwiftCompilerDiscordappBot
のクラッシュ原因を突き止めたい…State changed from up to crashed
ってのが時々出てくるのですが、何がトリガーなのかさっぱりわかっていないのです。Process
のstandardInput
にパイプのFileHandle
を渡してパイプへデータを書き込んでも、Linuxだと起動したプロセスが標準入力を読んでくれない現象に悩んでたのだけど、launch()
の前にパイプへデータを書き込んでおく事で読んでくれる様になった。launch()
後にパイプへ書き込んでも問題ない。 (edited)Process.waitUntilExit()
がスレッドセーフではないため、Process.terminationStatus
がおかしくなる。 @swift-4.2.4
import Foundation let process = Process() process.launchPath = "/bin/false" let group = DispatchGroup(), queue = DispatchQueue.global() process.launch() queue.async(group: group) { process.waitUntilExit() } group.wait() print("terminationStatus should be 1, actual: \(process.terminationStatus)")
(edited)import Foundation let process = Process() process.launchPath = "/bin/false" let semaphore = DispatchSemaphore(value: 0) process.terminationHandler = { _ in semaphore.signal() } let queue = DispatchQueue.global() process.launch() queue.async { process.waitUntilExit() } print("terminationStatus should be 1, actual: \(process.terminationStatus)") semaphore.wait() print("terminationStatus should be 1, actual: \(process.terminationStatus)")
(edited)terminationStatus should be 1, actual: 0 terminationStatus should be 1, actual: 1
(edited)terminationHandler
を使った方が良さそう。 https://github.com/apple/swift-corelibs-foundation/blob/swift-4.2-branch/Foundation/Process.swift#L341waitUntilExit()
でも問題ないしその場合のオーバーヘッドもwaitUntilExit()
の方が少ないかな。swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-06-a
を使ったubuntu 16.04のdockerイメージ作成が失敗する様になった。 Step 7/7 : RUN swift --version ---> Running in bb3dce9f40cc swift: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by swift)
(edited)GLIBCXX_3.4.22
を含むlibstdc++.so.6
はubuntu 16.04のパッケージとしては未リリースぽい。swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-07-a
で直ってた。 /// - Note: this differs from the Darwin implementation in that the keys must be Strings open var threadDictionary = [String : Any]()
(edited)Thread.current.threadDictionary
を Thread Local Storage として使おうとしたときにObjectIdentifier
の debugDescription
をキーにするとか?"ObjectIdentifier(3001238)"
みたいな?NSMutableDictionary
だと何がまずいんだろう?Dictionary
じゃなければいけない理由が本当にあるなら、 [AnyHashable: Any]
ではだめなのかとか聞いてみると良いと思います。 (edited)[954/1340] Linking CXX executable bin/clang-check ... clang: error: unable to execute command: Killed clang: error: linker command failed due to signal (use -v to see invocation)
cmake -G Ninja ../../../swift-corelibs-foundation \ -DCMAKE_C_COMPILER=../../llvm-linux-x86_64/bin/clang \ -DCMAKE_SWIFT_COMPILER=../../swift-linux-x86_64/bin/swiftc \ -DFOUNDATION_PATH_TO_LIBDISPATCH_SOURCE=../../../swift-corelibs-libdispatch \ -DFOUNDATION_PATH_TO_LIBDISPATCH_BUILD=../../libdispatch-linux-x86_64
[250/3012] Building CXX object
+ /usr/bin/cmake --build /home/katsumi/work/swift-source/build/Ninja-DebugAssert/llvm-linux-x86_64 -- -j1 all [59/1905] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86ISelLowering.cpp.o FAILED: /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Target/X86 -I/home/katsumi/work/swift-source/llvm/lib/Target/X86 -I/usr/include/libxml2 -Iinclude -I/home/katsumi/work/swift-source/llvm/include -Wno-unknown-warning-option -Werror=unguarded-availability-new -g -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wno-class-memaccess -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -g -fno-exceptions -fno-rtti -MMD -MT lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86ISelLowering.cpp.o -MF lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86ISelLowering.cpp.o.d -o lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86ISelLowering.cpp.o -c /home/katsumi/work/swift-source/llvm/lib/Target/X86/X86ISelLowering.cpp clang: error: unable to execute command: Killed clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script. clang: note: diagnostic msg: ********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/X86ISelLowering-5d18e1.cpp clang: note: diagnostic msg: /tmp/X86ISelLowering-5d18e1.sh clang: note: diagnostic msg: ******************** ninja: build stopped: subcommand failed. utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
2つのマシンで試してたけど片方は全然手前で死んだ。swift build -c release
だとswift-nightlyボットのCIも通るみたい。[1071/2408] Linking CXX shared library lib/libLTO.so.7svn FAILED: : && /usr/bin/clang++ -fPIC -Wno-unknown-warning-option
^ 昨日ビルドしてた2つのマシンがリンクフェーズの同じところで死んでました。[31/78] Linking CXX shared library src/libdispatch.so
ここでコケるようになった でも、例の謎の Killed じゃなくて /usr/bin/ld.gold: error: cannot find -lswiftSwiftOnoneSupport
docker-machine upgrade
したらハマったので共有。 https://twitter.com/norio_nomura/status/1063237666903273474docker-machine upgrade
したらdocker-machineが壊れた。boot2dockerをv18.06.1-ceにして復旧。 -- 18.09.0 iso breaks swarm ingress · Issue #4608 · docker/machine https://t.co/EwqzwMziDimissing required module 'SwiftShims'
でコケた・・cached
を設定すると良いらしいので、やってみるcached
はメモリ消費が多すぎて、使うのを止めました。docker-machine
使う構成です。docker-machine
を使った構成のメモ https://github.com/norio-nomura/swift-dev/blob/sourcekit-linux/docker-machine-on-mac.mdcached
で問題なくなるけど、大規模だとまだダメという認識です。cached
だとキャッシュメモリがバカみたいに消費されたと記憶。docker-machine
を使わずにnfs使う方法。 https://qiita.com/kunit/items/36d9e5fa710ad26f8010 (edited)docker
にオプション指定ではなくdocker-compose
を使う事が多いなら、こちらが良いのかも。$ docker volume create --driver local --opt type=nfs --opt o=addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3,acregmin=1,acdirmin=1 --opt device=:/Users Users $ docker run --privileged -it -v Users:/Users -w `pwd` --rm norionomura/swift:421 bash -c "time dd if=/dev/zero of=test bs=1k count=100000" 100000+0 records in 100000+0 records out 102400000 bytes (102 MB, 98 MiB) copied, 4.34849 s, 23.5 MB/s real 0m4.365s user 0m0.020s sys 0m0.220s
docker-machine
VMware Fusion + NFS $ docker run --privileged -it -v `pwd`:`pwd` -w `pwd` --rm norionomura/swift:421 bash -c "time dd if=/dev/zero of=test bs=1k count=100000" 100000+0 records in 100000+0 records out 102400000 bytes (102 MB, 98 MiB) copied, 1.43024 s, 71.6 MB/s real 0m1.455s user 0m0.030s sys 0m0.180s
$ docker run --privileged -it -v `pwd`:`pwd` -w `pwd` --rm norionomura/swift:421 bash -c "time dd if=/dev/zero of=test bs=1k count=100000" 100000+0 records in 100000+0 records out 102400000 bytes (102 MB, 98 MiB) copied, 45.2698 s, 2.3 MB/s real 0m45.259s user 0m0.370s sys 0m4.710s
docker-machine
と同等の場合もある。cached
は使ってもあまり変わらなかった。dd
での書き込みですからね。読み込みはcached
の効果が出そうです。import Foundation class Cat {} let a: Cat = Cat() let array = NSMutableArray() array.add(a as Any)
Could not cast value of type 'main.Cat' (0x7f180f3b0040) to 'Foundation.NSObject' (0x7f1801800a20). #0 0x000000000410ac94 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410ac94) #1 0x0000000004108b22 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108b22) #2 0x000000000410ae42 SignalHandler(int) (/usr/bin/swift+0x410ae42) #3 0x00007f180ef80390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f180d6bf428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007f180d6c102a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00007f18095ec742 (/usr/lib/swift/linux/libswiftCore.so+0x3c7742) #7 0x00007f18095e6b62 (/usr/lib/swift/linux/libswiftCore.so+0x3c1b62) #8 0x00007f18095e6bbb (/usr/lib/swift/linux/libswiftCore.so+0x3c1bbb) #9 0x00007f18095e7e43 swift_dynamicCastClassUnconditional (/usr/lib/swift/linux/libswiftCore.so+0x3c2e43) #10 0x00007f18016a4b52 $S10Foundation11_SwiftValueC5storeyAA8NSObjectCypFZTf4nd_n (/usr/lib/swift/linux/libFoundation.so+0x6ebb52) #11 0x00007f18016a42d9 $S10Foundation11_SwiftValueC5storeyAA8NSObjectCypFZ (/usr/lib/swift/linux/libFoundation.so+0x6eb2d9) #12 0x00007f1801342eb2 $S10Foundation14NSMutableArrayC6insert_2atyyp_SitF (/usr/lib/swift/linux/libFoundation.so+0x389eb2) #13 0x00007f1801342e3e $S10Foundation14NSMutableArrayC3addyyypF (/usr/lib/swift/linux/libFoundation.so+0x389e3e) #14 0x00007f180f3af102 #15 0x0000000001043efe llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/usr/bin/swift+0x1043efe) #16 0x0000000001048022 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) (/usr/bin/swift+0x1048022) #17 0x00000000004f8b42 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std:
Date
, DateComponents
のnanosecond
周りがSwift 5.0で直ったぽい。 @swift-4.2.4 @swift-5.0.3
import Foundation let now = Date() let comp = Calendar(identifier: .gregorian).dateComponents(in: .current, from: now) let recreatedDate = Calendar(identifier: .gregorian).date(from: comp) print(now.timeIntervalSinceReferenceDate == recreatedDate?.timeIntervalSinceReferenceDate)
swift-4.2.x-RELEASE
を毎月出すらしい。 https://forums.swift.org/t/announcing-swift-4-2-2-and-monthly-swift-4-2-x-dot-releases-for-linux/20148norionomura/swift
、5.0を機にubuntu16.04からubuntu18.04へ切り替えてたのだけど、Discordのボットをubuntu18.04にするとProcess
で起動したswift
プロセスが終了せずにタイムアウトしてしまう不具合に遭遇。--enable-test-discovery
を試せるtoolchainのDockerイメージを作りました。 https://forums.swift.org/t/test-discovery-on-linux/26203/5.build/x86_64-unknown-linux/debug/testlist.derived/
にLinuxMain.swift
とXCTestManifests.swift
相当を生成してそれを実行してる。 $ rm Tests/LinuxMain.swift remove Tests/LinuxMain.swift? y $ _docker_swift_run norionomura/swift:pr-25685 swift test --enable-test-discovery --parallel [117/117] Testing YamsTests.YamlErrorTests/testYamlErrorScanner $ tree .build/x86_64-unknown-linux/debug/testlist.derived/ .build/x86_64-unknown-linux/debug/testlist.derived/ ├── YamsTests.swift └── main.swift 0 directories, 2 files
(edited)swift test --generate-linuxmain
の生成物をリポジトリへ含めるのが不要になる。 (edited)LinuxMain.swift
がなかったら勝手に--enable-test-discovery
する、とかそんな挙動になるのかな。SourceKit
ではなくIndexStore
なのか? https://github.com/apple/swift-package-manager/pull/2174--enable-test-discovery
くらいしか利用法が思いつかないな。FoundationNetworking
に続き、FoundationXML
も分離するらしい。 https://github.com/apple/swift-corelibs-foundation/pull/2432Foundation
は、全部入りを指すんですよね?Foundation
はNetworking
とXML
が取り除かれたパッケージになる。全部入りパッケージは無い(と思う)。import Foundation
したときに入るものが異なってしまいますよね。#if canImport(FoundationXML)
とかが libcurl
やlibxml2
をインストールしなくても実行時エラーにならなくなる。 (edited)libunwind
. - norio-nomura/SwiftBacktraceswift-DEVELOPMENT-SNAPSHOT-2019-09-24-a
以降で発生してる事を確認した。 https://bugs.swift.org/browse/SR-11570Swift.swiftmodule
を生成するところから進まなくて、VMのメモリを3GBまで増やしたらようやく進む様になった。以前は1GBで問題なかったのに…import Foundation private final class _Thread: Thread { private let block: () -> Void init(block: @escaping () -> Void) { self.block = block } override func main() { block() } }
<stdin>:8:5: error: 'super.init' isn't called on all paths before returning from initializer } ^
Foundation.Thread
の定義がずれてるってことですか?swift-DEVELOPMENT-SNAPSHOT-2020-08-18-a
からNG (edited)swift-DEVELOPMENT-SNAPSHOT-2020-08-18-a
版のswift-corelibs-foundationに入った変更で関係しそうなものは無さそうなので、コンパイラの挙動が変わったのだと思う。 https://github.com/apple/swift-corelibs-foundation/compare/swift-DEVELOPMENT-SNAPSHOT-2020-08-11-a...swift-DEVELOPMENT-SNAPSHOT-2020-08-18-a (edited)swift-5.3.1-RELEASE
からLinux版のSwiftPMに渡された--static-swift-stdlib
もswiftc
へ-static-stdlib
を渡す様になったけど、FoundationNetworking
, FoundationXML
を使ってると-static-stdlib
渡ってなかったのか。swift-5.3-RELEASE
でも同一条件で-Xswiftc -static-stdlib
を使うとlib/swift_static
のswiftmoduleの配置が変わった影響ですね-static-stdlib
がLinuxでも動く様になったと報告されてる詳細に、FoundationNetworking
, FoundationXML
利用有無とか書かれてない。-static-stdlib
を使うと外部依存するライブラリが変わるのか。--static-swift-stdlib
付け外し後はswift package clean
ではダメで、swift package reset
が必要ぽいのも、混乱の要因かも…norionomura/swift:5.3.1
で apt-get update && apt-get install -y libxml2-dev
した後 swift package reset; swift build -Xswiftc -static-stdlib
はリンク出来るが swift package reset; swift build --static-swift-stdlib
はダメという事までわかった… (edited)import FoundationNetworking import Foundation print(try! String(contentsOf: URL(string: "https://example.com")!))
僕の環境だとこれを swiftc main.swift -static-stdlib
でコンパイルするとCoreFoundationのシンボルが足りないと怒られます。norionomura/swift:5.3.1
を使ってます。Dockerfile
からswift-5.3.1-RELEASE
相当をビルドしようとしてるけど、途中でdocker build
が止まる…norionomura/swift:531
で試してみます--static-swift-stdlib
の場合、オブジェクトファイルを作るときにはSwiftPMは-static-stdlibを渡さないので /usr/lib/swift/CoreFoundation/module.map
を見て、autolinkのエントリを追加しないからリンク時に-lCoreFoundation が付かないんだ! (edited)apt-get update && apt-get install -y libxml2-dev swift build -Xswiftc -static-stdlib
でリンク出来ることを確認しました。# ldd `swift build --show-bin-path`/sourcekitten linux-vdso.so.1 => (0x00007fffa45cd000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f50112a8000) libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f50110a5000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5010ea1000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5010b98000) libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f50107dd000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f501045b000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5010245000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f500fe7b000) /lib64/ld-linux-x86-64.so.2 (0x00007f50140a1000) libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007f500fae7000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f500f8cd000) liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f500f6ab000) libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007f500dbf4000)
.so
がリンクされてる気がするんだけど、実際にシンボルを参照していなければ、.so
が無くても動いたりするのだろうか?libicudata
と libicuuc
が.soでリンクされてるのがおかしい気がしますねlibxml2.so
がlibicu*
を使ってますね。apt-get update && apt-get install -y libxml2
するだけで実行可能になりました。 (edited)sourcekitd
が無いと動かないのですが。echo 'import Foundation'|swiftc -static-executable -
はまた違ったリンクエラーになるのね。/usr/lib/swift_static/linux/libswiftImageInspectionShared.a(ImageInspectionELF.cpp.o):ImageInspectionELF.cpp:function swift::initializeProtocolLookup(): error: undefined reference to 'swift::addImageProtocolsBlockCallbackUnsafe(void const*, unsigned long)' ...
libxml2
しかインストールされていないので、libxml2-dev
へ変更した方が良いかなと。release/5.3
ベースにしてやり直してますSWXMLHash
がビルドできなかったですswift-DEVELOPMENT-SNAPSHOT-2020-11-09-a
でビルドできました。 (edited).so
, .a
両方が入ってる場合に .a
を優先する方法ってないのだろうか。-static
を付けたら.aを優先してくれないですか? lldはそういう挙動だったと思います-static
は他のオプションの関係で使えないみたい。 # swift build -Xswiftc -static-stdlib -Xlinker -static /usr/bin/ld.gold: fatal error: -pie and -static are incompatible clang-10: error: linker command failed with exit code 1 (use -v to see invocation) <unknown>:0: error: link command failed with exit code 1 (use -v to see invocation) [0/1] Linking sourcekitten
.so
を探さないという極端な挙動のオプションはあるけど、両方存在する場合に.a
を優先する的なのは見当たらない… # ld.gold --help Usage: ld.gold [options] file... Options: … -Bstatic -l does not search for shared libraries
(edited)swift-DEVELOPMENT-SNAPSHOT-2020-11-13-a
で試そうと思ったら、まだPRの変更が含まれてなかった。swift-DEVELOPMENT-SNAPSHOT-2020-11-16-a
で確認しました。 docker run -v$PWD:$PWD -w$PWD norionomura/swift:nightly sh -c 'apt-get update && apt-get install -y libxml2-dev && swift build -c release --static-swift-stdlib'
で無事にsourcekitten
をビルドできました。swiftlang/swift:nightly
はまだ更新されてないのでnorionomura/swift:nightly
で。$ docker-swift-run find /usr -name "*XCTest*" /usr/lib/swift_static/shims/XCTestOverlayShims.h /usr/lib/swift/shims/XCTestOverlayShims.h /usr/lib/swift/linux/libXCTest.so /usr/lib/swift/linux/x86_64/XCTest.swiftdoc /usr/lib/swift/linux/x86_64/XCTest.swiftmodule
swift/utils/build-script-impl
にlibXCTest.a
をビルドする仕組みが入ってないぽい。foundation_static
を見ると、product
としてxctest_static
を用意していく作法ぽい。 https://github.com/apple/swift/blob/main/utils/build-script-impl#L2301swift-5.4-RELEASE
でSwiftLintにswift build --configuration release -Xswiftc -static-stdlib
するとundefined reference
でリンクエラーになる。 https://github.com/norio-nomura/docker-swiftlint/pull/18/checks?check_run_id=2445741371-Xlinker -lCoreFoundation
で治ると思います。-Xlinker -lCoreFoundation
では治らないようです。 https://github.com/norio-nomura/docker-swiftlint/pull/18/checks?check_run_id=2446742238-Xlinker -lCFURLSessionInterface -Xlinker -lcurl
で治りました。CIでも試し中。import FoundationNetworking _ = URLSession.shared
(edited)Data(buffer: ByteBuffer)
が NIOFoundationCompat
モジュールに定義されていて、Linuxだとこれをimportしないと使えないんだけどutils/build-script --release-debuginfo --test --skip-early-swift-driver
でビルドしてテスト実行まで含めてピッタリ2時間半ってところ。ARM CPUの4コアと24 GBメモリのマシン。swift:5.5.2-focal
で、最適化バグで、実行ファイルが該当箇所でコアダンプ吐いてクラッシュする症状に出会いました。 しかも、その箇所 + 5.5.2 の組み合わせは過去に動いていて、 新規に追加した別のコードが、間接的に?なんらかの影響をその箇所に与えていたようです。 printを追加すると症状が消えたりしたので、 @_optmize(none)
を付けて解決しました。 みなさんも気をつけて・・・DEVELOPMENT-SNAPSHOT
はインストール先のディレクトリ名を見ればいつのものかわかるけど、Docker版はswift -version
に含まれるハッシュを元にリポジトリを検索しないとわからない。そのためにSwiftボットはGitHubのGraphQL APIを使ってタグを取得してたのだけど、その仕組みをGitHub CLI extensionとして独立させた。 https://github.com/norio-nomura/gh-query-tags (edited)swift:focal
だと動くのにswift:bionic
だとswiftlint version
すら動かない。 $ docker run -it --rm -v $(pwd):$(pwd) -w$(pwd) swiftlint:bionic swiftlint version free(): invalid pointer
swift:latest
はbionic
なんだけど、focal
を使った方が良いのかな。FileManager.DirectoryEnumerationOptions.producesRelativePathURLs
という欲しかったものがあることに気がついて使ったが、Linuxに実装されてなかった。。--platform=linux/amd64
を付けて実行した時に/proc/self/cmdline
の内容がバグってて、 $ docker run --platform=linux/arm64 alpine cat /proc/self/cmdline|xargs -0 echo cat /proc/self/cmdline $ docker run --platform=linux/amd64 alpine cat /proc/self/cmdline|xargs -0 echo /bin/cat cat /proc/self/cmdline
CommandLine.arguments
の取得にそれを利用してるSwift製のバイナリはその影響を受けるので、swift build
とか動かない。 $ docker run -it -v $PWD:$PWD:rw -w $PWD --platform=linux/amd64 swift swift build error: Unexpected argument '/usr/bin/swift-build' Usage: swift build <options> See 'build -help' for more information.
正規の手順(argc
,argv
)?を使ってる場合、影響を受けない。 https://lima-vm.io で立ち上げたdockerだと/proc/self/cmdline
の内容は少しおかしいけど、SwiftのCommandLine.arguments
は影響を受けない。 $ docker.lima run --platform=linux/arm64 alpine cat /proc/self/cmdline|xargs -0 echo cat /proc/self/cmdline $ docker.lima run --platform=linux/amd64 alpine cat /proc/self/cmdline|xargs -0 echo /bin/cat /proc/self/cmdline
/proc/self/cmdline
じゃなくてcrt0がくれるargvをコンパイラが吐くエントリポイントで保存しておくのが良いのかなぁ。docker buildx build --platform linux/amd64,linux/arm64
は、Rosetta入りのlimaでもamd64がqemuになってめっちゃ遅かったけど、Docker DesktopだとちゃんとRosettaで動いて速い。$ docker run --privileged ghcr.io/norio-nomura/re-register-rosetta Rosetta is not correctly registered. Re-registering rosetta... Successfully re-registered Rosetta. $ docker run --privileged ghcr.io/norio-nomura/re-register-rosetta It looks like Rosetta is correctly registered.
(edited)c++ ArgvGrabber::ArgvGrabber() : argv(nullptr), argc(0) { findArgv(findStack()); }
/proc/self/maps
から sscanf(line, "%p-%p", &base, &top)
でスタックトップを取ってるけど、これは保険のチェック用っぽいなProcessInfo.arguments
とか存在してるし、もうこれはプロセスでグローバルなものとして世の中回ってるって事やな (edited)ProcessInfo.arguments
というか CommandLine.arguments
ですねSwift自体が提供してるのは/proc/<pid>/cmdline
が、その機能じゃないの?docker buildx build --platform linux/amd64,linux/arm64
は、Rosetta入りのlimaでもamd64がqemuになってめっちゃ遅かったけど、Docker DesktopだとちゃんとRosettaで動いて速い。 --platform linux/amd64,linux/arm64
でRosettaが使われることが分かったので、Docker Desktopを使う理由はさらに減った。PackageDescription
が見えないとか言い出したexport PATH=$HOME/.local/share/swiftly/toolchains/バージョン/usr/bin:$PATH
を指定して何とか凌いでますwexport PATH=$HOME/.local/share/swiftly/toolchains/バージョン/usr/bin:$PATH
を指定して何とか凌いでますw -Xswiftc -disallow-use-new-driver
を渡すとある程度の部分までは動きました (1 月くらいに確認した時点では) (edited)docker image pull
してコンテナ内のツールチェーンのバージョンとイメージのハッシュをメモして力技で何とかしてました.(自動化できそう)usr/
が出てくるのだと思ったら swift-DEVELOPMENT-SNAPSHOT-2024-04-02-a-ubuntu22.04/
が出てきた。--strip-components=1
-Xswiftc -disallow-use-new-driver
を渡すとある程度の部分までは動きました (1 月くらいに確認した時点では) (edited)swift
コマンドの代わりに古い swift-driver で動いてくれる swift-legacy-driver
コマンドがあったのを忘れてました.これが廃止されるまでは swiftly でインストールした場合はこっちでも何とかなりますね.(e.g. swift-legacy-driver build
, swift-legacy-driver experimental-sdk install
) (edited)/proc/self/cmdline
依存だったコマンド引数取得をスタックスキャンするようにしたところですかねぇ-M raspi4b
が使えないのでたまたまリリースを待ち侘びてました. (edited)tonistiigi/binfmt:qemu-v8.1.5
を試してみてます。tonistiigi/binfmt:qemu-v8.1.5
を試してみてます。 --static-swift-stdlib
をつけるとリンクエラーになる件、/usr/lib/swift_static/CoreFoundation/module.modulemap
と/usr/lib/swift_static/dispatch/module.modulemap
で指定されているライブラリがリンカへ渡されていないからみたい。swift-autolink-extract
の担当かな?--swift-sdk
を受け取ってるのはmainの20240604です。-lDispatchStubs
とかが現れるので、それのレスポンスファイルを作成に関わってそうな5.10.1のclang
かswift-autolink-extract
が怪しいのかなと。-Xswiftc -save-temps
で残せました。ありがとうございます。 (edited)swift-autolink-extract
の出力が違ってた。-public-autolink-library
でFoundation.swiftmoduleのLINK_LIBRARYエントリとして登録しているので、$ diff -u cross-on-docker.autolink cross-on-mac.autolink --- cross-on-docker.autolink 2024-06-11 16:39:17 +++ cross-on-mac.autolink 2024-06-11 16:39:37 @@ -5,15 +5,12 @@ -lswiftGlibc -lBlocksRuntime -ldispatch --lDispatchStubs -lswiftDispatch --lCoreFoundation -lFoundation -lFoundationNetworking -lFoundationXML -lcurl -lxml2 --luuid -licui18nswift -licuucswift -licudataswift
moudle.modulemap
の定義として該当するのは、Dispatch
とCoreFoundation
ですね。 (edited)import Foundation
であればリンカオプションなしでリンクできる…はず…import Foundation
はあると思う。swift-autolink-extract
はswift-driverのお仕事なのかな。swift-autolink-extract
はフロントエンドのお仕事ですねswift-autolink-extract
は5.10.1のやつが使われてるぽいから、mainで直っても恩恵を受けるのは当分先ですよね。swift.xctoolchain/usr/lib/swift_static/linux/static-stdlib-args.lnk
に-lDispatchStubs -lCoreFoundation -luuid
を追加することで--static-swift-stdlib
でのビルドが通るようになりました。 (edited)swift-sdk-generator
の成果物に対して、さらに$ cd ubuntu-jammy.sdk/usr/lib; ln -sf aarch64-linux-gnu/ld-linux-aarch64.so.1
と合わせて2箇所の修正が必要でした。 (edited)swift-sdk-generator
のubuntuパッケージダウンロードが不安定すぎて使いたくない。qemu-user-static
検出に使おうと思ってたpmap
がswiftlint
同様にqemu-user-static
環境でクラッシュする。apt-get install qemu-user-static
して入る6.2を使ったら、11回中3回クラッシュする感じになり、失敗したjobも再実行で通ったりして、とりあえずPRのビルドが全部通った。スッキリしない。 https://github.com/norio-nomura/docker-swiftlint/pull/37 (edited)/usr/lib/swift_static/linux/static-stdlib-args.lnk
に記述する方法swift build --swift-sdk
してターゲットSwift 5.10のツールチェインを起動して、ホストとターゲットのtripleが同じ時、ホスト用にビルドされる.o
とターゲット用にビルドされる.o
って、混ざったりしないのかな。 (edited).build/aarch64-unknown-linux-gnu/release/SwiftLintExtraRules-tool.build
ターゲット向けビルド: .build/aarch64-unknown-linux-gnu/release/SwiftLintExtraRules.build
みたいな感じで混ざらないらしい。.o
を渡していることが判明。失敗して当然だ。 (edited).build/aarch64-unknown-linux-gnu/release/description.json
を比較してみたところ、swiftlint
っていうモジュールが最終ターゲット用とプラグイン用で2つ作られていて失敗する方は中身が入れ替わってた。 それに合わせて、.build/release.yaml
に記述されるswiftlint.product/Objects.LinkFileList
の中身もプラグイン用にビルドされたものが渡されて、結果リンクが失敗するぽい。Package.swift
からプラグインのモジュール定義を外したらリンク通ることは確認した。/SwiftLint/.build
が残らないので、残せるように修正します。# repeat following until link error occurs docker buildx build --load builder/ --build-arg BUILDER_IMAGE=swiftlang/swift:nightly -t swiftlint:try --target native-builder --no-cache-filter native-builder --progress plain # if link error occurs, keep image with tag docker tag swiftlint:try swiftlint:link-error
How to extract /SwiftLint/.build
to link-error
directory: mkdir -p link-error; docker run --rm swiftlint:link-error tar czO -C /SwiftLint .build | tar xzvf - -C link-error
(edited)aarch64-on-aarch64
, x86_64-on-x86_64
でランダムで起き、aarch64-on-x86_64
, x86_64-on-aarch64
では起きません。 (edited)--target native-builder
を追加。# repeat following until link error occurs docker buildx build --load . -t poc-module-name-conflict:try --progress plain \ --target builder --no-cache-filter native-builder # after link error occurs, keep image with tag using --target native-builder docker buildx build --load . -t poc-module-name-conflict:try --progress plain \ --target native-builder # if link error occurs, keep image with tag docker tag poc-module-name-conflict:try poc-module-name-conflict:link-error
How to extract /poc-module-name-conflict/.build
to link-error
directory: mkdir -p link-error; \ docker run --rm poc-module-name-conflict:link-error \ tar czO -C /poc-module-name-conflict .build | tar xzvf - -C link-error
(edited)--no-cache-filter
が無いと怒られてしまったbrew install lima
2. if docker for mac is not installed, install docker cli brew install docker docker-buildx docker-completion
3. create docker instance limactl create https://gist.githubusercontent.com/norio-nomura/9f8d469252a13adf2efdc49af0a47a30/raw/a700cc7261f8e782fd0b7c5373ef1201b5158a0d/lima.yaml --tty=false --name docker
4. enable boot dokcer instance at login limactl start-at-login --enabled docker
5. create "lima-docker" context to use docker context create lima-docker --docker host=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
6. use "lima-docker" as default context docker context use lima-docker
https://gist.github.com/norio-nomura/9f8d469252a13adf2efdc49af0a47a30 (edited)template://docker
に対し containerd-snapshotter
を有効にしてmulti arch build出来るようにbuildkit
を有効にして、docker build
をdocker buildx build
に.build
と正常にリンクできた.build
をCIのアーティファクトからダウンロード出来るように、明日以降するかもしれません。 (edited)--mount=type=bind,target=${BUNDLE_PATH}/${TARGET_TRIPLE_ARCH},from=runtime
これを維持したままシェルを繋ぎたい#if os(macOS)
でbinaryTarget
が定義されてるのだけど、linuxでもダウンロードされるのが気になってて。これって意図された動作なのかな。 https://github.com/realm/SwiftLint/blob/3e8a0516b248cfa4f51d7caa321c842013c42572/Package.swift#L166-L174--mount=type=bind,target=${BUNDLE_PATH}/${TARGET_TRIPLE_ARCH},from=runtime
これを維持したままシェルを繋ぎたい buildx build --load . --progress plain --build-arg SLEEP=1
Build session will hangs at sleep like following: #31 0.090 Enter the following command to enter build session: #31 0.090 lima user: #31 0.090 limactl shell docker bash -c 'sudo nsenter --all --target=$(lsns|awk "/^4026532477/{print \$4}") bash' #31 0.090 #31 0.090 Docker for Mac user: #31 0.090 docker run -it --privileged --pid=host --rm ubuntu bash -c 'nsenter --all --target=$(lsns|awk "/^4026532477/{print \$4}") bash'
Copy and paste the command to enter build session. $ docker run -it --privileged --pid=host --rm ubuntu bash -c 'nsenter --all --target=$(lsns|awk "/^4026532477/{print \$4}") bash' ################################################################ # # # Swift Nightly Docker Image # # Tag: swift-DEVELOPMENT-SNAPSHOT-2024-06-13-a # # # ################################################################ root@buildkitsandbox:/#
(edited)nsenter(1)
を使う手法。$ limactl shell docker bash -c 'sudo nsenter --all --target=$(lsns|awk "/^4026532602/{print \$4}") bash' ################################################################ # # # Swift Nightly Docker Image # # Tag: swift-DEVELOPMENT-SNAPSHOT-2024-06-13-a # # # ################################################################ root@buildkitsandbox:/#
docker buildx build https://gist.github.com/edf224977880e6e7598e76b1330f2990.git --build-arg SLEEP=1
docker buildx build
- DockerfileRUN --mount=type=cache
のターゲットディレクトリ内ならば、ビルドセッションを跨いでも維持されるのかな? (edited)swift-DEVELOPMENT-SNAPSHOT-2024-07-01-a
キタswift -version
しか実行してないから、引っかからないぽい。swift-DEVELOPMENT-SNAPSHOT-2024-07-01-a
dockerイメージを使って、クロスビルド使った問題再現用プロジェクトのビルドでリンクエラーが起きなくなったことを確認した。swift -version
しか実行してないから、引っかからないぽい。 docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
使ってインストールする方法。 (edited)docker/setup-qemu-action
、ubuntuやdebianからaptで配布されてるモノ、qemuのソース取得してビルドする、とか色々試してダメだったのに。multiarch/qemu-user-static
がインストールしているバージョンを調べたらdebian bookwormで使われてた7.2で、ubuntuでは使われていないバージョンだった。 ちなみにubuntuでのqemu-user-static
は focal: 4.2 jammy: 6.2 mantic: 8.0 noble: 8.2 で、僕が試してダメだったのは 6.2, 8.0, 8.2, 9.0.1(自前ビルド)swift-6.0-DEVELOPMENT-SNAPSHOT-2024-07-02-a
にリンクエラー対策パッチがチェリーピックされてて swiftlang/swift:nightly-6.0-jammy
も更新されてたので、対策なしでリンクエラーが起きないことも確認した。tonistiigi/binfmt
, multiarch/qemu-user-static
の各バージョンをインストールして、arm64版swiftlintを2回動作確認で起動するDockerfileを10回ビルドし、クラッシュやハングアップしないかテストしてみた。 https://github.com/norio-nomura/compare-qemu-user-static/actions/runs/9856830637 (edited)tonistiigi/binfmt:latest
はダメで、multiarch/qemu-user-static:latest
は通る。norionomura/swiftlint
にaarch64追加した。 そしてqemu-user-static
のバージョンによりクラッシュ回避する情報をforumへ投稿した。 https://forums.swift.org/t/swift-runtime-unable-to-suspend-thread-when-compiling-in-qemu/67676/20environ
っていう環境変数ポインタが意図しない場所にある? setenv
とかを使うとずれてしまうことがあるらしい?***GRABBING ARGV for 5534*** envp = 0xaaaaffb21da0, stack is from 0xffffebec0000 to 0xffffebee1000 ARGV is at (nil) with count 0 ***ARGV GRABBED***
setenv
を使うとenviron
が大きくずれることはわかったけど、自前でsetenv
を_swift_stdlib_getUnsafeArgvArgc
よりも先に呼び出す方法がわからなくてうまく再現できないAppC
モジュールをApp
ターゲットがimportする形にしてますa.cpp
の中にhttps://github.com/swiftlang/swift/blob/afe1fa0c09ff240756bd3e15d3e441bc4a71e776/stdlib/public/CommandLineSupport/CommandLine.cpp#L231 のArgvGrabber
のコピペ実装を置いていて、そっちはsetenv
のあとに呼び出されていい感じに壊れるんですよねCommandLine.arguments
で出てくるSwift標準ライブラリのArgvGrabber
は正しい結果を返していて、うまく再現できないlibBadLib.so
ができたのでdynamicになったっぽいroot@36e7be3c11c2:/empty-args-test# swift run Building for debugging... [10/10] Linking App Build complete! (0.41s) 😈 use 'setenv' in static constructor a.cpp: ***GRABBING ARGV for 6756*** a.cpp: envp = 0xaaaaf3b8a940 a.cpp: envp = 0xaaaaf3b8a940, stack is from 0xffffd25d0000 to 0xffffd25f1000 ARGV is at (nil) with count 0 // ←自前実装のArgvGrabberは壊れてる a.cpp: ***ARGV GRABBED*** Hello, World! CommandLine.arguments: [".build/aarch64-unknown-linux-gnu/debug/App"] // ←SwiftStdLibのほうはうまく動いてる
(lldb) bt * thread #1, name = 'App', stop reason = breakpoint 1.1 2.1 * frame #0: 0x0000fffff5adc9f4 libc.so.6`__setenv(name="ZES_ENABLE_SYSMAN", value="1", replace=1) at setenv.c:255:6 frame #1: 0x0000fffff7fc7624 frame #2: 0x0000fffff7fc772c
ZES_ENABLE_SYSMAN
とかいう怪しい文字列は得られた(lldb) image lookup -a 0x0000fffff58ac9f4 Address: libc.so.6[0x000000000003c9f4] (libc.so.6.PT_LOAD[0]..text + 88500) Summary: libc.so.6`__setenv at setenv.c:255:6
(lldb) breakpoint set -n setenv Breakpoint 1: no locations (pending). WARNING: Unable to resolve breakpoint to any actual locations. (lldb) run Process 7724 launched: '/empty-args-test/.build/debug/App' (aarch64) 1 location added to breakpoint 1 Process 7724 stopped * thread #1, name = 'App', stop reason = breakpoint 1.1 frame #0: 0x0000fffff58ac9f4 libc.so.6`__setenv(name="ZES_ENABLE_SYSMAN", value="1", replace=1) at setenv.c:255:6 (lldb) bt * thread #1, name = 'App', stop reason = breakpoint 1.1 * frame #0: 0x0000fffff58ac9f4 libc.so.6`__setenv(name="ZES_ENABLE_SYSMAN", value="1", replace=1) at setenv.c:255:6 frame #1: 0x0000fffff7fc7624 frame #2: 0x0000fffff7fc772c (lldb) image lookup -a 0x0000fffff7fc7624 (lldb) image lookup -a 0x0000fffff7fc772c (lldb)
(lldb) breakpoint set -n setenv Breakpoint 1: no locations (pending). WARNING: Unable to resolve breakpoint to any actual locations. (lldb) breakpoint set -r '^\$ss11CommandLine.*' Breakpoint 2: no locations (pending). WARNING: Unable to resolve breakpoint to any actual locations. (lldb) run Process 8380 launched: '/empty-args-test/.build/debug/App' (aarch64) 17 locations added to breakpoint 2 1 location added to breakpoint 1 Process 8380 stopped * thread #1, name = 'App', stop reason = breakpoint 1.1 frame #0: 0x0000fffff58ac9f4 libc.so.6`__setenv(name="ZES_ENABLE_SYSMAN", value="1", replace=1) at setenv.c:255:6 (lldb) c Process 8380 resuming :smiling_imp: use 'setenv' in static constructor Process 8380 stopped * thread #1, name = 'App', stop reason = breakpoint 1.1 frame #0: 0x0000fffff58ac9f4 libc.so.6`__setenv(name="FOO", value="BAR", replace=1) at setenv.c:255:6 (lldb) c Process 8380 resuming a.cpp: ***GRABBING ARGV for 8380*** a.cpp: envp = 0xaaaaaafee220 a.cpp: envp = 0xaaaaaafee220, stack is from 0xfffffffdf000 to 0x1000000000000 ARGV is at (nil) with count 0 a.cpp: ***ARGV GRABBED*** Hello, World! Process 8380 stopped * thread #1, name = 'App', stop reason = breakpoint 2.10 frame #0: 0x0000fffff7c20dec libswiftCore.so`$ss11CommandLineO9argumentsSaySSGvgZ libswiftCore.so`$ss11CommandLineO9argumentsSaySSGvgZ: -> 0xfffff7c20dec <+0>: stp x29, x30, [sp, #-0x10]! 0xfffff7c20df0 <+4>: adrp x0, 795 0xfffff7c20df4 <+8>: add x0, x0, #0x60 0xfffff7c20df8 <+12>: adrp x1, 0
main.swiftの中が走るまでの間にCommandLine
に誰も触ってないな・・・CommandLine
の呼び出しに関わらずargvを保持してるわDEBUG_ARGVGRABBER
をセットしてstdlibを自前でビルドする必要が・・・--static-swift-stdlib
したらstdlibより先に自前コードのコンストラクタセクションが開始されてそこでsetenv
すれば壊せる(dynamicにして壊せなかったのは、SwiftPMのdynamic libという時点でlibSwiftCoreの依存が自動で追加されてそっちが先にinitされるため。clang単体でやれば変わったかも) (edited)__attribute__((constructor(0)))
とかすれば誤魔化せそうimport Foundation fflush(stdout)
import Foundation fflush(stdout)
<stdin>:2:8: error: reference to var 'stdout' is not concurrency-safe because it involves shared mutable state 1 | import Foundation 2 | fflush(stdout) | `- error: reference to var 'stdout' is not concurrency-safe because it involves shared mutable state 3 | SwiftGlibc.stdout:1:12: note: var declared here 1 | public var stdout: UnsafeMutablePointer<FILE>! | `- note: var declared here
@preconcurrency
でよかった.swift-format
がないディレクトリで実行した場合に動かなくなったなとおもっていたのですが,どうやら設定ファイルを探す処理で無限ループしていたみたいです. macOS では問題ないので Foundation の URL
の挙動の違いが原因だったようです. https://github.com/swiftlang/swift-format/issues/694#issuecomment-2397669986 (edited)deletingLastPathComponent()
の単体テストって String
に対してはあるけれど,URL
に対してのテストコードは一切無いんですね.URL(filePath: "/foo", directoryHint: .isDirectory).deletingLastPathComponent().path()
が "/"
になりました..swift-format
がすでにあるディレクトリでしか実行しない人は踏まないので,踏む環境は限られると思いますがハマる人はめっちゃ踏みやすいですね. (edited)dirname
が同じ動作をしてたのを思い出した。はまりがちな罠なのかな。 override define dirname $(patsubst %/,%,$(dir $(patsubst %/,%,$1))) endef $(info dirname: $(call dirname,/foo)) test:
$ make test dirname: make: Nothing to be done for `test'.
(edited)/
の上が /..
になる環境もあるらしくて,その環境での無限ループを修正するために /foo
の上が空になる環境 (Linux の Swift 6.0) でまた無限ループが再発してしまった... この辺は連鎖的に問題が起こっていて大変そうですね... https://github.com/swiftlang/swift-format/pull/845swift -version
しか実行してないから、引っかからないぽい。 swift test
を aarch64 Linux の実機で実行するとクラッシュもしくはカーネルごとハングするので qemu-user-static の問題と関連していたりしないか気になってます. Fedora 40 (Asahi Linux) だとシェルごとクラッシュして,Raspberry Pi OS (Debian 12) だとカーネルごとハングしてマシンごと強制再起動するしかなくなります.どちらも aarch64 Linux です.x86_64 Linux 環境だと今のところ同じ条件でもこのような問題が起きたことはないです.aarch64 Linux 環境でもこのリポジトリの swift test
以外で同じ Swift ツールチェーンを使っている上では何も問題が起こったことがないです.Process.waitUntilExit()
がハングするんですがそんなことってあります? import Foundation let process = Process() process.executableURL = URL(fileURLWithPath: "/bin/sh") process.arguments = ["-c", "echo 'Hello, World!'"] let stdout = Pipe() process.standardOutput = stdout try process.run() let stdoutData = stdout.fileHandleForReading.readDataToEndOfFile() let stdoutString = String(data: stdoutData, encoding: .utf8)! process.waitUntilExit() // <- ここで固まって先に進まない print(stdoutString)
(edited)waitUntilExit
の前に while process.isRunning {}
するだけで通るようになるのも謎Process.waitUntilExit()
がハングするんですがそんなことってあります? import Foundation let process = Process() process.executableURL = URL(fileURLWithPath: "/bin/sh") process.arguments = ["-c", "echo 'Hello, World!'"] let stdout = Pipe() process.standardOutput = stdout try process.run() let stdoutData = stdout.fileHandleForReading.readDataToEndOfFile() let stdoutString = String(data: stdoutData, encoding: .utf8)! process.waitUntilExit() // <- ここで固まって先に進まない print(stdoutString)
(edited)waitUntilExit()
がハングアップするようになって、16.04へ戻したことがある。 (edited)swift-5.0-RELEASE
の時だった。まあ今でも実行環境により動かなくなる実装になっててもおかしくはない?swift package init --type executable
して swift build --swift-sdk arm64-apple-macosx --product test
で作成したtest
がmacOS上で動くところまで確認できたけど、botに使わせるのはかなりハードルが高いな。swift build --swift-sdk
が生成するコマンドラインを、botのCLIへ渡す必要がある。swift build --verbose --swift-sdk
で観測できる、生成されるfrontendへのコマンドラインオプションをコピーしてbotのCLIへ渡そうとすると、Discordのメッセージ長制限に引っかかる。swift build --swift-sdk
は、最後codesign
しようとしてcodesign
がなくて失敗する。import SwiftUI
もいける--swift-sdk
相当のオプションを暗黙で渡せるようにするのは現状では難しいです。 特定バージョンのコンパイラに最新SDKの組み合わせが常に使われるbotを別途用意するのはできるかも?ってところ。
-target arm64-apple-macosx15.0 -Onone -resource-dir /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -color-diagnostics -swift-version 6 -sdk /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -use-ld=lld -Xfrontend -tools-directory -Xfrontend /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/toolset/bin -sdk /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -ld-path=/home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/toolset/bin/ld64.lld -g -Xcc -isysroot -Xcc /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -Xcc -g -I /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/usr/lib -
swift build
が--swift-sdk
オプションの指定で上記オプションを生成する部分が、botが利用しているswift
には存在しないので、この面倒をみないと簡易にSwiftSDKを切り替えられる様にはできない。 (edited)/usr/bin/swift-frontend --version Swift version 6.0.3 (swift-6.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Target: x86_64-apple-macosx15.2 Swift version 6.0.3 (swift-6.0.3-RELEASE) Target: x86_64-apple-macosx15.2
(edited)import SwiftUI
(edited)import SwiftUI
(edited)/usr/bin/swift-frontend -frontend -interpret - -target x86_64-apple-ios18.2-macabi -enable-objc-interop -sdk /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -I /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/usr/lib -tools-directory /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/toolset/bin -empty-abi-descriptor -resource-dir /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -Xcc -isysroot -Xcc /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -module-name main -target-sdk-version 18.2 -target-sdk-name macosx15.2 -prebuilt-module-cache-path /home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules -external-plugin-path '/home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server' -external-plugin-path '/home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/home/bot/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server' -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins
Target: x86_64-apple-ios18.2-macabi Swift version 6.0.3 (swift-6.0.3-RELEASE) Target: x86_64-apple-ios18.2-macabi
(edited)#if canImport(Musl) print("Hello, Musl!") #endif
#if canImport(Musl) print("Hello, Musl!") #endif
Hello, Musl!
Target: x86_64-swift-linux-musl
sdkRootPath: /home/bot/.swiftpm/swift-sdks/swift-6.0.3-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.0.3-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/x86_64 swiftResourcesPath: /home/bot/.swiftpm/swift-sdks/swift-6.0.3-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.0.3-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/x86_64/usr/lib/swift_static swiftStaticResourcesPath: /home/bot/.swiftpm/swift-sdks/swift-6.0.3-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.0.3-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/x86_64/usr/lib/swift_static includeSearchPaths: not set librarySearchPaths: not set toolsetPaths: ["/home/bot/.swiftpm/swift-sdks/swift-6.0.3-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.0.3-RELEASE_static-linux-0.0.1/swift-linux-musl/toolset.json"]
(edited)import Musl print("Hello, Musl!")
import Musl print("Hello, Musl!")
Target: x86_64-swift-linux-musl <unknown>:0: error: compiled module was created by an older version of the compiler; rebuild 'Swift' and try again: /home/bot/.swiftpm/swift-sdks/swift-DEVELOPMENT-SNAPSHOT-2025-01-05-a_static-linux-0.0.1.artifactbundle/swift-DEVELOPMENT-SNAPSHOT-2025-01-05-a_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/x86_64/usr/lib/swift_static/linux-static/Swift.swiftmodule/x86_64-swift-linux-musl.swiftmodule
import Musl print("Hello, Musl!")
Hello, Musl!
Target: x86_64-swift-linux-musl
import Musl print("Hello, Musl!")
Hello, Musl!
Target: x86_64-swift-linux-musl
$ curl -fLsS https://download.swift.org/swift-6.1-branch/static-sdk/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz -O $ sha256 swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz SHA256 (swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz) = c701d3f5bb69464fd443f20c4748cab068c9c6d8f6995f1ba5be70022778d21f $ cat swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz <?xml version="1.0" encoding="UTF-8" standalone="no"?><Error><Code>404</Code><Message>No message</Message><RequestId>7e2efc3d-e9a6-48be-935e-8c25252d5475</RequestId></Error>
$ swift sdk install --checksum c701d3f5bb69464fd443f20c4748cab068c9c6d8f6995f1ba5be70022778d21f https://download.swift.org/swift-6.1-branch/static-sdk/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz Downloading a Swift SDK bundle archive from `https://download.swift.org/swift-6.1-branch/static-sdk/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz`... Downloading 100% [=====================================================================================================] Downloading swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz Swift SDK bundle archive successfully downloaded from `https://download.swift.org/swift-6.1-branch/static-sdk/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz`. Verifying if checksum of the downloaded archive is valid... Downloaded archive has a valid checksum. Swift SDK bundle at `https://download.swift.org/swift-6.1-branch/static-sdk/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_static-linux-0.0.1.artifactbundle.tar.gz` is assumed to be an archive, unpacking... Error: tar: Error opening archive: Unrecognized archive format
curl
でAccept-Encoding: ...
を渡していないのにたまにContent-Encoding: gzip
で返されて、鍵のインポート時にエラー gpg: no valid OpenPGP data found.
で失敗してた。 curl
で明示的に--compressed
を使うことでエラー回避。swift
のサブコマンド追加、macOSだとPATHが通ってればどこに置いても良いけど、Linuxだとswift
と同じディレクトリしか認識しない。CommandLine.arguments[0]
がAbsolutePath
だとそのパスのディレクトリ決め打ちになる。 [https://github.com/swiftlang/swift-driver/blob/8cbf26f4024d333cc5108403d08f8dd07048141f/Sources/swift-driver/main.swift#L125]swift-driver
をmacOSでビルドして実行すると、Linux同様swift
と同じディレクトリからしか見つけてくれない もしかしてmacOSの/usr/bin/swift
がswift-driver
とは関係なく、勝手にやってる動作なのでは (edited)