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

[Bug]: odin package doesn't work properly

Open xigoi opened this issue 2 years ago • 4 comments

Problem description

When I install the odin package and try to compile or run a valid Odin program (such as the first example in the documentation), it produces the following error:

Syntax Error: Path does not exist:

Doing the same on a non-Android device compiles the program as expected, so this is a Termux-specific issue.

What steps will reproduce the bug?

  • Install the odin package with pkg install odin
  • Create an empty directory and cd to it
  • Create a file hellope.odin with the following content:
    package main
    
    import "core:fmt"
    
    main :: proc() {
    	fmt.println("Hellope!")
    }
    
  • Run the command odin run .

What is the expected behavior?

The command should compile the program and output the text “Hellope!”.

System information

termux-info:

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=13097
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://termux.astra.in.ua/apt/termux-main/ stable main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/24 termux extras
Updatable packages:
All packages up to date
termux-tools version:
0.184
Android version:
11
Kernel build information:
Linux localhost 4.9.227-perf-g5de92d1 #1 SMP PREEMPT Sun May 16 21:25:04 CST 2021 aarch64 Android
Device manufacturer:
Xiaomi
Device model:
Mi 9 SE

xigoi avatar Jun 04 '22 15:06 xigoi

From https://odin-lang.org/docs/install/:

Notes for Linux:: The compiler currently relies on the core and shared library collection being relative to the compiler executable. Installing the compiler in the usual sense (to /usr/local/bin or similar) is therefore not as straight forward as you need to make sure the mentioned libraries are available. As a result, it is recommended to simply explicitly invoke the compiler with /path/to/odin in your preferred build system, or add /path/to/odin to $PATH.

And I'm pretty sure that only the compiler is installed, the libraries aren't: https://github.com/termux/termux-packages/blob/0d95692efb238f6da4b8cae4dde7bc4e020215c4/packages/odin/build.sh#L31-L33

j0ng4b avatar Jun 04 '22 22:06 j0ng4b

This seems to be the case. I did the following:

git clone https://github.com/odin-lang/Odin
cd Odin
git checkout dev-2022-04 # to have the matching version
cp $(which odin) .

Now, when I compile an Odin file with this copy of the compiler, it works correctly. However, when I run the produced executable, I get a new error:

error: Android 5.0 and later only support position-independent executables (-fPIE).

xigoi avatar Jun 05 '22 08:06 xigoi

However, when I run the produced executable, I get a new error:

This is the odin code that you've compiled? If yes, the error happens because the odin compiler isn't producing position-independent executables (-fPIE) and probably it doesn't support PIE executables: https://github.com/odin-lang/Odin/issues/919

j0ng4b avatar Jun 05 '22 16:06 j0ng4b

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 20 '22 21:07 stale[bot]