Skip to content

Commit 18b0b2d

Browse files
r-barnesmeta-codesync[bot]
authored andcommitted
boost manifest: build from source on Linux with -fPIC
Summary: Drop the [debs] satisfier (libboost-all-dev) and add cxxflags/cflags=-fPIC under [b2.args.os=linux] so that boost's static archives are PIC and can be linked into downstream shared libraries (specifically rebalancer's librebalancer.so). The Ubuntu libboost-all-dev package ships static archives built without -fPIC, which fails at link time with R_X86_64_PC32 / 'recompile with -fPIC' errors when the consumer is a shared library. Building boost ourselves with cflags=-fPIC fixes this. Boost's b2 build does not pick PIC up from CMAKE_POSITION_INDEPENDENT_CODE because it is not CMake-driven. Note: this changes behavior for every consumer of fbcode_builder that runs with --allow-system-packages on Debian/Ubuntu — they will now build boost from source instead of installing libboost-all-dev. Build time for boost is ~5-10 min on a 16-core runner. If this is unacceptable for any consumer, the right follow-up is a per-consumer way to keep the system satisfier (e.g. opt-in [debs] block keyed off a context flag). Reviewed By: bigfootjon Differential Revision: D103767938 fbshipit-source-id: 06275b77b8635f1a5742e1289e0ecc6e762e70c7
1 parent 7808582 commit 18b0b2d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

  • build/fbcode_builder/manifests

build/fbcode_builder/manifests/boost

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ sha256 = c86bd9d9eef795b4b0d3802279419fde5221922805b073b9bd822edecb1ca28e
1414
BOOST_ROOT_1_69_0
1515
BOOST_ROOT_1_83_0
1616

17-
[debs]
18-
libboost-all-dev
17+
# Build boost from source rather than satisfying it from libboost-all-dev.
18+
# The Ubuntu boost packages ship static archives without -fPIC, which
19+
# fails to link into our shared rebalancer library.
1920

2021
[homebrew]
2122
boost
@@ -106,6 +107,12 @@ patchfile = boost_1_83_0.patch
106107
# RHEL hardened gcc is not compatible with PCH
107108
# https://bugzilla.redhat.com/show_bug.cgi?id=1806545
108109
pch=off
110+
# Build with -fPIC so the static archives we install can be linked into
111+
# downstream shared libraries (e.g. rebalancer's librebalancer.so).
112+
# Boost's b2 build does not pick this up from CMAKE_POSITION_INDEPENDENT_CODE
113+
# because it is not driven by CMake.
114+
cxxflags=-fPIC
115+
cflags=-fPIC
109116

110117
[b2.args.os=darwin]
111118
toolset=clang

0 commit comments

Comments
 (0)