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

makefile: fix parallel make check failing on the first run (#177) #178

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ endif
ifeq ($(TEST_TMPDIR),)
TEST_TMPDIR := $(TMPD)
endif
# Avoid setting up the tmp directory on Makefile restarts or when the target
# isn't a check target
ifeq ($(MAKE_RESTARTS),)

# Avoid setting up the tmp directory when the target isn't a check target or
# on Makefile restarts
ifneq ($(filter %check,$(MAKECMDGOALS)),)
ifeq ($(MAKE_RESTARTS),)

ifeq ($(TEST_TMPDIR),)
ifeq ($(BASE_TMPDIR),)
Expand All @@ -27,11 +28,13 @@ ifeq ($(BASE_TMPDIR),)
BASE_TMPDIR :=/tmp
endif
# Use /dev/shm on Linux if it has the sticky bit set (otherwise, /tmp or other
# base dir), and create a randomly-named rocksdb.XXXX directory therein.
# base dir), and create a randomly-named rocksdb.XXXXXX directory therein.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why you changed the randomness/added more XXX? A comment somewhere (either in the source or the PR) would suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a comment in the Makefile, but I did explain it in the commit message:

Also use 6 Xs for the mktemp template in order to support BusyBox mktemp and maybe some others as well, that require the template to end with 6 Xs exactly.

ifneq ($(shell [ "$$(uname -s)" = "Linux" ] && [ -k /dev/shm ] && echo 1),)
BASE_TMPDIR :=/dev/shm
endif
TEST_TMPDIR := $(shell mktemp -d "$(BASE_TMPDIR)/rocksdb.XXXX")
# Use 6 Xs in the template in order to appease the BusyBox mktemp command,
# which requires the template to end with exactly 6 Xs.
TEST_TMPDIR := $(shell mktemp -d "$(BASE_TMPDIR)/rocksdb.XXXXXX")
endif

# The `export` line below doesn't work in case Make restarts (due to included
Expand All @@ -41,11 +44,15 @@ endif
# to avoid having the TEST_TMPDIR implicitly set for test that are run through
# makefiles that include make_config.mk, and because we don't want to change
# make_config.mk on every run)
$(shell echo 'TEST_TMPDIR?=$(TEST_TMPDIR)' > test_config.mk)
$(shell printf 'ifeq ($$(TEST_TMPDIR),)\nTEST_TMPDIR:=$(TEST_TMPDIR)\nendif\n' > test_config.mk)

else

# If neither TEST_TMPDIR nor TMPD were specified, try to load TEST_TMPDIR from
# a previous run as saved in test_config.mk (generated by the shell call above)
include test_config.mk

endif
endif

-include test_config.mk

export TEST_TMPDIR