Skip to content

Commit

Permalink
Fix toolchain collision
Browse files Browse the repository at this point in the history
Hunter computes a toolchain-id using the compiler vendor, version, and
compile flags. The idea is that if you change some flag that will
change the ABI, it will compute a new toolchain-id which will rebuild
dependencies.

This toolchain-id is computed by taking all of those inputs and
computing a SHA1 digest, and then truncating it to the first 7
characeters.

On Debian 12 I'm finding that this constantly collides when switching
branches, which requires me to delete the build directory every time I
change to a new branch.

This change truncates the CONFIG-ID, TOOLCHAIN-ID and HUNTER-ID to 9
characters instead of 7, which resolves the problem for me.
  • Loading branch information
ambroff committed Sep 18, 2023
1 parent f619c3e commit 33b6d07
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions cmake/modules/hunter_apply_gate_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ function(hunter_apply_gate_settings)
if(gate_done)
if(cache_init)
# set *_ID_PATH variables in parent scope
string(SUBSTRING "${HUNTER_SHA1}" 0 7 HUNTER_ID)
string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 7 HUNTER_CONFIG_ID)
string(SUBSTRING "${HUNTER_TOOLCHAIN_SHA1}" 0 7 HUNTER_TOOLCHAIN_ID)
string(SUBSTRING "${HUNTER_SHA1}" 0 9 HUNTER_ID)
string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 9 HUNTER_CONFIG_ID)
string(SUBSTRING "${HUNTER_TOOLCHAIN_SHA1}" 0 9 HUNTER_TOOLCHAIN_ID)
set(HUNTER_ID_PATH "${HUNTER_CACHED_ROOT}/_Base/${HUNTER_ID}")
set(HUNTER_TOOLCHAIN_ID_PATH "${HUNTER_ID_PATH}/${HUNTER_TOOLCHAIN_ID}")
set(HUNTER_CONFIG_ID_PATH "${HUNTER_TOOLCHAIN_ID_PATH}/${HUNTER_CONFIG_ID}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/hunter_calculate_self.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function(hunter_calculate_self root version sha1 result)
hunter_assert_not_empty_string("${sha1}")
hunter_assert_not_empty_string("${result}")

string(SUBSTRING "${sha1}" 0 7 archive_id)
string(SUBSTRING "${sha1}" 0 9 archive_id)

if(EXISTS "${root}/cmake/Hunter")
set(hunter_self "${root}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/hunter_download.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function(hunter_download)
endif()

if(HUNTER_PACKAGE_SCHEME_UNPACK)
string(SUBSTRING "${HUNTER_PACKAGE_SHA1}" 0 7 x)
string(SUBSTRING "${HUNTER_PACKAGE_SHA1}" 0 9 x)
set(hunter_lock_sources TRUE)
set(
hunter_lock_sources_dir
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/hunter_download_cache_raw_file.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function(hunter_download_cache_raw_file)
if(NOT is_github)
set(url "${server}/raw/${suffix}")
else()
string(SUBSTRING "${suffix}" 0 7 cache_tag)
string(SUBSTRING "${suffix}" 0 9 cache_tag)
set(url "${server}/releases/download/cache-${cache_tag}/${suffix}")
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/hunter_download_server_url.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function(hunter_download_server_url)
set(hunter_url_list) # list of URLs to try downloading from

# extract archive-ID from archive SHA1
string(SUBSTRING "${x_SHA1}" 0 7 archive_id)
string(SUBSTRING "${x_SHA1}" 0 9 archive_id)

# get filename from download URL
get_filename_component(package_filename_raw "${x_URL}" NAME)
Expand Down
6 changes: 3 additions & 3 deletions cmake/modules/hunter_finalize.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ macro(hunter_finalize)
# * define HUNTER_CONFIG_ID_PATH
hunter_apply_gate_settings()

string(SUBSTRING "${HUNTER_SHA1}" 0 7 HUNTER_ID)
string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 7 HUNTER_CONFIG_ID)
string(SUBSTRING "${HUNTER_TOOLCHAIN_SHA1}" 0 7 HUNTER_TOOLCHAIN_ID)
string(SUBSTRING "${HUNTER_SHA1}" 0 9 HUNTER_ID)
string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 9 HUNTER_CONFIG_ID)
string(SUBSTRING "${HUNTER_TOOLCHAIN_SHA1}" 0 9 HUNTER_TOOLCHAIN_ID)

set(HUNTER_INSTALL_PREFIX "${HUNTER_CONFIG_ID_PATH}/Install")
list(APPEND CMAKE_PREFIX_PATH "${HUNTER_INSTALL_PREFIX}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/hunter_make_directory.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function(hunter_make_directory parent sha1 result)
hunter_assert_not_empty_string("${sha1}")
hunter_assert_not_empty_string("${result}")

string(SUBSTRING "${sha1}" 0 7 dir_id)
string(SUBSTRING "${sha1}" 0 9 dir_id)

set(dir_path "${parent}/${dir_id}")
set(done_path "${dir_path}/DONE")
Expand Down

0 comments on commit 33b6d07

Please sign in to comment.