Skip to content

fix include-ordering on FreeBSD that could cause build issues#1972

Merged
BareosBot merged 3 commits intobareos:masterfrom
arogge:dev/arogge/master/fix-freebsd-build
Oct 2, 2024
Merged

fix include-ordering on FreeBSD that could cause build issues#1972
BareosBot merged 3 commits intobareos:masterfrom
arogge:dev/arogge/master/fix-freebsd-build

Conversation

@arogge
Copy link
Member

@arogge arogge commented Oct 2, 2024

This PR makes sure /usr/local/include comes after our own include-directories in the include order to fix a problem where header-only libraries could be mixed up between translation units.
It also fixes an ODR violation in the storage daemon.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Required backport PRs have been created
  • Correct milestone is set
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR

arogge added 2 commits October 2, 2024 14:26
this adds the SYSTEM option to include_directories(/usr/local/include)
on FreeBSD.

When adding /usr/local/include using include_directories() for FreeBSD,
it may be used as the first -I on the compiler's commandline so that
system installed headers in /usr/local will be preferred over headers of
the libraries we discovered.
However, this can vary between translation units, leading to some TUs
being compiled with headers from /usr/local/include and some with
headers we have bundled.
As a result, you may run into all sorts of issues when finally linking
TUs that used different versions of a header-only library into a binary.

To avoid this, we declare /usr/local/include as a SYSTEM include
directory, so CMake will always put it after all non-SYSTEM include
directories on the command line and use -isystem, which as a side-effect
also silences warnings.
This removes askdir.cc from SDSRCS (i.e. the source files for bareos-sd)
as it is already listed in LIBBAREOSSD_SRCS and leads to the TU being
linked into the resulting binary twice, which is an ODR violation.
@arogge arogge added this to the 24.0.0 milestone Oct 2, 2024
@arogge arogge self-assigned this Oct 2, 2024
@arogge arogge requested a review from sebsura October 2, 2024 12:39
@BareosBot BareosBot merged commit f5bc305 into bareos:master Oct 2, 2024
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.

3 participants