在 Ubuntu 14.04 上构建 linuxbrew(自制软件)独立版本

Building linuxbrew (homebrew) standalone version on Ubuntu 14.04

首要问题

我正在努力将 linuxbrew standalone installation on Ubuntu 14.04.3 LTS, but the script in the original link is currently broken. My ideal answer would be a script that sets it up correctly in one go. I've improved the script 构建到 运行 并减少问题。

修复脚本的当前进度

在通过 linuxbrew 构建 gcc 作为独立设置的一部分时,我无法克服 crti.o 错误。但是,我找到了一些解释问题的资源:

我搜索了该文件,它就在那里!

find -name crti.o
./.linuxbrew/lib/crti.o
./.linuxbrew/Cellar/glibc/2.19/lib/crti.o

我目前遇到 crtn.o 的以下编译器错误:

/home/hbr/.linuxbrew/Cellar/binutils/2.25.1/x86_64-unknown-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/home/hbr/.linuxbrew/Cellar/binutils/2.25.1/x86_64-unknown-linux-gnu/bin/ld: cannot find -lc
/home/hbr/.linuxbrew/Cellar/binutils/2.25.1/x86_64-unknown-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
make[3]: *** [libgcc_s.so] Error 1
make[3]: Leaving directory `/tmp/gcc20150929-3726-hif3of/gcc-5.2.0/build/x86_64-unknown-linux-gnu/libgcc'
make[2]: *** [all-stage1-target-libgcc] Error 2
make[2]: Leaving directory `/tmp/gcc20150929-3726-hif3of/gcc-5.2.0/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/tmp/gcc20150929-3726-hif3of/gcc-5.2.0/build'
make: *** [bootstrap] Error 2

本质上,在这一步我需要弄清楚如何确保 brew/linuxbrew/the gcc 编译命令知道在哪里可以找到它。我尝试将其添加到 the script 中的 PATHLIBRARY_PATHLD_LIBRARY_PATH,但都没有成功。因此,必须有一些其他方法来确保正确设置路径并找到目标文件。有什么想法吗?

注意:我最初在this github issue中寻求帮助,但他们目前无法解决这个问题。

更新

我认为这个 linuxbrew gcc 公式 可能需要一个 linuxbrew 案例,它实现了在 Whosebug crti.o file missing.

中找到的解决方案之一

这是原文homebrew gcc formula,供参考

我已经更新了在 14.04 中测试和工作的 linuxbrew standalone installation instructions with the solution. I've also created an updated linuxbrew-standalone.sh,并在下面的 TODO 评论中列出了一些小警告。

# /bin/bash
set -e
set -u
set -x

cd $HOME

# TODO: The next ln -s line breaks cross compiling with multiarch, need an alternative!
#       source: 
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
sudo apt-get update -y
sudo apt-get update --fix-missing -y
sudo apt-get install build-essential curl g++ git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev gawk make patch tcl -y

unset LD_LIBRARY_PATH PKG_CONFIG_PATH HOMEBREW_CC
PATH=$HOME/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin
yes | ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/linuxbrew/go/install)"

# hang on here. you will have to press return
# note that even if brew doctor is a little unhappy we want to keep going
brew doctor || true

mkdir $HOME/.linuxbrew/lib
ln -s lib $HOME/.linuxbrew/lib64
ln -s $HOME/.linuxbrew/lib $HOME/.linuxbrew/lib64
ln -s /usr/lib64/libstdc++.so.6 /lib64/libgcc_s.so.1 $HOME/.linuxbrew/lib/
PATH=$HOME/.linuxbrew/lib:$PATH
export PATH
LIBRARY_PATH=$HOME/.linuxbrew/lib
export LIBRARY_PATH
LD_LIBRARY_PATH=$HOME/.linuxbrew/lib
export LD_LIBRARY_PATH

# before this, you may want to `brew edit glibc` to produce compatibility for your particular kernel, for example:
# "--enable-version=2.6.18"

#brew unlink gawk
brew install glibc
brew unlink glibc
brew install https://raw.githubusercontent.com/Homebrew/homebrew-dupes/master/zlib.rb
brew reinstall binutils
brew link glibc
brew install patchelf
brew install gcc --with-glibc --only-dependencies -v
# When tested gcc was working except for the linking step, that's why it is force-accepted with ||true
# TODO: make it so force accepting isn't necessary and errors are shown correctly
brew install gcc --with-glibc -v || true
rm -f $HOME/.linuxbrew/lib/{libstdc++.so.6,libgcc_s.so.1}
brew link gcc --overwrite
export HOMEBREW_CC=gcc

brew install bzip2 curl expat
brew install git --with-brewed-curl --with-brewed-openssl --without-tcl-tk
brew tap homebrew/dupes
brew install coreutils findutils gawk gnu-sed gnu-which grep libpng libxml2 libxslt make ncurses readline
#ln -s ncursesw/curses.h ncursesw/form.h ncursesw/ncurses.h ncursesw/term.h ncursesw/termcap.h $HOME/.linuxbrew/include/
#ln -s libncurses.a $HOME/.linuxbrew/lib/libcurses.a
#ln -s libncurses.so $HOME/.linuxbrew/lib/libcurses.so
brew install ruby
PATH=$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin
brew install hello && brew test hello; brew remove hello

修复问题的主要线路是 sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64,但它附带一个警告,我对修复感兴趣,因为它 breaks cross compiling with multiarch