【问题标题】:gentoo ld.gold failed on sys-libs/dbgentoo ld.gold 在 sys-libs/db 上失败
【发布时间】:2015-04-15 17:00:54
【问题描述】:

我最近从默认的 binutils 链接器 ld.bfd 切换到 ld.gold(以使链接时间优化工作,为什么不呢?)。它是手动制作的(比如这里:http://wiki.gentoo.org/wiki/Gold)。结果我得到了从 /usr/bin/ld 到 ld.gold 二进制文件的符号链接链,因此链接器在构建过程中被透明地更改了。

但是当我尝试重建所有包时,我发现 ld.gold 有时会导致配置/编译失败,例如“C 编译器无法创建可执行文件”:

checking for x86_64-pc-linux-gnu-gcc... x86_64-pc-linux-gnu-gcc                                    
checking whether the C compiler works... no                                                      
configure: error: in `/var/tmp/portage/sys-libs/db-6.0.30-r1/work/db-6.0.30/build_unix-abi_x86_64.amd64':
configure: error: C compiler cannot create executables                                           

实际上是链接器问题:

configure: checking whether the C compiler works                                                   
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/../../../../x86_64-pc-linux-gnu/bin/ld: --default-symver: unknown option
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/../../../../x86_64-pc-linux-gnu/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status

但是使用默认的 bfd 链接器可以成功构建包,所以问题是如何回到 bfd 链接器来处理无法使用 ld.gold 构建的包?

问题包是 =sys-libs/db-6.0.30-r1(现在引起我注意的那个)。

【问题讨论】:

    标签: c linker ld gentoo gold-linker


    【解决方案1】:

    我想到的解决方案是通过 package.env 使用每个包的环境修改。在问题包中使用了libtool,它调用gcc作为链接器,所以需要添加的是-Wl,-fuse-ld=bfd(在链接阶段,LDFLAGS)。

    所以,完整的解决方案是:

    mkdir -p /etc/portage/env                                                                          
    echo 'LDFLAGS="${LDFLAGS} -Wl,-fuse-ld=bfd"' >> /etc/portage/env/force-bfd.conf                    
    echo 'sys-libs/db force-bfd.conf' >> /etc/portage/package.env                                  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-11
      • 1970-01-01
      • 2015-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多