Bazel should create static binaries
OpenPublic

Assigned To
zarko
Priority
Normal
Author
schroederc
Blocked By
Restricted Maniphest Task
Differential Revisions
Restricted Differential Revision
Subscribers
schroederc, juanch, fromberger, Core Team
Projects
None
Description

Most of our Go binaries currently rely on the system's leveldb and snappy shared libraries. We should link in //third_party/leveldb and //third_party/snappy, respectively.

Some of our C++ binaries are also dynamically linked.

schroederc created this task.Via WebMay 11 2015, 12:30 PM
schroederc claimed this task.
schroederc lowered the priority of this task from "High" to "Low".Via WebMay 11 2015, 1:51 PM
schroederc added a comment.Via WebMay 14 2015, 11:45 AM

Our C++ extractor also is dynamically linked.

$ ldd cxx_extractor
        linux-vdso.so.1 =>  (0x00007ffdc86ba000)
        libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007ff048375000)
        libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007ff047f9a000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff047d95000)
        libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007ff047b72000)
        libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007ff047949000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff047642000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff047424000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff047120000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff046f09000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff046b44000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ff04859e000)
schroederc edited the task description. (Show Details)Via WebMay 14 2015, 11:45 AM
schroederc added a subscriber: zarko.
schroederc added a blocking task: Restricted Maniphest Task.Via WebMay 19 2015, 3:04 PM
schroederc added a comment.Via WebMay 21 2015, 11:51 AM

See http://tschottdorf.github.io/linking-golang-go-statically-cgo-testing/ for more content on statically linking Go. It's more of a pain than may be worth it.

schroederc removed a blocked task: Restricted Maniphest Task.Via WebMay 27 2015, 1:58 PM
schroederc added a revision: Restricted Differential Revision.Via WebJun 15 2015, 10:28 AM
schroederc closed blocking task Restricted Maniphest Task as "Resolved".Via WebJun 15 2015, 10:37 AM
schroederc changed the visibility of this Maniphest Task from "All Users" to "Public (No Login Required)".Via WebMay 16 2016, 3:30 PM
schroederc placed this task up for grabs.Via WebJun 13 2016, 12:23 PM
schroederc lowered the priority of this task from "Low" to "Wishlist".
schroederc removed a subscriber: zarko.
schroederc merged a task: Restricted Maniphest Task.
juanch added a comment.EditedVia WebMay 31 2017, 4:14 PM

Any chance to bump the priority of this task higher? It's in the critical path of running Kythe on our side. For the near term, we need C++ and Java. Go can be ready later.

fromberger raised the priority of this task from "Wishlist" to "Normal".Via WebMay 31 2017, 4:19 PM

I don't know how we'll actually do this—does Bazel already support static linking, or is this going to be some kind of manual process?

fromberger added a comment.Via WebMay 31 2017, 4:21 PM

Re: Java. Is static linking even a thing for Java? I suppose you could do a shell-archive trick, but doesn't the JVM always load its extensions dynamically?

zarko claimed this task.Via WebMay 31 2017, 4:24 PM

I'm not sure what it means to statically-link Java, but I can look into C++.

juanch added a comment.Via WebMay 31 2017, 4:46 PM

Bazel c++ rules have options for static linking (https://bazel.build/versions/master/docs/be/c-cpp.html). Hope that is enough.

The work I can think of for Java may be to include all the jars Kythe needs in the release.

zarko added a comment.Via WebMay 31 2017, 5:26 PM

As we've discovered, the indexer/extractor will build with linkopts=["-static"], but the resulting binaries die during initialization:

#0  0x00000000013aa1fb in raise ()
#1  0x0000000001410958 in abort ()
#2  0x000000000140501d in uw_init_context_1 ()
#3  0x0000000001405bc8 in _Unwind_Backtrace ()
#4  0x0000000001336c0f in google::StackTraceInit::StackTraceInit() ()
#5  0x00000000004069b0 in __cxx_global_var_init17 ()
#6  0x00000000004069ec in _GLOBAL__sub_I_utilities.cc ()
#7  0x0000000001408367 in __libc_csu_init ()
#8  0x0000000001407df9 in __libc_start_main ()
#9  0x0000000000407d67 in _start ()

Add Comment