Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: do not export valgrind with export() #2189

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Apr 15, 2024

in Seastar, valgrind library is only used at the build time, and is used internally for accessing its header files when buildings its internal .cc files. so we don't expect to expose it via export(), for exposing it in SeastarTargets.cmake.

but somehow when building Seastar as a static library, valgrind is still exposed in Seastar's CMake configuration file. if a CMake based project consume Seastar using its CMake configuration file, it runs into following failure when CMake generates the building system:

-- Configuring done (2.5s)
CMake Error at external/seastar/build/release/SeastarTargets.cmake:52 (set_target_properties):
  The link interface of target "Seastar::seastar" contains:

    Valgrind::valgrind

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  external/seastar/build/release/SeastarConfig.cmake:36 (include)
  CMakeLists.txt:6 (find_package)

fortunately, in CMake 3.26, BUILD_LOCAL_INTERFACE was introduced this problem in specific, so that the linked library is not included by export() anymore.

in this change, we include Valgrind::valgrind using this generator expression if the CMake's version is greater or equal to 3.26, so that Valgrind is not required for building Seastar applications.

as this generator expression is not available on CMake versions lower than 3.26, and the minimal required CMake version for building Seastar is 3.13, and Seastar does support static build. The issue is still not fully addressed even with this change with older CMake and if Seastar is built as a static library.

previously, 372a16a intended to address this. but somehow Valgrind is still exposed by SeastarTargets.cmake.

Refs #2180
Signed-off-by: Kefu Chai kefu.chai@scylladb.com

@tchaikov
Copy link
Contributor Author

@robinchrist hi Robin, could you help test this change?

in Seastar, valgrind library is only used at the build time, and is
used internally for accessing its header files when buildings its
internal .cc files. so we don't expect to expose it via `export()`,
for exposing it in `SeastarTargets.cmake`.

but somehow when building Seastar as a static library, valgrind is
still exposed in Seastar's CMake configuration file. if a CMake
based project consume Seastar using its CMake configuration file,
it runs into following failure when CMake generates the building
system:

```
-- Configuring done (2.5s)
CMake Error at external/seastar/build/release/SeastarTargets.cmake:52 (set_target_properties):
  The link interface of target "Seastar::seastar" contains:

    Valgrind::valgrind

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  external/seastar/build/release/SeastarConfig.cmake:36 (include)
  CMakeLists.txt:6 (find_package)
```

fortunately, in CMake 3.26, `BUILD_LOCAL_INTERFACE` was introduced
this problem in specific, so that the linked library is not included
by `export()` anymore.

in this change, we include `Valgrind::valgrind` using this generator
expression if the CMake's version is greater or equal to 3.26, so that
`Valgrind` is not required for building Seastar applications.

as this generator expression is not available on CMake versions lower
than 3.26, and the minimal required CMake version for building Seastar
is 3.13, and Seastar does support static build. The issue is still not
fully addressed even with this change with older CMake and if Seastar
is built as a static library.

previously, 372a16a intended to address this. but somehow Valgrind
is still exposed by SeastarTargets.cmake.

Refs scylladb#2180
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
@tchaikov tchaikov added the build build system label Apr 15, 2024
@tchaikov
Copy link
Contributor Author

@scylladb/seastar-maint hello maintainers, could you help review this change?

@avikivity avikivity merged commit 21fbccc into scylladb:master Apr 18, 2024
14 checks passed
@avikivity
Copy link
Member

We should consider dropping valgrind. Is there anything it does that asan/ubsan does not?

@tchaikov tchaikov deleted the build-sans-valgrind branch April 18, 2024 16:20
@robinchrist
Copy link

robinchrist commented May 19, 2024

Yep I can confirm that this fix is working! Thanks a lot @tchaikov

@nyh
Copy link
Contributor

nyh commented May 19, 2024

We should consider dropping valgrind. Is there anything it does that asan/ubsan does not?

Four years ago, after someone who was a valgrind fan decided that Seastar must depend on it, I wrote a patch in https://groups.google.com/g/seastar-dev/c/f0WfaK0KgZ0/m/qK2WlDMrCAAJ making this dependency optional - i.e., if you (a Seastar developer) already have valgrind installed, it will be compiled in a way that you can use valgrind on it. But if you don't have valgrind installed? That's fine, and you can still compile without it.

But there was fierce opposition to my patch and it never got in.

Maybe it's time to reconsider - my original patch or something else with the same effect of making valgrind optional.

robinchrist added a commit to robinchrist/Kataklysmos that referenced this pull request May 19, 2024
@tchaikov
Copy link
Contributor Author

We should consider dropping valgrind. Is there anything it does that asan/ubsan does not?

Four years ago, after someone who was a valgrind fan decided that Seastar must depend on it, I wrote a patch in https://groups.google.com/g/seastar-dev/c/f0WfaK0KgZ0/m/qK2WlDMrCAAJ making this dependency optional - i.e., if you (a Seastar developer) already have valgrind installed, it will be compiled in a way that you can use valgrind on it. But if you don't have valgrind installed? That's fine, and you can still compile without it.

But there was fierce opposition to my patch and it never got in.

Maybe it's time to reconsider - my original patch or something else with the same effect of making valgrind optional.

if it's desirable to make valgrind optional, i can add a Seastar_VALGRIND option. and i concur with Raphael and Pekka on #if __has_include() is not the cure of this issue (if it is).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants