4

我在 Arch Linux x86_64 上,尝试构建 WebRTC 库。执行此操作时出现编译错误:

[ghilliard@diadem trunk]$ ninja -C out/Release peerconnection_server
ninja: Entering directory `out/Release'
[1/1] LINK peerconnection_server
FAILED: c++ -Wl,-z,now -Wl,-z,relro -Wl,--fatal-warnings -pthread -Wl,-z,noexecstack -fPIC -B/home/ghilliard/Code/webrtc-attempt2/trunk/third_party/binutils/Linux_x64/Release/bin -Wl,--disable-new-dtags -m64 -Wl,--icf=none -fuse-ld=gold -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -o peerconnection_server -Wl,--start-group obj/talk/examples/peerconnection/server/peerconnection_server.data_socket.o obj/talk/examples/peerconnection/server/peerconnection_server.main.o obj/talk/examples/peerconnection/server/peerconnection_server.peer_channel.o obj/talk/examples/peerconnection/server/peerconnection_server.utils.o obj/talk/libjingle.a obj/net/third_party/nss/libcrssl.a obj/third_party/jsoncpp/libjsoncpp.a  -Wl,--end-group -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 -ldl -lcrypto -lrt -lXext -lX11 -lXcomposite -lXrender -lexpat
/home/ghilliard/Code/webrtc-attempt2/trunk/third_party/binutils/Linux_x64/Release/bin/ld.gold: -plugin: unknown option
/home/ghilliard/Code/webrtc-attempt2/trunk/third_party/binutils/Linux_x64/Release/bin/ld.gold: use the --help option for usage information
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

链接时间优化似乎存在问题。但是,我无法弄清楚如何在不启用 LTO 的情况下构建 WebRTC。如果我手动运行失败的命令并 append -fno-lto,则链接正常。如何在gyp配置中添加或更改编译器/链接器标志,以便将其应用于所有内容?

4

2 回答 2

2

ninja 不尊重环境变量,但 gyp 尊重。

所以在设置好LDFAGS环境变量之后,你必须运行gyp_chromium让gyp生成正确的ninja build文件。

export LDFLAGS='-fno-lto' build/gyp_chromium ninja -C out/Release peerconnection_server

于 2014-05-21T06:58:50.940 回答
0

您可能会尝试在构建之前在环境变量中设置编译器/链接器标志:

export CFLAGS="${CFLAGS} -fno-lto"
export CXXFLAGS="${CXXFLAGS} -fno-lto"
export LDFLAGS="${LDFLAGS} -fno-lto"
ninja -C out/Release
于 2014-05-16T13:59:50.080 回答