Conversation
| if [[ $# -eq 0 ]] | ||
| then | ||
| /bin/cat >&2 | ||
| cat >&2 |
There was a problem hiding this comment.
You can submit this change to Homebrew/brew.
| return if ld_so.readable? | ||
| sys_interpreter = ["/lib64/ld-linux-x86-64.so.2", "/lib/ld-linux.so.3", "/lib/ld-linux.so.2", "/lib/ld-linux-armhf.so.3"].find do |s| | ||
| sys_interpreter = ["/lib64/ld-linux-x86-64.so.2", "/lib/ld-linux.so.3", "/lib/ld-linux.so.2", "/lib/ld-linux-armhf.so.3", "/system/bin/linker"].find do |s| | ||
| Pathname.new(s).executable? |
There was a problem hiding this comment.
You can submit this change to Linuxbrew/brew.
There was a problem hiding this comment.
Please submit this change to Linuxbrew/brew in a separate PR.
| HOMEBREW_TEMP = Pathname.new(ENV.fetch("HOMEBREW_TEMP", "/tmp")) | ||
| # IF ANDROID | ||
| HOMEBREW_TEMP = Pathname.new(ENV.fetch("HOMEBREW_TEMP", "/data/data/com.termux/files/usr/tmp")) | ||
|
|
There was a problem hiding this comment.
Setting HOMEBREW_TEMP can go in https://github.com/Linuxbrew/brew/wiki/Android
There was a problem hiding this comment.
I wanted to just use $TMPDIR, but the line above dissuaded me.
The strategy I've used in past for such a problem is to create a short symlink (e.g. /tmp/t) that points to the arbitrary-length TMPDIR, then use the shorter path as TMPDIR. Of course, if /tmp isn't writable, it seems best to use TMPDIR as is.
Do you think the above suggestion could fit upstream?
There was a problem hiding this comment.
My guess is that they'd prefer to keep the existing behaviour, using HOMEBREW_TEMP and ignoring TMPDIR. An Android specific installer for Linuxbrew could set the environment variables needed for Android.
There was a problem hiding this comment.
| Pathname.new path | ||
| # IF ANDROID | ||
| elsif File.executable?(path = "/data/data/com.termux/files/usr/bin/#{tool}") | ||
| Pathname.new path |
There was a problem hiding this comment.
Add to https://github.com/Linuxbrew/brew/wiki/Android
ln -s /data/data/com.termux/files/usr/bin/* ~/.linuxbrew/bin/| Version.new build_version | ||
| elsif (path = locate("clang")) && | ||
| build_version = `#{path} --version`[/clang version (\d\.\d\.\d)/, 1] | ||
| Version.new build_version |
There was a problem hiding this comment.
I'd suggest removing this chunk and changing line 83 to (untested)
build_version = Utils.popen_read(path, "--version")[/clang(-| version )(\d{2,})/, 2]If clang --version also displays clang version x.x.x on Ubuntu, this change can go upstream to Homebrew/brew.
There was a problem hiding this comment.
Seems to!
$ clang --version
clang version 4.0.1-6 (tags/RELEASE_401/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ which clang
/usr/bin/clang
$ dpkg -S /usr/bin/clang
clang: /usr/bin/clang
$ dpkg -l clang
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-====================-===============-===============-=============================================
ii clang 1:4.0-37~exp3ub amd64 C, C++ and Objective-C compiler (LLVM based)
| if keep?(path) | ||
| args << "#{wl}--enable-new-dtags" | ||
| args << "#{wl}-rpath=" | ||
| end |
There was a problem hiding this comment.
This change cannot be sent upstream. Since the Android dynamic linker is open source, playing the long game, I'd suggest contributing a patch to Android to add support for DT_RPATH. Alternatively, I'd suggest the Termux ld tool enable --enable-new-dtags by default.
There was a problem hiding this comment.
I can't imagine Android being amenable to that since "rpath is a design bug". I'll look into option B.
| args += ["#{wl}--dynamic-linker=#{dynamic_linker_path}"] if dynamic_linker_path | ||
| args << "-B#{@opt}/glibc/lib" unless mode == :ld | ||
| args += path_flags("-L", library_paths) | ||
| args << "#{wl}--enable-new-dtags" |
|
|
||
| IFS=$'\n' | ||
| for path in $(/usr/bin/which -a "$SCM_FILE" 2>/dev/null) | ||
| for path in $(command -v "$SCM_FILE" 2>/dev/null) |
There was a problem hiding this comment.
This patch can go upstream to Homebrew/brew. which is not an essential utility on Debian and is not installed by default in the fedora Docker image. command -v is POSIX and universal.
There was a problem hiding this comment.
Do you suggest a separate CL for each of these little bits?
There was a problem hiding this comment.
What's a CL? I'd suggest a separate PR for each change.
There was a problem hiding this comment.
Sorry, yes. "CL" is our jargon at work for PR. You'll see a bunch of small PRs for this.
| if [[ -z "$HOMEBREW_NO_ENV_FILTERING" && "$1" != "test-bot" ]] | ||
| then | ||
| PATH="/usr/bin:/bin:/usr/sbin:/sbin" | ||
| PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin/applets" |
| FILTERED_ENV=() | ||
| # Filter all but the specific variables. | ||
| for VAR in HOME SHELL PATH TERM LOGNAME USER CI CIRCLECI TRAVIS SSH_AUTH_SOCK SUDO_ASKPASS \ | ||
| LD_LIBRARY_PATH ANDROID_ROOT ANDROID_DATA \ |
There was a problem hiding this comment.
This patch cannot go upstream. As a workaround, you can use HOMEBREW_NO_ENV_FILTERING=1
There was a problem hiding this comment.
I hope to convince termux to switch to using DT_RUNPATH, then we don't need this any more.
I added ANDROID_ROOT/DATA to silence some warnings, but I didn't dig into it much, and I suspect they're not essential.
There was a problem hiding this comment.
Added the environment variable to the android wiki page, and suggested upstream that termux enable RUNPATH by default like the rest of Linux. IMHO Homebrew should as well, but I'll leave well enough alone :)
ported from Linuxbrew#621
The --enable-new-dtags option to ld causes it to emit a RUNPATH rather than RPATH entry in the elf header. Because the Android linker supports RUNPATH but not RPATH, this means many things can now Just Work. This should (eventually) eliminate the need to set LD_LIBRARY_PATH. Prior art: This [became the default for Linux in 2013](https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=822b8bf) but I think termux isn't getting it because it reports "Android" instead of "Linux"? Or maybe the way it works changed since then. Regardless, [Debian has been using RUNPATH by default since December 2016.](https://sources.debian.org/src/binutils/2.27.90.20161231-1/debian/patches/ld-new-dtags-by-default.diff/?hl=27#L27) Their [newest configuration](https://sources.debian.org/src/binutils/2.30-7/debian/rules/#L362) uses the newer configuration option seen in this patch. The [suse and gentoo](https://web.archive.org/web/20160101182307/http://comments.gmane.org/gmane.comp.gnu.binutils/57379) maintainers said they did the same in 2004 and 2005, respectively. So it seems well battle-tested, to me. For the curious: This came up because I'm working on [getting Homebrew working under Termux](Linuxbrew/brew#621).
|
Between my six pull requests on three projects and the new wiki page, I think I got it all. |
|
Thanks, Buck! |
The --enable-new-dtags option to ld causes it to emit a RUNPATH rather than RPATH entry in the elf header. Because the Android linker supports RUNPATH but not RPATH, this means many things can now Just Work. This should (eventually) eliminate the need to set LD_LIBRARY_PATH. Prior art: This [became the default for Linux in 2013](https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=822b8bf) but I think termux isn't getting it because it reports "Android" instead of "Linux"? Or maybe the way it works changed since then. Regardless, [Debian has been using RUNPATH by default since December 2016.](https://sources.debian.org/src/binutils/2.27.90.20161231-1/debian/patches/ld-new-dtags-by-default.diff/?hl=27#L27) Their [newest configuration](https://sources.debian.org/src/binutils/2.30-7/debian/rules/#L362) uses the newer configuration option seen in this patch. The [suse and gentoo](https://web.archive.org/web/20160101182307/http://comments.gmane.org/gmane.comp.gnu.binutils/57379) maintainers said they did the same in 2004 and 2005, respectively. So it seems well battle-tested, to me. For the curious: This came up because I'm working on [getting Homebrew working under Termux](Linuxbrew/brew#621).
ported from Linuxbrew#621
Migrated from Linuxbrew/brew#621
This is the result of discussion in #598
More context here: https://docs.google.com/document/d/1FNMnPTKIrXkloFFoHtTXZl2yAgvXm4G-0hHAd0RbLVY/edit#heading=h.mkvoio42su01