depends: `$(package)_*_env` settings only apply to the first command #22719

issue dongcarl opened this issue on August 16, 2021
  1. dongcarl commented at 4:53 PM on August 16, 2021: contributor

    For example, $(package)_config_env is prepended to $(package)_config_cmds, which means that if $(package)_config_cmds contains multiple commands chained by &&, only the first command would have its environment modified according to $(package)_config_env.

    https://github.com/bitcoin/bitcoin/blob/b935abb9eb2eeaceb5621e110e1889c2ce1b7734/depends/funcs.mk#L212

    Since $(package)_*_env settings contain crucial env vars such as PATH or PKG_CONFIG_PATH, its omission in subsequent commands is likely a bug:

    https://github.com/bitcoin/bitcoin/blob/b935abb9eb2eeaceb5621e110e1889c2ce1b7734/depends/funcs.mk#L137-L142

    This has lead to problems such as: #16883 (comment)

    A test-able demo of this problem: https://github.com/dongcarl/bitcoin/commit/e233c6d1e96ed35489c6be37f07bd01546083b9e

  2. dongcarl cross-referenced this on Aug 16, 2021 from issue depends: Export variables from make to environment explicitly by hebasto
  3. hebasto commented at 5:04 PM on August 16, 2021: member

    As export (see #19882) looks pretty invasive, maybe bash -c '...'?

  4. dongcarl commented at 5:29 PM on August 16, 2021: contributor

    As export (see #19882) looks pretty invasive, maybe bash -c '...'?

    Wouldn't bash -c '...' have the same effect as export?

  5. hebasto commented at 10:45 AM on August 18, 2021: member

    As export (see #19882) looks pretty invasive...

    The assumption above is wrong.

    As a new sub-shell is invoked for each line of the recipe, there are no side effects of using export (#19882).

    A demo of the solution: https://github.com/hebasto/bitcoin/commit/926ba37cc5c351398253714fd143933d784dbc77.


    Wouldn't bash -c '...' have the same effect as export?

    Yes, it would.

  6. hebasto added the label Brainstorming on Aug 26, 2021
  7. hebasto added the label Build system on Aug 26, 2021
  8. hebasto cross-referenced this on Feb 6, 2022 from issue build: Make `$(package)_*_env` available to all `$(package)_*_cmds` by hebasto
  9. fanquake closed this on Dec 8, 2022

  10. sidhujag referenced this in commit 5dde8cb2a6 on Dec 8, 2022
  11. lyricidal cross-referenced this on Mar 30, 2023 from issue [Upstream] build: Make `$(package)_*_env` available to all `$(package)_*_cmds` by lyricidal
  12. bitcoin locked this on Dec 8, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:53 UTC