Merge bitcoin/bitcoin#29963: depends: Do not consider CC environment variable for detecting system

b149a28f6b depends: Do not consider `CC` environment variable when detecting system (Hennadii Stepanov)

Pull request description:

  On the master branch @ 3c88eac28e, consider the following commands in the `depends` subdirectory:
  ```sh
  $ make print-build HOST=i686-pc-linux-gnu CC="clang -m32"
  build=x86_64-pc-linux-gnu
  $ make print-host HOST=i686-pc-linux-gnu CC="clang -m32"
  host=i686-pc-linux-gnu
  ```
  The printed variable values are expected.

  However, switching the `CC` variable context from Makefile to the shell environment breaks expectations:
  ```sh
  $ CC="clang -m32" make print-build HOST=i686-pc-linux-gnu
  build=i686-pc-linux-gnu
  $ CC="clang -m32" make print-host HOST=i686-pc-linux-gnu
  host=i686-pc-linux-gnu
  ```

  This PR fixes this issue.

  #### UPDATE 2026-01-20

  On the master branch @ 7f5ebef56a:
  ```
  $ gmake print-build HOST=i686-pc-linux-gnu CC="clang -m32"
  build=i686-pc-linux-gnu
  $ gmake print-host HOST=i686-pc-linux-gnu CC="clang -m32"
  host=i686-pc-linux-gnu
  ```

ACKs for top commit:
  sedited:
    Re-ACK b149a28f6b
  ryanofsky:
    Code review ACK b149a28f6b. `env --unset` was replaced with `unset &&` since last review. I still think it could be better to write `CC=$(build_CC)` here even if `build_CC` may not be defined at this point (https://github.com/bitcoin/bitcoin/pull/29963#issuecomment-3774229317) because it makes intent of the code more obvious, but current PR is already an improvement

Tree-SHA512: bd498706ad46aab93192e21b7cc30c34a714c5f31601122752fc94416dc51846b8d4eaf5d1c3250ba64d4eadf3fd43c9f7f5d9e178a47ee2165474ac6833fa31
This commit is contained in:
merge-script
2026-03-23 14:57:19 +08:00

View File

@@ -49,7 +49,7 @@ FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources
C_STANDARD ?= c11
CXX_STANDARD ?= c++20
BUILD = $(shell ./config.guess)
BUILD = $(shell unset CC && ./config.guess)
PATCHES_PATH = $(BASEDIR)/patches
BASEDIR = $(CURDIR)
HASH_LENGTH:=11