Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Android dynamic linker doesn't support DT_RPATH #598

Closed
bukzor opened this issue Feb 8, 2018 · 63 comments
Closed

Android dynamic linker doesn't support DT_RPATH #598

bukzor opened this issue Feb 8, 2018 · 63 comments
Assignees
Labels

Comments

@bukzor
Copy link
Contributor

bukzor commented Feb 8, 2018

I've been tinkering with getting Linuxbrew working under termux under Android under Chromebook. The final missing link is that the android linker has absolutely no support for rpath.

How would I go about instructing homebrew to use --enable-new-dtags when compiling for Android? This will cause it to create runpath entries, which the android linker does support.

I would propose we do this (--enable-new-dtags) for all of homebrew, if I had any idea of whether it would work, or what the effect would be.

@sjackman
Copy link
Member

sjackman commented Feb 9, 2018

Check out this wiki page: https://github.com/Linuxbrew/brew/wiki/Chromebook-Install-Instructions
I've never run Linuxbrew on Chromebook, and these instructions may be out of date.

@sjackman sjackman self-assigned this Feb 9, 2018
@sjackman sjackman added the bug label Feb 9, 2018
@sjackman
Copy link
Member

sjackman commented Feb 9, 2018

Wow. I had no idea that ld use RPATH by default. I assumed that is used RUNPATH. Thanks for teaching me something!

We use patchelf to modify the RPATH of installed binaries, and by default it changes RPATH to RUNPATH. So, executables installed from source will use RPATH and executables in poured bottles use RUNPATH. That's inconsistent and a bit weird. I prefer the behaviour of RPATH which overrides LD_LIBRARY_PATH. An incorrectly set LD_LIBRARY_PATH can break Linuxbrew executables. patchelf has an option --force-rpath to use RPATH than RUNPATH.

I'm surprised that Android OS doesn't support RPATH. Is that documented somewhere?

@sjackman sjackman changed the title Linuxbrew for Android: linker doesn't support rpath Android dynamic linker doesn't support DT_RPATH Feb 9, 2018
@sjackman
Copy link
Member

sjackman commented Feb 9, 2018

@sjackman sjackman closed this as completed Feb 9, 2018
emanresusername added a commit to emanresusername/brew that referenced this issue Feb 10, 2018
Linuxbrew#598
disclaimer: i have no idea what i'm doing
@bukzor
Copy link
Contributor Author

bukzor commented Feb 14, 2018

Apologies for the wallotext. I got excited.

@sjackman Thanks for the replies! I didn't notice them till now D: Could you advice me on the original question? How do I add an Android homebrew flavor that uses CFLAGS=-Wl,--enable-new-dtags?

If I set up a github repo that, when run in circleci, allows you to ssh to Android, would you use it? It would take me several hours to get it running smoothly, but I don't mind.

Although I personally have no opinion on RPATH vs RUNPATH, these are facts: All upstream maintainers prefer RUNPATH, and RPATH has been "deprecated" for ten years. Today, both Ubuntu and Arch compilers use RUNPATH by default, and of course the Android linker has no RPATH support. See also the patchelf default behavior. I believe their argument goes: LD_LIBRARY_PATH "should" be a user override for the linker, and RPATH was a design mistake.

Given that bottles use RUNPATH already, is that sufficient to prove that using RUNPATH rather than RPATH works fine for both Linuxbrew and the wider Homebrew? IMHO it would be a smart choice from a future-proofing perspective, but again, I don't feel strongly. I just want Linuxbrew for Android!

Re the Linuxbrew-chromebook wiki: It requires switching to dev mode which isn't an option for me, as I want to maintain corporate trust on this machine.

@sjackman
Copy link
Member

sjackman commented Feb 14, 2018

How do I add an Android homebrew flavor that uses CFLAGS=-Wl,--enable-new-dtags?

For now, modify this code to add -Wl,--enable-new-dtags. Once you get it working, open a PR, and we can talk about how to get it into Linuxbrew.

args += rpath_flags("#{wl}-rpath=", rpath_paths)

If I set up a github repo that, when run in circleci, allows you to ssh to Android, would you use it?

As much as I'd like to say yes, I'm afraid that I don't have the time to take on this project myself. I'm happy to answer questions though.

I believe their argument goes: LD_LIBRARY_PATH "should" be a user override for the linker, and RPATH was a design mistake.

I do understand the argument. For the purposes of Linuxbrew, however, I prefer RPATH to RUNPATH, because of how LD_LIBRARY_PATH is often used on high performance computing (HPC) systems. It's common to have LD_LIBRARY_PATH set globally (which in my opinion should never ever be done) to specify the locations of the system's compiler libraries, OpenBLAS, and other such libraries. Setting LD_LIBRARY_PATH in this way would however break all of the Linuxbrew executables, which would then use the HPC system libraries rather than the Linuxbrew libraries. That breakage is not what the user desires. Unsetting LD_LIBRARY_PATH would mean that all of the host executables would stop working. The only solution that I see is to use RPATH rather than RUNPATH so that Linuxbrew executables ignore LD_LIBRARY_PATH (which shouldn't be set anyway, but here we are).

Re the Linuxbrew-chromebook wiki: It requires switching to dev mode which isn't an option for me, as I want to maintain corporate trust on this machine.

Feel free to update the Linuxbrew Wiki with instructions that do not require dev mode. That'd be quite useful I think to other Android users.

@bukzor
Copy link
Contributor Author

bukzor commented Feb 14, 2018

Once you get it working, open a PR, and we can talk about how to get it into Linuxbrew.

Can do! :meseeks:

LD_LIBRARY_PATH is often used on high performance computing (HPC) systems.

You'll have an easier time convincing the HPC maintainers to switch to the (demonstrably better) system of using --prefix or rpath than to reverse the rpath->runpath migration. Again, I don't myself have any opinion on the matter, but those are facts. I maintained the blas/lapack installation at ATI (AMD), and I did it using --prefix. I think that qualifies as HPC? I maintained a whole bunch of shell scripts with inlined patches which amounted to a poor man's linuxbrew. It's why I'm excited about Linuxbrew.

Feel free to update the Linuxbrew Wiki with instructions that do not require dev mode. That'd be quite useful I think to other Android users.

This ticket is blocks such a thing from existing :D I'll do such when I get it working.

@sjackman
Copy link
Member

sjackman commented Feb 14, 2018

Can do! :meseeks:

Great!

You'll have an easier time convincing the HPC maintainers to switch

I don't unfortunately have the time to convince each HPC admin to stop globally setting LD_LIBRARY_PATH, and its use is widespread. I agree that using either RPATH or RUNPATH is miles better than setting LD_LIBRARY_PATH globally.

system of using --prefix

I'm not sure what you mean by this exactly. Using ./configure --prefix doesn't usually set the RPATH/RUNPATH of an executable. There are exceptions of course, but it's not the default behaviour.

than to reverse the rpath->runpath migration

Since RUNPATH is still not the default behaviour of ld, it look to me as though that migration is ongoing.

It's why I'm excited about Linuxbrew.

Great! ☺️

@emanresusername
Copy link
Contributor

@sjackman continuing from this thread

sadly i don't think it adds much to the investigation

brew install -s hello || brew gist-logs hello
Updating Homebrew...
CANNOT LINK EXECUTABLE "/usr/bin/gcc-7": library "libandroid-support.so" not found
CANNOT LINK EXECUTABLE "/usr/bin/clang": library "libLLVM-5.0.so" not found
Error: hello cannot be built with any available compilers.
Install Clang or brew install gcc
Error: No logs.

you were right, it was undoing my changes in brew update (just put exit 0 at the top of update.sh locally)
but then even after that no change :(

i did notice that when i put a random println in /data/data/com.termux/files/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/cc

near this patch, it never got printed, maybe there a different file i should be modifying or some other interaction in the ecosystem i'm not accounting for?

@sjackman
Copy link
Member

Try…

export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_ENV_FILTERING=1

@emanresusername
Copy link
Contributor

no dice 😢

but just as a sanity check, i put a exit 1 right at the top of this script and it didn't seem to affect anything

is there maybe something upstream that's looking at the $OSTYPE and linux-android doesn't match so it doesn't make it into .../linux/super/cc or something like that?

@sjackman
Copy link
Member

sjackman commented Feb 15, 2018

Try…

❯❯❯ brew irb <<<'superenv?'
#<Pathname:/home/sjackman/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super>

See

def superenv?
ARGV.env != "std" && Superenv.bin
end

@emanresusername
Copy link
Contributor

Yeah that seems right

rb(main):002:0> superenv?
=> #<Pathname:/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super>

Maybe just the ldflags method isn't getting called?

@sjackman
Copy link
Member

Check the files ~/.cache/Homebrew/Logs/hello/*.cc to see what superenv did or didn't do. What error message are you seeing with brew install -s hello ?

@emanresusername
Copy link
Contributor

emanresusername commented Feb 16, 2018

Same output from brew install -s hello as here
But interestingly there's no ~/.cache/Homebrew/Logs at all 😲
Any other directories to check or might we be venturing into termux/termux-chroot specific special behavior?

# UPDATE: output from `brew install -sd hello`
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/hello.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::AliasLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/perkeep.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromPathLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/hello.rb
CANNOT LINK EXECUTABLE "/usr/bin/gcc-7": library "libandroid-support.so" not found
CANNOT LINK EXECUTABLE "/usr/bin/clang": library "libLLVM-5.0.so" not found
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/llvm.rb
Error: hello cannot be built with any available compilers.
Install Clang or brew install gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/compilers.rb:127:in `compiler'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/compilers.rb:109:in `select_for'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/ENV/shared.rb:176:in `compiler'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/ENV/super.rb:40:in `setup_build_environment'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:85:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:202:in `<main>'

@sjackman
Copy link
Member

Use…

export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_ENV_FILTERING=1

and remove LD_LIBRARY_PATH from here:

LIBRARY_PATH LD_LIBRARY_PATH LD_PRELOAD LD_RUN_PATH

@emanresusername
Copy link
Contributor

emanresusername commented Feb 16, 2018

aww yiss. motha! fuckin! progress!
s/breadcrumbs/progress/

/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/hello.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::AliasLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/perkeep.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FromPathLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/hello.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/binutils.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/make.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/gcc.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/glibc.rb
==> Downloading https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
####################################################################################################################################### 100.0%
tar: gzip: Cannot exec: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Error: Failure while executing: tar xzf /home/.cache/Homebrew/hello-2.10.tar.gz
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils.rb:296:in `safe_system'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/download_strategy.rb:77:in `safe_system'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/download_strategy.rb:239:in `stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/resource.rb:115:in `block in unpack'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/fileutils.rb:14:in `block in mktemp'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/fileutils.rb:74:in `block in run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/fileutils.rb:74:in `chdir'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/fileutils.rb:74:in `run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/fileutils.rb:13:in `mktemp'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/resource.rb:114:in `unpack'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/resource.rb:92:in `stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1872:in `stage'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1090:in `brew'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:124:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils.rb:554:in `with_env'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:121:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:202:in `<main>'

... then pkg install gzip ... then

Already downloaded: /home/.cache/Homebrew/hello-2.10.tar.gz
==> ./configure --disable-silent-rules --prefix=/data/data/com.termux/files/home/linuxbrew/.linuxbrew/Cellar/hello/2.10
Last 15 lines from /home/.cache/Homebrew/Logs/hello/01.configure:
configure: WARNING: unrecognized options: --disable-debug
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... no
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc-7
checking whether the C compiler works... no
configure: error: in `/usr/tmp/hello-20180215-3532-do4wrh/hello-2.10':
configure: error: C compiler cannot create executables
See `config.log' for more details
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/debrew.rb:11:in `raise'
FormulaUnavailableError: No available formula with the name "xorg"
1. raise
2. ignore
3. backtrace
4. irb
5. shell
Choose an action:

(awaiting my input ... what do i do?!?)

@sjackman
Copy link
Member

😂

@sjackman
Copy link
Member

sjackman commented Feb 16, 2018

Please report the output of…

brew install -s hello
brew gist-logs hello

@emanresusername
Copy link
Contributor

https://gist.github.com/anonymous/b4b0ffe4cb58771ff4489ac0186a3c57
(i still have some of the random exit 1 and throw "this error if you ever execute this" changes in linux/super/cc (as well as the original --enable-new-dtags patch), doesn't seem like those are affecting anything, should i remove them all anyway?

@sjackman
Copy link
Member

I was hoping that there'd be a useful error message in config.log, but no such luck. Just this:

configure:4014: checking whether the C compiler works
configure:4036: gcc-7    conftest.c  >&5
configure:4040: $? = 1
configure:4078: result: no

https://gist.github.com/anonymous/b4b0ffe4cb58771ff4489ac0186a3c57#file-config-log-L71

I'd suggest starting an interactive Brew shell with brew sh and trying to compile a simple program like "Hello, world!" in that shell, and see if it works.

I see that Termux sets LD_PRELOAD.

Warning: Setting LD_* vars can break dynamic linking.
Set variables:
  LD_LIBRARY_PATH: /data/data/com.termux/files/usr/lib
  LD_PRELOAD: /data/data/com.termux/files/usr/lib/libtermux-exec.so

https://gist.github.com/anonymous/b4b0ffe4cb58771ff4489ac0186a3c57#file-00-doctor-out-L8

Try removing LD_LIBRARY_PATH and LD_PRELOAD from this list:

LIBRARY_PATH LD_LIBRARY_PATH LD_PRELOAD LD_RUN_PATH

@sjackman
Copy link
Member

You'll likely also have to add /data/data/com.termux/files/usr/lib to Linuxbrew's list of RPATH.

def determine_extra_rpath_paths

@emanresusername
Copy link
Contributor

emanresusername commented Feb 16, 2018

good news

more progress!

bad news

brew sh wasn't happy :(

Your shell has been configured to use Homebrew's build environment;
this should help you build stuff. Notably though, the system versions of
gem and pip will ignore our configuration and insist on using the
environment they were built under (mostly). Sadly, scons will also
ignore our configuration.
When done, type `exit'.
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/git: line 88: which: command not found
zsh: segmentation fault

news ?

this might be relevant to it not finding awk and which?

termux-chroot "which which awk"
/data/data/com.termux/files/usr/bin/applets/which
/data/data/com.termux/files/usr/bin/applets/awk

but the PATH doesn't include /data/data/com.termux/files/usr/bin/applets 🤔

@sjackman
Copy link
Member

sjackman commented Feb 16, 2018

Scientific progress goes boink

@sjackman
Copy link
Member

With export HOMEBREW_NO_ENV_FILTERING=1 your PATH should be preserved. See

brew/bin/brew

Lines 67 to 69 in 80394bd

if [[ -z "$HOMEBREW_NO_ENV_FILTERING" && "$1" != "test-bot" ]]
then
PATH="/usr/bin:/bin:/usr/sbin:/sbin"

That should get you past ./config.status: 1790: ./config.status: awk: not found

zsh: segmentation fault

¯\_(ツ)_/¯
What does /bin/sh point to? Can you use a shell other than zsh to get past this error?

@sjackman
Copy link
Member

Total shot in the dark, but try…

/system/bin/linker64 /data/data/com.termux/files/home/linuxbrew/.linuxbrew/bin/hello

@emanresusername
Copy link
Contributor

Segfaults as well 😭

@sjackman
Copy link
Member

Try…

brew install patchelf

@emanresusername
Copy link
Contributor

@sjackman
Copy link
Member

./configure: getconf: not found

https://gist.github.com/anonymous/6aee66948e494786a207a32551475402#file-01-configure-L35

Any chance there's a Termux package for getconf?

Try…

brew install tree

@emanresusername
Copy link
Contributor

there is a termux getconf. installing that and rerunning brew install patchelf
will try brew install tree after that, pending you screaming

NOOOOO STAHHHHPP!!!!! GOOD GOD MAN!!! WHAT ARE YOU DOING?!?!?!? ABORT!!!!! ABORT!!! STOP INSTALLING PATCHELF AND INSTALL TREE RIGHT THIS INSTANT!!!!

or something of the like...

@emanresusername
Copy link
Contributor

brew install patchelf: take 2 🎬
brew install tree underway...

@emanresusername
Copy link
Contributor

emanresusername commented Feb 17, 2018

brew install -v tree

@sjackman
Copy link
Member

brew install patchelf

g++-7 -Wall -static-libgcc -static-libstdc++   -o patchelf patchelf.o  
/data/data/com.termux/files/usr/bin/ld: cannot find -lc++_shared

https://gist.github.com/anonymous/3bd4a9255fd5c7be6f299ce768d69ee5#file-02-make-L10

@sjackman
Copy link
Member

brew install tree

tree.h:55:10: fatal error: langinfo.h: No such file or directory

https://gist.github.com/anonymous/d1a70ae4d526d679c24216c4ab37cb77#file-01-make-L14

@sjackman
Copy link
Member

sjackman commented Feb 17, 2018

Try…

brew install emojify
emojify :tada:

@sjackman
Copy link
Member

Try…

brew install pstree

@emanresusername
Copy link
Contributor

well, as i was pkg installing <things> to avoid embarrassing myself when i said "i already tried installing all those", turns out there was a lc++ package i didn't install (-‸ლ)
(i tried all the other permutations lc, lc_shared, lc++_shared)
pkg install lc++; brew install patchelf: in progress
brew install emojify pstree: pending ...

@emanresusername
Copy link
Contributor

@emanresusername
Copy link
Contributor

holy shit!

holy shit
EMOJIFY WORKED!!!

emojify :astonished: 
😲 

less-holy 💩

brew install pstree

@bukzor
Copy link
Contributor Author

bukzor commented Feb 17, 2018

Ehh. I wish I had noticed this thread going on. I've already fixed (or at least worked around) all this in my own studies. The only thing holding me back was the rpath issue above. I've lost the edits due to a chromebook powerwash (derp), but I'm sure I can reiterate them quickly. I'll start that today.

@sjackman
Copy link
Member

Woo! I take my successes where I can get them. 🤩

@sjackman
Copy link
Member

@bukzor Great!

@sjackman
Copy link
Member

pstree.c:62:14: fatal error: glob.h: No such file or directory

https://gist.github.com/anonymous/dee80dfdd81ebbde80ae82afd8d0ae93#file-01-make-L7
😭
glob.h is usually provided by glibc. Do you know whether Termux has a glibc package, or similar package to provide libc headers?

@sjackman
Copy link
Member

There's some good tidbits over here:
https://wiki.termux.com/wiki/Differences_from_Linux

pkg install termux-exec termux-chroot

I see there's also Clang as well as GCC 5. It's worth a shot too:
https://wiki.termux.com/wiki/Development_Environments#C

@emanresusername
Copy link
Contributor

pkg search glibc only gives

argp/stable 1.3 aarch64
  Standalone version of arguments parsing functions from GLIBC

I have clang (but not libclang) installed
And GCC from this repo

@sjackman
Copy link
Member

@bukzor Which packages provides libc and its headers, and is it glibc or some other libc implementation?

@bukzor
Copy link
Contributor Author

bukzor commented Feb 21, 2018

libc is shipped as part of "bionic", which is android's non-gnu libc. It's not packaged by termux.

I've pushed up the edits I've made to my own homebrew to a termux-support branch, and wrote a document for my debugging process on that branch.

@sjackman
Copy link
Member

sjackman commented Feb 21, 2018

Cool. Thanks, Buck! We're in the process of merging Linuxbrew/brew into Homebrew/brew. So Linuxbrew/brew won't merge patches that we don't think will be eventually accepted upstream into Homebrew/brew. Some of these patches could be merged upstream. If you open a PR, I can comment on which chunks I think could be merged upstream. Some of the issues could be handled by setting HOMEBREW configuration environment variables, such as HOMEBREW_TEMP, which could be documented in a Linuxbrew/brew Wiki page.

@bukzor
Copy link
Contributor Author

bukzor commented Feb 22, 2018

Great success: https://imgur.com/a/88G1J

(I wasn't able to copy the text out of termux in a way that would paste to gist.)
termux doesn't ship with a static libstdc++. emojify works too.

@sjackman: I saw that! Good luck!

I hope that I can somehow make an android (or should it be named termux?) specialization which sets the necessary defaults.

@sjackman
Copy link
Member

sjackman commented Feb 22, 2018

Nicely done!
🤖🍺 Androidbrew? Or Droidbrew?

@bukzor
Copy link
Contributor Author

bukzor commented Feb 22, 2018

I got pstree working by installing libandroid-glob-dev and adding -landroid-glob to the compiler invocation.

u0_a51@localhost:/data/data/com.termux/files/usr/tmp/pstree-20180221-11155-ophply
[2018-02-21 04:54:43 PM -0800 (Wed)]$ clang    -v  pstree.c   -o pstree -landroid-glob 
clang version 5.0.1 (tags/RELEASE_501/final)     
Target: i686--linux-android 
Thread model: posix 
InstalledDir: /data/data/com.termux/files/usr/bin 
"/data/data/com.termux/files/usr/bin/clang-5.0" -cc1 -triple i686--linux-android -emit-obj -mrelax-all -disable-free
 -disable-llvm-verifier -discard-value-names -main-file-name pstree.c -mrelocation-model pic -pic-level 2 
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array 
-target-cpu i686 -target-feature +ssse3 -v -dwarf-column-info -debugger-tuning=gdb 
-resource-dir /data/data/com.termux/files/usr/lib/clang/5.0.1 -internal-isystem /usr/local/include 
-internal-isystem /data/data/com.termux/files/usr/lib/clang/5.0.1/include 
-internal-externc-isystem /data/data/com.termux/files/usr/include -fdebug-compilation-dir /data/data/com.termux/files/usr/tmp/pstree-20180221-11155-ophply -ferror-limit 19 -fmessage-length 228 
-femulated-tls -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics 
-o /data/data/com.termux/files/usr/tmp/pstree-ae2c64.o -x c pstree.c
clang -cc1 version 5.0.1 based upon LLVM 5.0.1 default target i686--linux-android
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here: 
#include <...> search starts here:  
/data/data/com.termux/files/usr/lib/clang/5.0.1/include    
/data/data/com.termux/files/usr/include     
End of search list.  
"/data/data/com.termux/files/usr/bin/ld" -pie --eh-frame-hdr -m elf_i386 -dynamic-linker /system/bin/linker -o pstree /data/data/com.termux/files/usr/bin/../lib/crtbegin_dynamic.o 
-L/data/data/com.termux/files/usr/bin/../lib /data/data/com.termux/files/usr/tmp/pstree-ae2c64.o 
-landroid-glob -lgcc -ldl -lc -lgcc -ldl /data/data/com.termux/files/usr/bin/../lib/crtend_android.o

$ ./pstree
--= 05961 u0_a51 sleep 99999999

$ pstree 1
?-+-sleep 
`-2*[ssh-agent] 

$ pstree $$ 
bash-+-pstree  
`-6*[vim]

@bukzor bukzor mentioned this issue Feb 22, 2018
@sjackman
Copy link
Member

Termux could perhaps handle some of these idiosyncrasies by for example creating a symlink from libandroid-glob.so to libglob.so.

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

No branches or pull requests

3 participants