keroserene / go-webrtc

WebRTC for Go
Other
455 stars 76 forks source link

Can we use obj/libwebrtc.a instead of linking our own libwebrtc-magic.a? #99

Closed uumaro closed 4 years ago

uumaro commented 5 years ago

Time was, the webrtc build did not output a library (.a), just a bunch of objects (.o). But nowadays, ninja -C out/Release results in

[2189/2189] LIBTOOL-STATIC obj/libwebrtc.a

Can we use this one rather than doing our own "$AR" crs libwebrtc-magic.a $(find out/Release/obj -name '*.o' | sort)?

uumaro commented 5 years ago

I did some test builds just to see how the size of the ninja-built libwebrtc.a compare. In each case the ninja-built one is smaller--though I haven't checked whether it has the same functionality.

our magic .a libwebrtc.a os-arch
43,985,116 31,035,940 linux-amd64
28,666,216 27,094,462 linux-arm
101,549,584 80,000,128 android-arm
uumaro commented 5 years ago

I tried this in the Tor Browser build. It failed while building go-webrtc because of a missing FakeAudioCaptureModule. So it looks like we cannot use this library while go-webrtc still depends on symbols that it does not include.

/var/tmp/dist/gcc/bin /var/tmp/dist/gopath/src/github.com/keroserene/go-webrtc
/var/tmp/dist/gopath/src/github.com/keroserene/go-webrtc
# github.com/keroserene/go-webrtc
/tmp/go-build088218511/b001/_x008.o:peerconnection.cc:function Peer::Initialize(): error: undefined reference to 'FakeAudioCaptureModule::Create()'
collect2: error: ld returned 1 exit status
--- a/projects/webrtc/build
+++ b/projects/webrtc/build
@@ -132,23 +132,11 @@ GN_ARGS+=" use_custom_libcxx=false"
 rm -rf out/Release
 "$GN" gen out/Release --args="$GN_ARGS"
 ninja -C out/Release webrtc field_trial metrics_default pc_test_utils
-# The cctools ar doesn't have the 'D' deterministic option of GNU ar, but the
-# ZERO_AR_DATE environment variable similarly sets timestamps within the
-# archive to zero.
-# https://opensource.apple.com/source/cctools/cctools-886/ar/archive.c.auto.html
-# https://codereview.chromium.org/699083004/
-# .o files under out/Release/obj/ are the build outputs. Don't include .o
-# files from elsewhere under out/ because they are build helpers and things
-# like that, not necessarily of the target architecture, and anyway are not
-# needed.
-# https://bugs.torproject.org/22832
-find out/Release/obj -name '*.o' -print0 | sort -z \
-       | [% IF c("var/osx") %]ZERO_AR_DATE=1 [% END %] xargs -0 -- "$AR" crs libwebrtc-magic.a

 mkdir -p $distdir
 cd $distdir
 mkdir -p include lib
-cp -f $builddir/libwebrtc-magic.a [% c("var/webrtc/lib_path") %]
+cp -f "$builddir/out/Release/obj/libwebrtc.a" [% c("var/webrtc/lib_path") %]
 INCLUDE_DIR="$PWD/include"
 cd $builddir
 find . -type f -name '*.h' -print0 | while IFS= read -r -d '' h;