From 9a2a5a407876a0b358cf1e6299b30ef24cb4c328 Mon Sep 17 00:00:00 2001 From: David Greenberg Date: Mon, 14 Mar 2022 09:19:39 -0700 Subject: [PATCH] Add argument to pass extra arguments to boost b2 build tool (#28) Summary: X-link: https://github.com/facebook/fb303/pull/28 X-link: https://github.com/facebook/fboss/pull/115 X-link: https://github.com/facebook/folly/pull/1736 X-link: https://github.com/facebook/proxygen/pull/403 X-link: https://github.com/facebook/fbthrift/pull/488 This adds a way to pass arguments to the `b2` build tool, used by Boost. This is needed in order to link a getdeps built boost into an relocatable `.so`. The motivating use case is that we need to statically link Boost into a native library used by a python wheel, which must be relocatable. This functionality already exists for CMake-based projects. Reviewed By: mackorone Differential Revision: D34796774 fbshipit-source-id: 0d6a9f4703865dc02048b87e77394c44ef646af6 --- build/fbcode_builder/getdeps.py | 12 ++++++++++++ build/fbcode_builder/getdeps/manifest.py | 3 +++ 2 files changed, 15 insertions(+) diff --git a/build/fbcode_builder/getdeps.py b/build/fbcode_builder/getdeps.py index a4ae0cbfbb7..58387232e94 100755 --- a/build/fbcode_builder/getdeps.py +++ b/build/fbcode_builder/getdeps.py @@ -595,6 +595,8 @@ def run_project_cmd(self, args, loader, manifest): else {} ) + extra_b2_args = args.extra_b2_args or [] + if sources_changed or reconfigure or not os.path.exists(built_marker): if os.path.exists(built_marker): os.unlink(built_marker) @@ -620,6 +622,7 @@ def run_project_cmd(self, args, loader, manifest): loader, final_install_prefix=loader.get_project_install_prefix(m), extra_cmake_defines=extra_cmake_defines, + extra_b2_args=extra_b2_args, ) builder.build(install_dirs, reconfigure=reconfigure) @@ -760,6 +763,15 @@ def setup_project_cmd_parser(self, parser): 'e.g: \'{"CMAKE_CXX_FLAGS": "--bla"}\'' ), ) + parser.add_argument( + "--extra-b2-args", + help=( + "Repeatable argument that contains extra arguments to pass " + "to b2, which compiles boost. " + "e.g.: 'cxxflags=-fPIC' 'cflags=-fPIC'" + ), + action="append", + ) parser.add_argument( "--shared-libs", help="Build shared libraries if possible", diff --git a/build/fbcode_builder/getdeps/manifest.py b/build/fbcode_builder/getdeps/manifest.py index 705c2af4c7f..b9e29fa4ec2 100644 --- a/build/fbcode_builder/getdeps/manifest.py +++ b/build/fbcode_builder/getdeps/manifest.py @@ -466,6 +466,7 @@ def create_builder( # noqa:C901 loader, final_install_prefix=None, extra_cmake_defines=None, + extra_b2_args=None, ): builder = self.get_builder_name(ctx) build_in_src_dir = self.get("build", "build_in_src_dir", "false", ctx=ctx) @@ -527,6 +528,8 @@ def create_builder( # noqa:C901 if builder == "boost": args = self.get_section_as_args("b2.args", ctx) + if extra_b2_args is not None: + args += extra_b2_args return Boost(build_options, ctx, self, src_dir, build_dir, inst_dir, args) if builder == "bistro":