在没有根的非标准位置构建具有glibc的GCC [英] Building GCC with glibc in a non-standard location without root

查看:89
本文介绍了在没有根的非标准位置构建具有glibc的GCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个系统,我没有root权限,但我需要安装当前版本的GCC(4.7.2)。



系统正在运行Linux 2.6.18的x86_64版本,并且已经有了GCC 4.1(即使--version说它是用它编译的,也没有C ++支持)。编辑5:在这一点上,下面的步骤只是我试过的一套。从那时起我已经开始几次清洁。我正在寻找一个人来详细说明我需要的所有开关的确切顺序。



这是我到目前为止所经历的过程(其中ROOT是我家目录中的一个文件夹)

  make-3.82> ./ configure --prefix = $ ROOT& amp ;&安培;制作&&安装&& hash -r 
binutils-2.23> ./ configure --prefix = $ ROOT&&制作&& make install
autoconf-2.69> ./ configure --prefix = $ ROOT&&制作&& make install
automake-1.9> ./ configure --prefix = $ ROOT&&制作&& make install
flex-2.5.37> ./ configure --prefix = $ ROOT&&制作&& make install
libunwind-1.1> ./ configure --prefix = $ ROOT&&制作&& make install
gcc-4.7.2-scratch> ../ gcc-4.7.2 / configure --prefix = $ ROOT \
--disable-multilib --disable -nls --enable- languages = c,c ++ \
&&制作&&安装&& hash -r
ncurses-5.9> ./ configure --prefix = $ ROOT&&制作&& make install
texinfo-4.13> ./ configure --prefix = $ ROOT&&制作&& make install
glibc-2.14-scratch> touch $ ROOT /etc/ld.so.conf

修补glibc,带有 http://sourceforge.net/apps/trac/unattended/wiki/ModifyingTheBootDisk #PatchGLibc (更正行数为2.14)

  glibc-2.14-scratch> ../ glibc-2.14 / configure --prefix = $ ROOT \ 
--with-headers = $ 3_3_4_HEADERS&&制作&& make install

我添加的标志是摆脱对undefined的引用, __isoc99_sscanf'。我不知道实际需要哪些标志组合来解决这个问题,但是它解决了这些标志的问题。

  gcc -4.7.2-scratch2> ../ gcc-4.7.2 / configure --prefix = $ ROOT \ 
--disable-multilib --disable-nls --enable-languages = c,c ++ \
CPPFLAGS = - I $ ROOT / includeCFLAGS = - g -O2 -lc\
CXXFLAGS = - g -O2 -lcLDFLAGS = - L $ ROOT / lib \\ \\
-L ​​$ ROOT / lib64&&制作&& make install

现在我在GCC构建过程中遇到这个错误:

  build / genmddeps ../../gcc-4.7.2/gcc/config/i386/i386.md> tmp-mddeps 
uild / genmddeps:/lib64/libc.so.6:找不到版本'GLIBC_2.14'(build / genmddeps需要)

错误是有道理的,因为/ lib64中的libc是版本2.5,但我不知道如何让GCC使用我建立的安装到$ ROOT的那个/ lib。



编辑1:添加-rpath没有帮助,但我将我的lib目录添加到LD_RUN_PATH和LD_LIBRARY_PATH。有了这些设置,我无法运行任何东西,因为在加载共享库时出现错误 [program_name]:error:/home/mrambiguous/root/lib/libc.so.6:ELF文件OS ABI无效



另一个需要注意的问题是,当我尝试使用-rpath建议时,我开始从GCC获取关于无法识别的命令行选项的错误如-V)。我必须将其设置为使用系统的GCC 4.1。现在我不确定我的第一个GCC版本是否会被破坏,或者它是否曾经被使用过。



编辑2:我刚刚打开了libc。 so.6在vim中查看我是否能够以纯文本的方式找到关于ABI的任何内容,并且它与版权信息一起存在。 libc ABIs:UNIQUE IFUNC



它也证实了GCC 4.7.2在同一块文本中工作。 编译GNU CC版本4.7.2



编辑3:删除了$ ROOT,重新安装了所有内容,识别-V和-qversion作为有效的选项。编辑4:我尝试使用 brandelf -t SVR4 libc.so编辑ELF标题。 6 ,但这只是给我一个新的错误意外的PLT reloc type 0x25

解决方案

我很着急,所以我无法详细分析您的错误消息。



新的glibc和旧的glibc不仅仅是ABI不兼容,但也包含标题,请参阅 gcc bug 52922



因此,任何混音都会导致出现像您遇到的错误,您需要非常小心。

手调整是无望而乏味的。



如果您的目标是使用gcc-4.7.2,我建议您 Gentoo Prefix 。我有很多RHEL 5上运行的Gentoo Prefix实例(2.6.18内核,gcc-4.1和glibc-2.5)。这个编译gcc-4.7.2在glibc-2.5之上。



如果你想使用更新的glibc一些乐趣,看看前缀/ libc 。这是一项正在进行中的工作。预计会有很多破损。但是,当你试图手工编译出一个现代化的工具链时,它不会是一个大的缩影,是吧?


I have a system that I do not have root access to, but I need to install the current version of GCC (4.7.2) on.

The system is running an x86_64 build of Linux 2.6.18 and already has GCC 4.1 (without C++ support even though --version says it was built with it).

EDIT 5: At this point, the steps below are just one set of things that I've tried. I've started clean a few times since then. I'm looking for someone to detail the exact order I need to make everything in with all of the switches required.

This is the process I've gone through so far (where ROOT is a folder in my home directory)

    make-3.82>./configure --prefix=$ROOT && make && make install && hash -r
binutils-2.23>./configure --prefix=$ROOT && make && make install
autoconf-2.69>./configure --prefix=$ROOT && make && make install
automake-1.9>./configure --prefix=$ROOT && make && make install
flex-2.5.37>./configure --prefix=$ROOT && make && make install
libunwind-1.1>./configure --prefix=$ROOT && make && make install
gcc-4.7.2-scratch>../gcc-4.7.2/configure --prefix=$ROOT \
    --disable-multilib --disable-nls --enable-languages=c,c++ \
    && make && make install && hash -r
ncurses-5.9>./configure --prefix=$ROOT && make && make install
texinfo-4.13>./configure --prefix=$ROOT && make && make install
glibc-2.14-scratch>touch $ROOT/etc/ld.so.conf

Patched glibc with patch from http://sourceforge.net/apps/trac/unattended/wiki/ModifyingTheBootDisk#PatchGLibc (correcting line numbers for 2.14)

glibc-2.14-scratch>../glibc-2.14/configure --prefix=$ROOT \
    --with-headers=$3_3_4_HEADERS && make && make install

The flags I added were to get rid of undefined reference to '__isoc99_sscanf'. I don't know what combination of flags was actually necessary to fix that, but it fixed the problem with these flags.

gcc-4.7.2-scratch2>../gcc-4.7.2/configure --prefix=$ROOT \ 
    --disable-multilib --disable-nls --enable-languages=c,c++ \
    CPPFLAGS="-I$ROOT/include" CFLAGS="-g -O2 -lc" \
    CXXFLAGS="-g -O2 -lc" LDFLAGS="-L$ROOT/lib \
    -L$ROOT/lib64" && make && make install

Now I get this error during the GCC build:

build/genmddeps ../../gcc-4.7.2/gcc/config/i386/i386.md > tmp-mddeps
build/genmddeps: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by build/genmddeps)

The error makes sense because the libc in /lib64 is version 2.5, but I don't know how to get GCC to use the one that I built that installed to $ROOT/lib.

EDIT 1: Adding -rpath didn't help, but I added my lib directories to LD_RUN_PATH and LD_LIBRARY_PATH. With these set I couldn't run anything because I was getting the error [program_name]: error while loading shared libraries: /home/mrambiguous/root/lib/libc.so.6: ELF file OS ABI invalid

Another strange thing to note is that when I tried the -rpath suggestion, I started getting errors from GCC about unrecognized command line options (such as -V). I had to set it to use the system's GCC 4.1. Now I'm not sure if my first build of GCC became corrupted somehow or if it was ever being used in the first place.

EDIT 2: I just opened libc.so.6 in vim to see if I could find anything about the ABI in plain text and it is in there with the copyright info. libc ABIs: UNIQUE IFUNC

It also confirms that GCC 4.7.2 was working in that same block of text. Compiled by GNU CC version 4.7.2

EDIT 3: Removed $ROOT, reinstalled everything, same issue of not recognizing -V and -qversion as valid options.

EDIT 4: I tried editing the ELF header by using brandelf -t SVR4 libc.so.6, but that just gives me a new error unexpected PLT reloc type 0x25

解决方案

I am in a hurry so I can't analyze your error messages in detail.

Newer glibc and old glibc are not only ABI incompatible, but also headers, see gcc bug 52922.

Therefore any mixing will result in errors like you encountered, you need to be extremely careful.

Hand tuning is hopelessly tedious.

If your goal is to use gcc-4.7.2, I recommend you to Gentoo Prefix. I have many instances of Gentoo Prefix running on RHEL 5 (which have 2.6.18 kernel, gcc-4.1 and glibc-2.5 as you do). This compiles gcc-4.7.2 on top of glibc-2.5.

If your want some fun of using newer glibc, take a look at Prefix/libc. It is a work-in-progress though. Expect many breakage. But it won't be a big draw back as you are trying to compile out a modern toolchain by hand, will it?

这篇关于在没有根的非标准位置构建具有glibc的GCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆