Commit e9aa072
committed
ploop.go: use pkg-config
Instead of specifying CFLAGS and LDFLAGS, let's rely on pkg-config.
Unfortunately go doesn't have a way to selectively pass --static
flag to pkg-config, so if we try to build Docker statically the
resulting binary will have many undefined symbols:
# readelf -s bundles/1.7.1/binary/docker-1.7.1 | grep -w UND | grep -E 'xml|timer'
21029: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND xmlTextWriterWriteFormatE
21044: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND timer_create
.........
This clearly shows that neither libxml2 nor librt were linked in,
and the resulting binary will segfault on the first access to one
of these symbols.
To fix this, we have to pass --static to pkg-config.
For case of dynamic linking, this is also OK but leads to so-called
"overlinking" (see [1] for discussion about it). We could have used
LDFLAGS=-Wl,--as-needed to fix this, but as there is no way to
distinguish between LDFLAGS and LDLIBS (LDFLAGS should go before .o
files, and LDLIBS should go after) we can't use --as-needed.
Anyways, overlinking is probably a minor issue compared to
a sudden binary segfault. Still,
TODO: find a way to selectively pass --static to pkg-config
Note: this requires a very recent ploop (with ploop.pc added).
[1] https://wiki.mageia.org/en/Overlinking_issues_in_packaging
Signed-off-by: Kir Kolyshkin <[email protected]>1 parent 9425017 commit e9aa072
1 file changed
+1
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
0 commit comments