Skip to content

addpkg(main/hledger-cli): 1.43.2 #25265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open

addpkg(main/hledger-cli): 1.43.2 #25265

wants to merge 54 commits into from

Conversation

erplsf
Copy link

@erplsf erplsf commented Jul 5, 2025

Greetings,

This is a PR in an attempt to package hledger for Termux. I'm not very accustomed with the way that Haskell programs are built, and even less so with Termux-specific process. I've tried to follow the general steps where I could - added dependencies and other small tweaks.

I've decided to adjust common build steps make and make_install to also detect other naming convention for Cabal projects.

But the build fails now on compiling exe:alex and I'm out of luck. Any help or pointers are very welcome.

Here I also attach the full build log when running ./scripts/run-docker.sh ./build-package.sh -f -I hledger.

Ideally this closes #3803 and simonmichael/hledger#398.

build.log

This was referenced Jul 5, 2025
@erplsf erplsf changed the title Package hledger for termux addpkg(main/hledger): 1.43.2 Jul 5, 2025
@erplsf erplsf force-pushed the master branch 2 times, most recently from 62e4add to 235c3a6 Compare July 5, 2025 11:04
@erplsf erplsf requested a review from thunder-coding July 5, 2025 11:05
@robertkirkman
Copy link
Contributor

It says that the first error that will need to be solved is File permission check: FAILED (executable bit is set),

this can happen because of using chmod +x packages/hledger/build.sh. Try using these commands to resolve this, then the build in CI could proceed to other errors:

chmod -x packages/hledger/build.sh
git add packages/hledger/build.sh
git commit --amend
# try "downstream" first, later "origin" or whatever shows to the left of your fork repository
# URL in the output from the command "git remote -v"
git push -f downstream master

build.sh files in Termux are, I guess, special because they are not directly executed immediately; instead, they are sourced and their functions are run later at separate times.

@erplsf
Copy link
Author

erplsf commented Jul 5, 2025

Thank you, I'll try that.

But while the build fails in CI, could you take a look at the local build result or you trust CI only?

@robertkirkman
Copy link
Contributor

I could soon sure, but also, I have requested for MrAdityaAlok to check if they know any way to build this software for Android and resolve the error, because they are very great with Haskell for Android and also they will know the best changes to make to cabal commands in termux_step_make.sh and termux_step_make_install.sh.

@erplsf
Copy link
Author

erplsf commented Jul 5, 2025

I see other linting failures meanwhile, will get on to fixing them.

@erplsf
Copy link
Author

erplsf commented Jul 5, 2025

got up to dlopen failed: "/data/data/com.termux/files/usr/lib/libpthread.so" is too small to be an ELF executable: only found 11 bytes error on x86_64 build locally.

@erplsf
Copy link
Author

erplsf commented Jul 5, 2025

I've tried also to build the package for aarch64 without bundled in Cabal config (by overriding termux_step_make with just cabal build all). this gets me to a mysterious <no location info>: error: External interpreter terminated (255) when building brick-2.9.

- Executable stripping does not work while cross-compiling

Signed-off-by: Aditya Alok <[email protected]>
@erplsf
Copy link
Author

erplsf commented Jul 6, 2025

I get much further when reverting a config change to Cabal - so I think indeed, something got fixed for shellcheck but broken for all other packages.
I'll attach a build log in a bit, when the new run finishes.

@MrAdityaAlok
Copy link
Member

@erplsf #25273 should fix your issue.

@erplsf
Copy link
Author

erplsf commented Jul 6, 2025 via email

@erplsf erplsf requested a review from MrAdityaAlok July 7, 2025 09:32
@erplsf
Copy link
Author

erplsf commented Jul 7, 2025

now that it build in ci, I'll go ahead and try to build it on my device to see if it runs/is usable (in case I forgot any dependencies)

@robertkirkman
Copy link
Contributor

robertkirkman commented Jul 7, 2025

now that it build in ci, I'll go ahead and try to build it on my device to see if it runs/is usable (in case I forgot any dependencies)

I know of several global errors that happened the last time I tried to build any haskell packages on-device, I assumed it was just not ready yet. but maybe now, we can find a way to fix those errors if they still happen.

@robertkirkman
Copy link
Contributor

thanks for the idea, but as upstream (hledger) itself only provides 64bit downloads, I'm hesitant in trying to even try to build it for 32bit.

Yes, that's ok if it's too tedious to do that.

Just now, I did try to build using the patch for basement that MrAdityaAlok sent, and it succeeded for aarch64, but for 32-bit arm it failed with this error:

error for 32-bit ARM of building PR #25265 including the patch for basement
Failed to build cborg-0.2.10.0.
Build log (
/home/builder/.cache/cabal/logs/ghc-9.12.2/cborg-0.2.10.0-bb163ac9a8bf4883e5d6262773b4128df5bea9a994b916970449b526d6ac046d.log
):
Configuring library for cborg-0.2.10.0...
Preprocessing library for cborg-0.2.10.0...
Building library for cborg-0.2.10.0...
[ 1 of 14] Compiling Codec.CBOR.ByteArray.Internal ( src/Codec/CBOR/ByteArray/Internal.hs, dist/build/Codec/CBOR/ByteArray/Internal.o )
[ 2 of 14] Compiling Codec.CBOR.ByteArray.Sliced ( src/Codec/CBOR/ByteArray/Sliced.hs, dist/build/Codec/CBOR/ByteArray/Sliced.o )
src/Codec/CBOR/ByteArray/Sliced.hs:44:1: warning: [GHC-66111] [-Wunused-imports]
    The qualified import of ‘Data.ByteString.Short.Internal’ is redundant
      except perhaps to import instances from ‘Data.ByteString.Short.Internal’
    To import instances alone, use: import Data.ByteString.Short.Internal()
   |
44 | import qualified Data.ByteString.Short.Internal as BSS
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[ 3 of 14] Compiling Codec.CBOR.ByteArray ( src/Codec/CBOR/ByteArray.hs, dist/build/Codec/CBOR/ByteArray.o )
src/Codec/CBOR/ByteArray.hs:39:1: warning: [GHC-66111] [-Wunused-imports]
    The qualified import of ‘Data.ByteString.Short.Internal’ is redundant
      except perhaps to import instances from ‘Data.ByteString.Short.Internal’
    To import instances alone, use: import Data.ByteString.Short.Internal()
   |
39 | import qualified Data.ByteString.Short.Internal as BSS
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[ 4 of 14] Compiling Codec.CBOR.Decoding ( src/Codec/CBOR/Decoding.hs, dist/build/Codec/CBOR/Decoding.o )
src/Codec/CBOR/Decoding.hs:426:62: error: [GHC-83865]
    • Couldn't match expected type ‘Word#’ with actual type ‘Word64#’
    • In the first argument of ‘toWord64’, namely ‘w64#’
      In the first argument of ‘k’, namely ‘(toWord64 w64#)’
      In the expression: k (toWord64 w64#)
    |
426 |   Decoder (\k -> return (ConsumeWord64 (\w64# -> k (toWord64 w64#))))
    |                                                              ^^^^

src/Codec/CBOR/Decoding.hs:445:65: error: [GHC-83865]
    • Couldn't match expected type ‘Word#’ with actual type ‘Word64#’
    • In the first argument of ‘toWord64’, namely ‘w64#’
      In the first argument of ‘k’, namely ‘(toWord64 w64#)’
      In the expression: k (toWord64 w64#)
    |
445 |   Decoder (\k -> return (ConsumeNegWord64 (\w64# -> k (toWord64 w64#))))
    |                                                                 ^^^^

src/Codec/CBOR/Decoding.hs:485:60: error: [GHC-83865]
    • Couldn't match expected type ‘Int#’ with actual type ‘Int64#’
    • In the first argument of ‘toInt64’, namely ‘n64#’
      In the first argument of ‘k’, namely ‘(toInt64 n64#)’
      In the expression: k (toInt64 n64#)
    |
485 |   Decoder (\k -> return (ConsumeInt64 (\n64# -> k (toInt64 n64#))))
    |                                                            ^^^^

src/Codec/CBOR/Decoding.hs:525:71: error: [GHC-83865]
    • Couldn't match expected type ‘Word#’ with actual type ‘Word64#’
    • In the first argument of ‘toWord64’, namely ‘w64#’
      In the first argument of ‘k’, namely ‘(toWord64 w64#)’
      In the expression: k (toWord64 w64#)
    |
525 |   Decoder (\k -> return (ConsumeWord64Canonical (\w64# -> k (toWord64 w64#))))
    |                                                                       ^^^^

src/Codec/CBOR/Decoding.hs:544:74: error: [GHC-83865]
    • Couldn't match expected type ‘Word#’ with actual type ‘Word64#’
    • In the first argument of ‘toWord64’, namely ‘w64#’
      In the first argument of ‘k’, namely ‘(toWord64 w64#)’
      In the expression: k (toWord64 w64#)
    |
544 |   Decoder (\k -> return (ConsumeNegWord64Canonical (\w64# -> k (toWord64 w64#))))
    |                                                                          ^^^^

src/Codec/CBOR/Decoding.hs:584:69: error: [GHC-83865]
    • Couldn't match expected type ‘Int#’ with actual type ‘Int64#’
    • In the first argument of ‘toInt64’, namely ‘n64#’
      In the first argument of ‘k’, namely ‘(toInt64 n64#)’
      In the expression: k (toInt64 n64#)
    |
584 |   Decoder (\k -> return (ConsumeInt64Canonical (\n64# -> k (toInt64 n64#))))
    |                                                                     ^^^^

src/Codec/CBOR/Decoding.hs:990:22: error: [GHC-83865]
    • Couldn't match expected type ‘Int#’ with actual type ‘Int64#’
    • In the first argument of ‘intToInt64#’, namely ‘off#’
      In the first argument of ‘I64#’, namely ‘(intToInt64# off#)’
      In the first argument of ‘k’, namely ‘(I64# (intToInt64# off#))’
    |
990 |         (intToInt64# off#)
    |                      ^^^^

[ 5 of 14] Compiling Codec.CBOR.Magic ( src/Codec/CBOR/Magic.hs, dist/build/Codec/CBOR/Magic.o )
src/Codec/CBOR/Magic.hs:124:1: error: [GHC-87110]
    Could not find module ‘GHC.IntWord64’.
    Use -v to see a list of the files searched for.
    |
124 | import           GHC.IntWord64 (wordToWord64#, word64ToWord#,
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

[ 7 of 14] Compiling Codec.CBOR.Encoding[boot] ( src/Codec/CBOR/Encoding.hs-boot, dist/build/Codec/CBOR/Encoding.o-boot )
[ 8 of 14] Compiling Codec.CBOR.FlatTerm[boot] ( src/Codec/CBOR/FlatTerm.hs-boot, dist/build/Codec/CBOR/FlatTerm.o-boot )
[ 9 of 14] Compiling Codec.CBOR.Encoding ( src/Codec/CBOR/Encoding.hs, dist/build/Codec/CBOR/Encoding.o )
Error: [Cabal-7125]
Failed to build cborg-0.2.10.0 (which is required by exe:hledger from hledger-1.43.2). See the build log above for details.

@erplsf
Copy link
Author

erplsf commented Jul 7, 2025 via email

@erplsf
Copy link
Author

erplsf commented Jul 7, 2025

Got this at the moment:

dlopen failed: cannot locate symbol "stg_upd_frame_info" referenced by
"/data/data/com.termux/files/home/.cabal/store/ghc-9.12.2-inplace/quote-quot-0.2.1.0-f00e68c33f055879f54c456f833b4501b64ee4bacfccebfd737ffe8b47b82052/lib/
libHSquote-quot-0.2.1.0-f00e68c33f055879f54c456f833b4501b64ee4bacfccebfd737ffe8b47b82052-ghc9.12.2.so
"...

[ 8 of 10] Compiling Data.Text.Builder.Linear.Char (
src/Data/Text/Builder/Linear/Char.hs,
dist/build/Data/Text/Builder/Linear/Char.o,
dist/build/Data/Text/Builder/Linear/Char.dyn_o )
Error: [Cabal-7125]
Failed to build text-builder-linear-0.1.3 (which is required by exe:hledger
from hledger-1.43.2). See the build log above for details.

@erplsf
Copy link
Author

erplsf commented Jul 7, 2025

if get the build to work on device first we can later work on refactoring the scripts.

@erplsf
Copy link
Author

erplsf commented Jul 7, 2025

what is already suspicious is that on device ghc is 9.12.2, which is older than in CI/docker.
edit: this is incorrect, ci also uses 9.12.2.

@erplsf
Copy link
Author

erplsf commented Jul 7, 2025

stg_upd_frame_info is also referenced here. if we want we can drop work on the on-device build for now and accept the win that we already have - we can try to package and distribute it as a binary for now.

@robertkirkman
Copy link
Contributor

robertkirkman commented Jul 7, 2025

if we want we can drop work on the on-device build for now and accept the win that we already have - we can try to package and distribute it as a binary for now.

This is acceptable, since there is already a very large amount of preexisting packages that cannot be built on-device. However, if you find any easy way to fix the problem for on-device building, it is still good to apply it.

Ideally, all packages would be great if buildable fully on-device, and I would like to get close to that goal some day, but this challenge is very difficult and can take many years, so some new packages being added that cannot be built on-device doesn't really slow it down that much, relatively.

@erplsf
Copy link
Author

erplsf commented Jul 7, 2025 via email

@robertkirkman
Copy link
Contributor

I started testing the aarch64 binary artifact a little bit, I have noticed some things that might be possible to tweak to polish the experience,

  • the command hledger demo 2 shows asciinema: callProcess: execvp: does not exist (No such file or directory), but pkg install asciinema resolves this. so, asciinema should be in TERMUX_PKG_DEPENDS of this package.
  • most distros name the package of this software "hledger" rather than "hledger-cli", so maybe the name of the folder should be changed here to "hledger" https://repology.org/project/hledger/versions

@erplsf
Copy link
Author

erplsf commented Jul 7, 2025

thanks! i assume you got the binary from the ci results?

@robertkirkman
Copy link
Contributor

thanks! i assume you got the binary from the ci results?

Correct

@MrAdityaAlok
Copy link
Member

Got this at the moment:

dlopen failed: cannot locate symbol "stg_upd_frame_info" referenced by
"/data/data/com.termux/files/home/.cabal/store/ghc-9.12.2-inplace/quote-quot-0.2.1.0-f00e68c33f055879f54c456f833b4501b64ee4bacfccebfd737ffe8b47b82052/lib/
libHSquote-quot-0.2.1.0-f00e68c33f055879f54c456f833b4501b64ee4bacfccebfd737ffe8b47b82052-ghc9.12.2.so
"...

[ 8 of 10] Compiling Data.Text.Builder.Linear.Char (
src/Data/Text/Builder/Linear/Char.hs,
dist/build/Data/Text/Builder/Linear/Char.o,
dist/build/Data/Text/Builder/Linear/Char.dyn_o )
Error: [Cabal-7125]
Failed to build text-builder-linear-0.1.3 (which is required by exe:hledger
from hledger-1.43.2). See the build log above for details.

"stg_upd_frame_info"
I have many times tried to solve this or even find what causes it, but never succeeded. It has occurred many a times during on device build.

@erplsf
Copy link
Author

erplsf commented Jul 7, 2025 via email

@erplsf
Copy link
Author

erplsf commented Jul 8, 2025

copying over a response from there:

geekosaur
does Android's dlopen not allow referencing already-loaded objects? every Haskell program (compiled by ghc) has libHSrts linked into it
(typically you dlopen NULL to access symbols already loaded into the program)
(I know you used 9.12.2 but that shared object goes back at least to ghc 6.0)

@MrAdityaAlok
Copy link
Member

copying over a response from there:

geekosaur
does Android's dlopen not allow referencing already-loaded objects? every Haskell program (compiled by ghc) has libHSrts linked into it
(typically you dlopen NULL to access symbols already loaded into the program)
(I know you used 9.12.2 but that shared object goes back at least to ghc 6.0)

Maybe it has something do with this: android/ndk#201

@erplsf
Copy link
Author

erplsf commented Jul 9, 2025

@MrAdityaAlok let's get this reviewed as change without on-device build - I'm making a pause on it now, as I won't have time to debug on-device builds anymore soon, so I want users to at least get the prebuilt version ready to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hledger
5 participants