Linuxbrew / brew

:beer::penguin: The Homebrew package manager for Linux
https://linuxbrew.sh
BSD 2-Clause "Simplified" License
2.66k stars 237 forks source link

Android dynamic linker doesn't support DT_RPATH #598

Closed bukzor closed 6 years ago

bukzor commented 6 years ago

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.

bukzor commented 6 years ago

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 commented 6 years ago

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

sjackman commented 6 years ago

@bukzor Great!

sjackman commented 6 years ago
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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

bukzor commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Nicely done! :robot::beer: Androidbrew? Or Droidbrew?

bukzor commented 6 years ago

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]
sjackman commented 6 years ago

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