termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

[Bug]: Cannot compile Swift packages in older Android

Open finagolfin opened this issue 1 year ago • 9 comments

Problem description

I build a Swift package in an old Android 9 device using the Swift compiler and get weird errors about not being able to find files. It works fine for me on the latest Android 13, so maybe it is related to the Android version?

If others on other Android versions can try this out, let me know what you find.

What steps will reproduce the bug?

  1. pkg install swift git
  2. git clone https://github.com/apple/swift-argument-parser.git
  3. cd swift-argument-parser
  4. swift build

What is the expected behavior?

Swift package builds fine.

System information

Android 9 AArch64 with all Termux packages up to date

finagolfin avatar Aug 17 '23 09:08 finagolfin

I tested it on all my available devices, and following are the results.

  1. Meizu PRO 6s (Android 7.1.1)
~/swift-argument-parser $ swift build
warning: 'swift-argument-parser': WARNING: linker: /data/data/com.termux/files/usr/tmp/TemporaryDirectory.3v37Ch/swift-argument-parser-manifest: unsupported flags DT_FLAGS_1=0x8000001
Building for debugging...
error: unexpected input file: /data/data/com.termux/files/home/swift-a
/data/data/com.termux/files/home/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:40:26: error: cannot find 'HelpCommand' in scope
      subcommands.append(HelpCommand.self)
                         ^~~~~~~~~~~
/data/data/com.termux/files/home/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:64:13: error: value of type 'String' has no member 'indentingEachLine'
        """.indentingEachLine(by: 4)
~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:90:11: error: value of type 'String' has no member 'indentingEachLine'
      """.indentingEachLine(by: 4) + "\n"
~~~~~~~~~ ^~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:106:12: error: value of type 'String' has no member 'indentingEachLine'
          .indentingEachLine(by: 8)
           ^~~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:127:8: error: value of type '[any ParsableCommand.Type]' has no member 'argumentsForHelp'
      .argumentsForHelp(visibility: .default)
       ^~~~~~~~~~~~~~~~
/data/data/com.termux/files/home/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:127:38: error: cannot infer contextual base in reference to member 'default'
      .argumentsForHelp(visibility: .default)
                                    ~^~~~~~~
/data/data/com.termux/files/home/swift-argument-parser/Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift:172:45: error: value of type 'String' has no member 'indentingEachLine'
        \(arg.bashValueCompletion(commands).indentingEachLine(by: 4))
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~
  1. Huawei Honor V8 (Android 8.0)
~/swift-argument-parser $ swift build
Building for debugging...
[109/109] Linking generate-manual
Build complete! (38.35s)
  1. Xiaomi MIX2S (Android 10)
~/swift-argument-parser $ swift build
Building for debugging...
[109/109] Linking generate-manual
Build complete! (21.25s)
  1. Xiaomi MIX4 (Android 12)
~/swift-argument-parser $ swift build
Building for debugging...
[109/109] Linking generate-manual
Build complete! (10.65s)
  1. Xiaomi Pad 5 Pro (Android 13)
~/swift-argument-parser $ swift build
Building for debugging...
[109/109] Linking generate-manual
Build complete! (10.68s)

licy183 avatar Aug 17 '23 14:08 licy183

Thanks a lot, @licy183, that is exactly the same error I see on a Snapdragon 820 device running Android 9. Since you don't see it on Android 8, maybe it's not related to the Android version. However, this is clearly only an issue on older devices, the question is why.

finagolfin avatar Aug 17 '23 15:08 finagolfin

Btw, I'm still running the old Termux 0.101 from the Play Store on that old device: any chance you are too on your 7.1.1 device alone?

finagolfin avatar Aug 17 '23 17:08 finagolfin

Btw, I'm still running the old Termux 0.101 from the Play Store on that old device: any chance you are too on your 7.1.1 device alone?

No. I use 0.118 on my Android 7.1.1 device.

licy183 avatar Aug 17 '23 22:08 licy183

Ahh, I just checked and I'm running 0.118 also: I had forgotten that I had updated to the F-Droid app and assumed I was still running the old Play Store version, so that's not it.

finagolfin avatar Aug 18 '23 05:08 finagolfin

Screenshot_2023-08-19_05-43-39

On Android 9. No errors.

Anonymous2716 avatar Aug 18 '23 23:08 Anonymous2716

Thanks, @Anonymous2716, guess it's not related to the Android version then. Can you check your Termux version with termux-info and maybe the CPU model?

finagolfin avatar Aug 19 '23 01:08 finagolfin

@finagolfin

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=UNKNOWN
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=2094
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://grimler.se/termux/termux-main stable main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
# x11-repo (sources.list.d/x11.list)
deb https://grimler.se/termux/termux-x11 x11 main
Updatable packages:
broot/stable 1.25.0 aarch64 [upgradable from: 1.24.2-1]
dart/stable 3.1.0 aarch64 [upgradable from: 3.0.7]
python-scipy/tur-packages 1.11.2 aarch64 [upgradable from: 1.11.1]
zlib-static/stable 1.3 aarch64 [upgradable from: 1.2.13]
zlib/stable 1.3 aarch64 [upgradable from: 1.2.13]
termux-tools version:
1.38.5
Android version:
9
Kernel build information:
Linux localhost 4.4.146 #2 SMP PREEMPT Wed Sep 9 18:47:45 CST 2020 aarch64 Android
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
com.termux.gui versionCode:7
com.termux.x11 versionCode:12
com.termux.styling versionCode:30

SoC : MediaTek Helio P20 , MT6757CD

Maybe try a clean install?

Anonymous2716 avatar Aug 19 '23 23:08 Anonymous2716

Thanks for the info. It was a clean install when I updated to the latest F-Droid-provided Termux version in the last year or so, but I suppose I could try that again.

finagolfin avatar Aug 20 '23 10:08 finagolfin

I simply updated a bunch of packages, including Swift to 5.10, and it is working now on the same Android 9 device. 🤷

finagolfin avatar Mar 12 '24 01:03 finagolfin

Oh, @licy183, can you check now on your Meizu PRO 6s, after updating all packages like I did?

finagolfin avatar Mar 12 '24 01:03 finagolfin

Emmm... swift cannot run on my device...

image

backtrace:

Thread 1 "swift-driver" received signal SIGBUS, Bus error.
0xf4d13f00 in __CFUniCharLoadBitmapData ()
   from /data/data/com.termux/files/usr/opt/ndk-multilib/arm-linux-androideabi/lib/libFoundation.so
(gdb) bt
#0  0xf4d13f00 in __CFUniCharLoadBitmapData ()
   from /data/data/com.termux/files/usr/opt/ndk-multilib/arm-linux-androideabi/lib/libFoundation.so
#1  0xf4d1417a in CFUniCharGetBitmapPtrForPlane ()
   from /data/data/com.termux/files/usr/opt/ndk-multilib/arm-linux-androideabi/lib/libFoundation.so
#2  0xf4cfd40c in CFStringFindWithOptionsAndLocale ()
   from /data/data/com.termux/files/usr/opt/ndk-multilib/arm-linux-androideabi/lib/libFoundation.so
#3  0xf4d00234 in CFStringCreateArrayWithFindResults ()
   from /data/data/com.termux/files/usr/opt/ndk-multilib/arm-linux-androideabi/lib/libFoundation.so
#4  0xf4b993d8 in $s10Foundation15NSMutableStringC18replaceOccurrences2of4with7options5rangeSiSS_SSAA8NSStringC14CompareOptionsVAA8_NSRangeVtF () from /data/data/com.termux/files/usr/opt/ndk-multilib/arm-linux-androideabi/lib/libFoundation.so
#5  0xf4b99104 in $s10Foundation8NSStringC20replacingOccurrences2of4with7options5rangeS2S_SSAC14CompareOptionsVAA8_NSRangeVtF ()
   from /data/data/com.termux/files/usr/opt/ndk-multilib/arm-linux-androideabi/lib/libFoundation.so
#6  0xf4b9eeb0 in $sSy10FoundationE20replacingOccurrences2of4with7options5rangeSSqd___qd_0_AA8NSStringC14CompareOptionsVSnySS5IndexVGSgtSyRd__SyRd_0_r0_lF () from /data/data/com.termux/files/usr/opt/ndk-multilib/arm-linux-androideabi/lib/libFoundation.so
#7  0xaaed220c in ?? ()
#8  0xaaed20e0 in ?? ()
#9  0xaad41a50 in ?? ()
#10 0xaad405e4 in ?? ()
#11 0xaad41e10 in ?? ()
#12 0xaae50484 in ?? ()
#13 0xaae19e74 in ?? ()
#14 0xaae20bb0 in ?? ()
#15 0xaac75554 in ?? ()
#16 0xaac6c3c4 in ?? ()
#17 0xab28944c in ?? ()
#18 0xf738cc7e in __libc_init () from /system/lib/libc.so
#19 0xaab58a24 in ?? ()

licy183 avatar Mar 12 '24 06:03 licy183

Huh, that's strange, works fine for me on Android 9 and Android 13 AArch64, will investigate.

finagolfin avatar Mar 12 '24 07:03 finagolfin

Oh wait, that's an armv7 device? That's not surprising, haven't tested those in awhile. Still, I will look into it.

finagolfin avatar Mar 12 '24 07:03 finagolfin