I'm cross-compiling a V8 project to an embedded ARM target using the GCC arm-gnueabi cross compiler. I got the V8 library itself cross-compiled successfully, and as a smoke test I wanted to link it to Google's hello world example and run it on the ARM board.
The libraries themselves clock in at a bit over 1.2 MB:
v8 % find out/arm.release/obj.target/ -name '*.a' -exec du -h {} +
1.2M out/arm.release/obj.target/tools/gyp/libv8_base.a
12K out/arm.release/obj.target/tools/gyp/libv8_libbase.a
4.0K out/arm.release/obj.target/tools/gyp/libv8_libplatform.a
4.0K out/arm.release/obj.target/tools/gyp/libv8_snapshot.a
4.0K out/arm.release/obj.target/tools/gyp/libv8_nosnapshot.a
4.0K out/arm.release/obj.target/third_party/icu/libicudata.a
164K out/arm.release/obj.target/third_party/icu/libicuuc.a
336K out/arm.release/obj.target/third_party/icu/libicui18n.
Yet when I build and link with
arm-linux-gnueabi-g++ -pthread -Iv8/include hi.cpp -Os -o hi_v8 -Wl,--start-group v8/out/arm.release/obj.target/{tools/gyp/libv8_{base,libbase,snapshot},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group
I get an executable that's 20 MB. Stripping it only gets me down to 17 MB
What is being linked in that balloons the file size so much? How can I avoid it? What tools can I use to diagnose the problem? This size may be problematic on the platform I am targeting.
I've taken a look at readelf --sections
, but it just tells me how large the .text
section is overall, which isn't particularly helpful. I also took a look at the suggestions here and tried using nm
, but it's too specific - I just a bunch of name-mangled symbols like _ZN2v88internal11FLAG_log_gcE
.