From 1cc8ee8465ce69fedf0270a0b76b3133891e53c8 Mon Sep 17 00:00:00 2001 From: Neil Spring Date: Fri, 23 Oct 2026 10:57:18 -0700 Subject: [PATCH] getdeps: Fix shared libfolly link in no-system-packages builds Summary: Fix the `oss-metaroce-linux-getdeps` continuous job, which fails when linking shared `libfolly.so` because source-built `libevent`, `zlib`, and `libaio` produce only static archives without position-independent code. Enable PIC for `zlib` and `libevent` (consistent with other manifests), and switch `libaio` to produce shared libraries so folly can link against them. Add a regression test that guards against these link inputs silently reverting. Re-enabling shared `libaio` was previously reverted (D93644345) but verified safe via a no-system-packages moxygen build. Blast radius is narrow: only `folly` and `cachelib` consume source-built libaio, and only `metaroce`/`rebalancer(-explorer)` request shared folly. Reviewed By: bigfootjon Differential Revision: D126978432 fbshipit-source-id: 56c67f890e2f99ecd3ae800f82adba71e475bcf9 --- .../getdeps/test/manifest_test.py | 31 +++++++++++++++++++ build/fbcode_builder/manifests/libaio | 4 +-- build/fbcode_builder/manifests/libevent | 1 + build/fbcode_builder/manifests/zlib | 3 ++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/build/fbcode_builder/getdeps/test/manifest_test.py b/build/fbcode_builder/getdeps/test/manifest_test.py index 9c66f3263..a2868a069 100644 --- a/build/fbcode_builder/getdeps/test/manifest_test.py +++ b/build/fbcode_builder/getdeps/test/manifest_test.py @@ -5,7 +5,9 @@ import unittest +from unittest.mock import MagicMock +from ..buildopts import BuildOptions from ..load import load_all_manifests, patch_loader from ..manifest import ManifestParser @@ -223,6 +225,35 @@ foo = bar manifests = load_all_manifests(None) self.assertNotEqual(0, len(manifests), msg="parsed some number of manifests") + def test_shared_folly_link_inputs(self) -> None: + # Shared libfolly.so links third-party static archives. Those archives + # must be position-independent, and libaio must install a shared + # library, or the no-system-packages builds fail in the folly link. + patch_loader(__name__) + # The resource loader ignores build options; a mock only satisfies + # the type signature. + manifests = load_all_manifests(MagicMock(spec=BuildOptions)) + for name in ("zlib", "libevent", "libaio"): + self.assertIn(name, manifests, msg="manifest still exists") + for name in ("zlib", "libevent"): + defines = manifests[name].get_section_as_dict("cmake.defines", {}) + self.assertEqual( + defines.get("CMAKE_POSITION_INDEPENDENT_CODE"), + "ON", + msg=name + " archives stay linkable into shared libfolly.so", + ) + libaio = manifests["libaio"] + self.assertIn( + "ENABLE_SHARED=1", + libaio.get_section_as_args("make.build_args", {}), + msg="source-built libaio provides libaio.so with version nodes", + ) + self.assertIn( + "ENABLE_SHARED=1", + libaio.get_section_as_args("make.install_args", {}), + msg="source-built libaio installs libaio.so with version nodes", + ) + def test_mismatch_name(self) -> None: with self.assertRaisesRegex( Exception, diff --git a/build/fbcode_builder/manifests/libaio b/build/fbcode_builder/manifests/libaio index 98690fbfa..acd0a48e4 100644 --- a/build/fbcode_builder/manifests/libaio +++ b/build/fbcode_builder/manifests/libaio @@ -17,8 +17,8 @@ builder = make subdir = libaio-0.3.113 [make.build_args] -ENABLE_SHARED=0 +ENABLE_SHARED=1 [make.install_args] install -ENABLE_SHARED=0 +ENABLE_SHARED=1 diff --git a/build/fbcode_builder/manifests/libevent b/build/fbcode_builder/manifests/libevent index b0bc66ec1..9c77f7efe 100644 --- a/build/fbcode_builder/manifests/libevent +++ b/build/fbcode_builder/manifests/libevent @@ -30,6 +30,7 @@ EVENT__DISABLE_BENCHMARK = ON EVENT__DISABLE_SAMPLES = ON EVENT__DISABLE_REGRESS = ON EVENT__LIBRARY_TYPE = STATIC +CMAKE_POSITION_INDEPENDENT_CODE = ON [dependencies.not(any(os=linux, os=freebsd))] openssl diff --git a/build/fbcode_builder/manifests/zlib b/build/fbcode_builder/manifests/zlib index ae77a3bad..dfb0e41a7 100644 --- a/build/fbcode_builder/manifests/zlib +++ b/build/fbcode_builder/manifests/zlib @@ -27,3 +27,6 @@ sha256 = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 builder = cmake subdir = zlib-1.3.1 patchfile = zlib_dont_build_more_than_needed.patch + +[cmake.defines] +CMAKE_POSITION_INDEPENDENT_CODE = ON