Skip to content

Comments

blk/CMakeLists.txt: generate interface library if libblk is disabled#60305

Merged
MaxKellermann merged 1 commit intoceph:mainfrom
MaxKellermann:blk_interface
Feb 13, 2025
Merged

blk/CMakeLists.txt: generate interface library if libblk is disabled#60305
MaxKellermann merged 1 commit intoceph:mainfrom
MaxKellermann:blk_interface

Conversation

@MaxKellermann
Copy link
Member

If all the libraries which libblk wraps (i.e. Bluestore, AIO, SPDK, ZBD) are disabled, then the build aborts with a linker failure:

 c++ [...] -o bin/ceph-mon [...] -lblk [...]
 mold: fatal: library not found: blk
 collect2: error: ld returned 1 exit status

This is because blk is used (via os) but if the add_library() directive is skipped, cmake attempts to look up a library with that name.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

If all the libraries which `libblk` wraps (i.e. Bluestore, AIO, SPDK,
ZBD) are disabled, then the build aborts with a linker failure:

```
 c++ [...] -o bin/ceph-mon [...] -lblk [...]
 mold: fatal: library not found: blk
 collect2: error: ld returned 1 exit status
```

This is because `blk` is used (via `os`) but if the `add_library()`
directive is skipped, `cmake` attempts to look up a library with that
name.

Signed-off-by: Max Kellermann <[email protected]>
@MaxKellermann
Copy link
Member Author

Bug fix PR nearly two months without a review. Posting a useless comment to keep your bot from marking it stale.

@athanatos
Copy link
Contributor

@aclamk @ifed01 Does this look reasonable to you?

@athanatos athanatos requested review from aclamk and ifed01 December 9, 2024 02:12
@MaxKellermann
Copy link
Member Author

It's been another month.

@tchaikov
Copy link
Contributor

tchaikov commented Jan 5, 2025

@MaxKellermann hi Max, thank you for this fix. but i think the reason why we linked os against blk was because of the bluestore backend, which in turn uses BlockDevice to access the underlying block devices. so instead of generating an interface library for blk, i think a better fix would be to put something like:

if(WITH_BLUESTORE)
  target_link_libraries(os
    blk)
endif()

where we don't link os against blk unconditionally. this change makes the dependency more obvious. what do you think?

@MaxKellermann
Copy link
Member Author

@tchaikov, that would be another way to fix this build failure; but I decided against it because it would require fixes in 3 places (src/crimson/os/alienstore/CMakeLists.txt, src/librbd/CMakeLists.txt, src/os/CMakeLists.txt), adding 3 more cmake conditionals; while my approach adds zero conditionals, as it only adds an else to an existing conditional. It's the simplest possible fix for this bug.
Under these circumstances, would you want me to change this PR to implement the other approach you suggested?

@tchaikov tchaikov self-assigned this Jan 7, 2025
@tchaikov
Copy link
Contributor

tchaikov commented Jan 7, 2025

thanks, Max. i will take a closer look at it and get back to you in this week.

Copy link
Contributor

@tchaikov tchaikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tchaikov
Copy link
Contributor

@tchaikov, that would be another way to fix this build failure; but I decided against it because it would require fixes in 3 places (src/crimson/os/alienstore/CMakeLists.txt, src/librbd/CMakeLists.txt, src/os/CMakeLists.txt), adding 3 more cmake conditionals; while my approach adds zero conditionals, as it only adds an else to an existing conditional. It's the simplest possible fix for this bug. Under these circumstances, would you want me to change this PR to implement the other approach you suggested?

a dummy library is indeed simpler. thanks!

@ceph-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@tchaikov
Copy link
Contributor

jenkins test api

@tchaikov
Copy link
Contributor

jenkins test make check arm64

@MaxKellermann MaxKellermann mentioned this pull request Feb 7, 2025
14 tasks
@MaxKellermann MaxKellermann merged commit 62da191 into ceph:main Feb 13, 2025
2 checks passed
@MaxKellermann MaxKellermann deleted the blk_interface branch February 13, 2025 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants