{"push_id":750655639,"size":2,"distinct_size":2,"ref":"refs/heads/ploop","head":"a7a8d9901647a0927e2d3a607c37d8f657f7f999","before":"dd590fdf6b1c993becef572910a34a775caf8e98","commits":[{"sha":"931185f8f5b0443723f12a6c9660fa6eab466cb0","author":{"email":"c0159612b0ef32139322233232df1a0d189c4b9b@openvz.org","name":"Kir Kolyshkin"},"message":"make binary: do not ignore unresolved symbols\n\nTL;DR: stop building static binary that may fail\n\nLinker flag --unresolved-symbols=ignore-in-shared-libs was added\nin commit 06d0843 two years ago for the static build case, presumably\nto avoid dealing with problem of missing libraries.\n\nFor the record, this is what ld(1) man page says:\n\n> --unresolved-symbols=method\n>    Determine how to handle unresolved symbols.  There are four\n>    possible values for method:\n> .........\n>    ignore-in-shared-libs\n>        Report unresolved symbols that come from regular object files,\n>        but ignore them if they come from shared libraries.  This can\n>        be useful when creating a dynamic binary and it is known that\n>        all the shared libraries that it should be referencing are\n>        included on the linker's command line.\n\nHere, the flag is not used for its purpose (\"creating a dynamic binary\")\nand does more harm than good. Instead of complaining about missing symbols\nas it should do if some libraries are missing from LIBS/LDFLAGS, it lets\nld create a binary with unresolved symbols, ike this:\n\n $ readelf -s bundles/1.7.1/binary/docker-1.7.1 | grep -w UND\n ........\n 21029: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND dlopen\n .........\n\nSuch binary is working just fine -- until code calls one of those\nfunctions, then it crashes (for apparently no reason, i.e. it is\nimpossible to tell why from the diagnistics printed).\n\nIn other words, adding this flag allows to build a static binary\nwith missing libraries, hiding the problem from both a developer\n(who forgot to add a library to #cgo: LDFLAGS -- I was one such\ndeveloper a few days ago when I was working on ploop graphdriver)\nand from a user (who expects the binary to work without crashing,\nand it does that until the code calls a function in one of those\nlibraries).\n\nRemoving the flag immediately unveils the problem (as it should):\n\n\t/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libsqlite3.a(sqlite3.o):\n\tIn function `unixDlError':\n\t(.text+0x20971): undefined reference to `dlerror'\n\t/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libsqlite3.a(sqlite3.o):\n\tIn function `unixDlClose':\n\t(.text+0x8814): undefined reference to `dlclose'\n\nThe problem is, gosqlite package says:\n\n\t#cgo LDFLAGS: -lsqlite3\n\nwhich is enough for dynamic linking, as indirect dependencies (i.e.\nlibraries required by libsqlite3.so) are listed in .so file and will be\nresolved dynamically by ldd upon executing the binary.\n\nFor static linking though, one has to list all the required libraries,\nboth direct and indirect. For libraries with pkgconfig support the\nlist of required libraries can be obtained with pkg-config:\n\n\t$ pkg-config --libs sqlite3 # dynamic linking case\n\t-lsqlite3\n\t$ pkg-config --libs --static sqlite3 # static case\n\t-lsqlite3 -ldl -lpthread\n\nIt seems that all one has to do is to fix gosqlite this way:\n\n\t-#cgo LDFLAGS: -lsqlite3\n\t+#cgo pkg-config: sqlite3\n\nUnfortunately, cmd/go doesn't know that it needs to pass --static\nflag to pkg-config in case of static linking\n(see https://github.com/golang/go/issues/12058).\n\nSo, for one, one has to do one of these things:\n\n1. Patch sqlite.go like this:\n\n\t-#cgo LDFLAGS: -lsqlite3\n\t+#cgo pkg-config: --static sqlite3\n\n(this is exactly what I do in goploop, see\nhttps://github.com/kolyshkin/goploop/commit/e9aa072f51)\n\n2. Patch sqlite.go like this:\n\t-#cgo LDFLAGS: -lsqlite3\n\t+#cgo LDFLAGS: -lsqlite3 -ldl -lpthread\n\n(I would submit this patch to gosqlite but it seems that\nhttps://code.google.com/p/gosqlite/ is deserted and not maintained,\nand patching it here is not right as it is \"vendored\")\n\n3. Explicitly add -ldl for the static link case.\nThis is what this patch does.\n\n4. Fork sqlite to github and maintain it there. Personally I am not\nready for that, as I'm neither a Go expert nor gosqlite user.\n\nNow, #3 doesn't look like a clear solution, but nevertheless it makes\nthe build much better than it was before.\n\nSigned-off-by: Kir Kolyshkin <kir@openvz.org>","distinct":true,"url":"https://api.github.com/repos/kolyshkin/docker/commits/931185f8f5b0443723f12a6c9660fa6eab466cb0"},{"sha":"a7a8d9901647a0927e2d3a607c37d8f657f7f999","author":{"email":"c0159612b0ef32139322233232df1a0d189c4b9b@openvz.org","name":"Kir Kolyshkin"},"message":"ploop: implement get/put refcounting\n\nSimilar to the way it is implemented in aufs.\nThis allows us to make the subsequent Get() faster,\nalso Put() now only unmounts if refcounting is down\nto zero.\n\nSigned-off-by: Kir Kolyshkin <kir@openvz.org>","distinct":true,"url":"https://api.github.com/repos/kolyshkin/docker/commits/a7a8d9901647a0927e2d3a607c37d8f657f7f999"}]}