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

cmake: Re-write the capability database to avoid file appends #10481

Conversation

SebastianBoe
Copy link
Collaborator

@SebastianBoe SebastianBoe commented Oct 10, 2018

CI sometimes fails with a temporarily corrupted toolchain capabilitiy
database file. Although not proven, there is evidence that CMake's
file(APPEND does not work atomically when there are concurrent writes
and reads of a certain size.

To avoid file appending, we re-write the key-value database
implementation to store keys in filenames and values in individual
single-byte files.

This (most likely) fixes #9992.

NB: Users that have been overriding the database file location with
the CMake variable ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE must now specify
a directory with the variable ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE_DIR.

Signed-off-by: Sebastian Bøe [email protected]

CI sometimes fails with a temporarily corrupted toolchain capabilitiy
database file. Although not proven, there is evidence that CMake's
file(APPEND does not work atomically when there are concurrent writes
and reads of a certain size.

To avoid file appending, we re-write the key-value database
implementation to store keys in filenames and values in individual
single-byte files.

This is (most likely) fixes zephyrproject-rtos#9992.

NB: Users that have been overriding the database file location with
the CMake variable ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE must now specify
a directory with the variable ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE_DIR.

Signed-off-by: Sebastian Bøe <[email protected]>
@SebastianBoe SebastianBoe requested a review from nashif as a code owner October 10, 2018 10:32
@SebastianBoe
Copy link
Collaborator Author

recheck

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@9b87f63). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #10481   +/-   ##
=========================================
  Coverage          ?   53.23%           
=========================================
  Files             ?      210           
  Lines             ?    25800           
  Branches          ?     5677           
=========================================
  Hits              ?    13735           
  Misses            ?     9755           
  Partials          ?     2310

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b87f63...941d6e4. Read the comment docs.

@SebastianBoe
Copy link
Collaborator Author

@nashif : This is ready for review.

@nashif nashif merged commit e7dcc9d into zephyrproject-rtos:master Oct 19, 2018
file(
WRITE
${key_path}
${inner_check}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't that just reduce the window of the race? I mean it's much better but you could still have two cmake instances trying to create the same key at the same time, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this is thread-safe.

AFAIK two threads writing the same byte to the same position of the same file is thread-safe.

But I could be wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK so there is a hopefully harmless race but a race nevertheless. PR #15128 just submitted removes the "hopefully".

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

Successfully merging this pull request may close these issues.

cmake compiler cache failures in CI
4 participants