Skip to content

Commit

Permalink
Update and fix bundled boost build (#9574)
Browse files Browse the repository at this point in the history
Summary:
Since Boost is a C++ library dependency, we should force building its bundled version when building against libc++.

Take this opportunity to update to a more recent Boost version, and use B2 options[1] to set the C++ version and toolchain from the superproject. Remove an outdated macOS patch that no longer applies.

Add the chrono and date_time components to the list of components to build as they're needed by mvfst.

Split from #9564.

[1] https://www.boost.org/doc/libs/1_87_0/tools/build/doc/html/index.html

Pull Request resolved: #9574

Reviewed By: Wilfred

Differential Revision: D67959735

fbshipit-source-id: 35c538f3c5b979a906f26bbe693d23d086a45419
  • Loading branch information
mszabo-wikia authored and facebook-github-bot committed Jan 9, 2025
1 parent 22baa54 commit 75c1143
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 39 deletions.
4 changes: 3 additions & 1 deletion third-party/boost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
option(FORCE_BUNDLED_BOOST "Always build boost, instead of using system version" OFF)
set(
BOOST_COMPONENTS
chrono
context
date_time
fiber
filesystem
iostreams
Expand All @@ -11,7 +13,7 @@ set(
system
thread
)
if(FORCE_BUNDLED_BOOST)
if(FORCE_BUNDLED_BOOST OR CLANG_FORCE_LIBCPP)
set(Boost_FOUND false)
else()
find_package(Boost 1.69.0 COMPONENTS ${BOOST_COMPONENTS})
Expand Down

This file was deleted.

18 changes: 11 additions & 7 deletions third-party/boost/bundled_boost.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
include(ExternalProject)
include(ExternalProject)
include(HPHPFunctions)
# We usually use SHA512, but given the SHA256 is on the boost.org download
# page, use that for transparency/ease of confirmation.
SET_HHVM_THIRD_PARTY_SOURCE_ARGS(
BOOST_DOWNLOAD_ARGS
SOURCE_URL
"https://boostorg.jfrog.io/artifactory/main/release/1.73.0/source/boost_1_73_0.tar.bz2"
"https://archives.boost.io/release/1.83.0/source/boost_1_83_0.tar.gz"
SOURCE_HASH
"SHA256=4eb3b8d442b426dc35346235c8733b5ae35ba431690e38c6a8263dce9fcbb402"
"SHA256=c0685b68dd44cc46574cce86c4e17c0f611b15e195be9848dfd0769a0a207628"
)
set(
COMMON_ARGS
--prefix=<INSTALL_DIR>
--libdir=<INSTALL_DIR>/lib
)

set(
B2_ARGS
${COMMON_ARGS}
Expand All @@ -22,9 +23,13 @@ set(
variant=release
threading=multi
runtime-link=static
cxxflags=-std=gnu++14
cxxstd=${CMAKE_CXX_STANDARD}
)

if (CLANG_FORCE_LIBCPP)
list(APPEND B2_ARGS toolset=clang stdlib=libc++)
endif()

string(REPLACE ";" "," BOOST_COMPONENTS_CSV "${BOOST_COMPONENTS}")
# We pass --with-libraires to bootstrap.sh, but that does not consistently
# affect b2
Expand All @@ -36,12 +41,11 @@ if (APPLE)
set(BOOST_CXX_FLAGS "-isysroot${CMAKE_OSX_SYSROOT}")
endif()

ExternalProject_Add(
ExternalProject_Add(
bundled_boost
${BOOST_DOWNLOAD_ARGS}
PATCH_COMMAND
cd tools/build && patch -p1 < "${CMAKE_CURRENT_SOURCE_DIR}/b3a59d265929a213f02a451bb6-macos-coalesce-template.patch"
CONFIGURE_COMMAND
${CMAKE_COMMAND} -E env
CXX=${CMAKE_CXX_COMPILER}
CXXFLAGS=${BOOST_CXX_FLAGS}
NO_CXX11_CHECK=true # we have c++17 (at least), and the check ignores CXXFLAGS, including `-isysroot` on macos
Expand Down

0 comments on commit 75c1143

Please sign in to comment.