From eb4e910b75f05cd3040b6cf10114192de7a9dc37 Mon Sep 17 00:00:00 2001 From: Yuri Goldfeld Date: Fri, 15 Dec 2023 15:28:44 -0800 Subject: [PATCH] Per preceding TODO -- parameterizing Conan profile to optionally forego LTO. This may not be the most elegant way in terms of Python, but the essence is fine. --- .github/workflows/main.yml | 26 +++++++++++++------------- conanfile.py | 26 ++++++++++++++++---------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b5aa792cb..093e3f6ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,7 +51,7 @@ jobs: - name: Create Conan profile run: | - cat < conan_profile + cat <<'EOF' > conan_profile [settings] compiler = ${{ matrix.compiler.name }} compiler.version = ${{ matrix.compiler.version }} @@ -69,8 +69,8 @@ jobs: CXX = ${{ matrix.compiler.cpp-path }} [options] - ipc:build = False ipc:doc = True + ipc:build = False EOF - name: Install Flow-IPC dependencies (like Doxygen) with Conan using the profile @@ -178,8 +178,7 @@ jobs: data['compiler']['gcc']['sanitizer'] = ['None', 'address', 'thread', 'memory', 'undefined'] data['compiler']['clang']['sanitizer'] = ['None', 'address', 'thread', 'memory', 'undefined'] option-env-name: ASAN - cmake-flags: | # At least ASAN with clang + LTO => cryptic link error. No need for LTO when *SAN. - -DCFG_NO_LTO=ON + no-lto: true # At least ASAN with clang + LTO => cryptic link error. No need for LTO when *SAN. - id: relwithdebinfo-ubsan conan-profile-build-type: RelWithDebInfo conan-profile-jemalloc-build-type: Release @@ -198,8 +197,7 @@ jobs: data['compiler']['gcc']['sanitizer'] = ['None', 'address', 'thread', 'memory', 'undefined'] data['compiler']['clang']['sanitizer'] = ['None', 'address', 'thread', 'memory', 'undefined'] option-env-name: UBSAN - cmake-flags: | # While UBSAN might work with LTO, I do not want the aggravation/entropy. Turn it off. - -DCFG_NO_LTO=ON + no-lto: true # While UBSAN might work with LTO, I do not want the aggravation/entropy. Turn it off. - id: relwithdebinfo-tsan conan-profile-build-type: RelWithDebInfo conan-profile-jemalloc-build-type: Release @@ -235,7 +233,7 @@ jobs: Shm_session_data_test.Multithread_object_database skip-transport-tests: true # TODO: Explain why briefly (even though there's prob a ticket). option-env-name: TSAN - cmake-flags: # See the other *SAN; but for now I heed jkontrik's words to keep consistent with non-*SAN. + no-lto: false # See the other *SAN; but for now I heed jkontrik's words to keep consistent with non-*SAN. - id: relwithdebinfo-msan conan-profile-build-type: RelWithDebInfo conan-profile-jemalloc-build-type: Release @@ -253,8 +251,7 @@ jobs: conan-custom-settings-defs: | data['compiler']['gcc']['sanitizer'] = ['None', 'address', 'thread', 'memory', 'undefined'] data['compiler']['clang']['sanitizer'] = ['None', 'address', 'thread', 'memory', 'undefined'] - cmake-flags: | # While MSAN might work with LTO, I do not want the aggravation/entropy. Turn it off. - -DCFG_NO_LTO=ON + no-lto: true # While MSAN might work with LTO, I do not want the aggravation/entropy. Turn it off. # We concentrate on clang sanitizers; they are newer/nicer; also MSAN is clang-only. So gcc ones excluded. # Attention! Excluding some sanitizer job(s) (with these reasons): @@ -412,7 +409,7 @@ jobs: - name: Create Conan profile run: | - cat < conan_profile + cat <<'EOF' > conan_profile [settings] compiler = ${{ matrix.compiler.name }} compiler.version = ${{ matrix.compiler.version }} @@ -435,11 +432,14 @@ jobs: ${{ matrix.build-test-cfg.conan-profile-custom-buildenv }} [options] - ipc:build = True - ipc:doc = False - flow:build = True flow:doc = False + flow:build = True + ipc:doc = False + ipc:build = True EOF + if [ "${{ matrix.build-test-cfg.no-lto }}" != '' ]; then + echo 'ipc:build_no_lto = True' + fi # We need to prepare a sanitizer ignore-list in MSAN mode. Background for this is subtle and annoying: # As it stands, whatever matrix compiler/build-type is chosen applies not just to our code (correct) diff --git a/conanfile.py b/conanfile.py index 27c3fd697..241470ca2 100644 --- a/conanfile.py +++ b/conanfile.py @@ -7,35 +7,39 @@ class IpcRecipe(ConanFile): settings = "os", "compiler", "build_type", "arch" options = { - "build": [True, False], + "build": [True, False], + "build_no_lto": [True, False], "doc": [True, False], } - + default_options = { - "build": True, + "build": True, + "build_no_lto": False, "doc": False, } def configure(self): if self.options.build: - self.options["jemalloc"].enable_cxx = False + self.options["jemalloc"].enable_cxx = False self.options["jemalloc"].prefix = "je_" - + def generate(self): deps = CMakeDeps(self) if self.options.doc: deps.build_context_activated = ["doxygen/1.9.4"] deps.generate() - + toolchain = CMakeToolchain(self) if self.options.build: toolchain.variables["CFG_ENABLE_TEST_SUITE"] = "ON" toolchain.variables["JEMALLOC_PREFIX"] = self.options["jemalloc"].prefix + if self.options.build_no_lto: + toolchain.variables["CFG_NO_LTO"] = "ON" if self.options.doc: toolchain.variables["CFG_ENABLE_DOC_GEN"] = "ON" toolchain.variables["CFG_SKIP_CODE_GEN"] = "ON" toolchain.generate() - + def build(self): cmake = CMake(self) cmake.configure() @@ -44,15 +48,17 @@ def build(self): if self.options.build: self.run("cmake --build . -- --keep-going VERBOSE=1") if self.options.doc: + # Note: `flow_doc_public flow_doc_full` could also be added here and work; however + # we leave that to `flow` and its own Conan setup. self.run("cmake --build . -- ipc_doc_public ipc_doc_full --keep-going VERBOSE=1") - + def requirements(self): if self.options.build: self.requires("capnproto/1.0.1") self.requires("flow/1.0") self.requires("gtest/1.14.0") self.requires("jemalloc/5.2.1") - + def build_requirements(self): self.tool_requires("cmake/3.26.3") if self.options.doc: @@ -61,6 +67,6 @@ def build_requirements(self): def package(self): cmake = CMake(self) cmake.install() - + def layout(self): cmake_layout(self)