ainame / Swift-WebP

A thin libwebp wrapper in Swift that provides both encode/decode APIs
MIT License
163 stars 39 forks source link

Enable builds on Ubuntu in GitHub actions #35

Closed ainame closed 5 years ago

ainame commented 5 years ago

I seemed to end up with facing a bug in Swift compiler or SPM. It seems that a linking command using ld.gold is consuming wrong parameters given from swiftc when running swift test command.

$ swift test --enable-test-discovery -v

/usr/bin/swift -frontend -merge-modules -emit-module /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.build/WebPTests~partial.swiftmodule /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.build/main~partial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-unknown-linux -disable-objc-interop -sdk / -I /Swift-WebP/.build/x86_64-unknown-linux/debug -I /usr/local/include -enable-testing -g -module-cache-path /Swift-WebP/.build/x86_64-unknown-linux/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/Swift-WebP/Sources/CWebP/module.modulemap -emit-module-doc-path /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.swiftdoc -module-name WebPPackageTests -o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.swiftmodule
/usr/bin/swiftc -sdk / -L/usr/local/lib -lwebp -g -L /Swift-WebP/.build/x86_64-unknown-linux/debug -o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.xctest -module-name WebPPackageTests -emit-executable -Xlinker '-rpath=$ORIGIN' @/Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.product/Objects.LinkFileList -target x86_64-unknown-linux -L /usr/lib
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
clang-7: 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)

The last command executed in the above /usr/bin/swift -frontend -merge-modules -emit-module /Swift-WebP/..... with -v option

 "/usr/bin/ld.gold" --sysroot=/ -pie -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.xctest //usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/Scrt1.o //usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crti.o //usr/lib/gcc/x86_64-linux-gnu/7.4.0/crtbeginS.o -L/usr/lib/swift/linux -L/usr/lib/swift -L/usr/local/lib -L/Swift-WebP/.build/x86_64-unknown-linux/debug -L/usr/lib -L//usr/lib/gcc/x86_64-linux-gnu/7.4.0 -L//usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu -L/usr/bin/../lib/x86_64-linux-gnu -L//lib/x86_64-linux-gnu -L//lib/../lib64 -L//usr/lib/x86_64-linux-gnu -L//usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../.. -L/usr/bin/../lib -L//lib -L//usr/lib -rpath /usr/lib/swift/linux -rpath /usr/lib/swift /usr/lib/swift/linux/x86_64/swiftrt.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/InternalRawRepresentable.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/WebPDecoder+Platform.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/WebPDecoder.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/WebPDecoderConfig.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/WebPEncoder+Platform.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/WebPEncoder.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/WebPEncoderConfig.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/WebPError.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebP.build/WebPImageInspector.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.build/WebPTests.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPPackageTests.build/main.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPTests.build/ResourceAccessHelper.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPTests.build/WebPEncoderIOSTests.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPTests.build/WebPEncoderMacOSTests.swift.o /Swift-WebP/.build/x86_64-unknown-linux/debug/WebPTests.build/WebPImageInspectorTests.swift.o -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lpthread -lutil -ldl -lswiftCore -lm -lFoundation -lswiftGlibc -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -lXCTest -lswiftCore -lswiftGlibc -lpthread -lutil -ldl -lm -lFoundation -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lXCTest -lswiftCore -lswiftGlibc -lpthread -lutil -ldl -lm -lFoundation -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lXCTest -lswiftCore -lswiftGlibc -lpthread -lutil -ldl -lm -lFoundation -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lXCTest -lswiftCore -lswiftGlibc -lpthread -lutil -ldl -lm -lFoundation -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lXCTest -lswiftCore -lswiftGlibc -lpthread -lutil -ldl -lm -lFoundation -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lXCTest -lswiftCore -lswiftGlibc -lpthread -lutil -ldl -lm -lFoundation -lswiftDispatch -ldispatch -lBlocksRuntime -lswiftSwiftOnoneSupport -llibwebp -lswiftCore -lwebp "-rpath=\$ORIGIN" -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc //usr/lib/gcc/x86_64-linux-gnu/7.4.0/crtendS.o //usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
/usr/bin/ld.gold: error: cannot find -llibwebp
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)

It looks like swiftc emits wrong parameter -llibwebp which should be -lwebp.