@@ -112,37 +112,31 @@ include builders/$(build_os).mk
112
112
include builders/default.mk
113
113
include packages/packages.mk
114
114
115
- full_env =$(shell printenv)
116
-
117
- build_id_string: =$(BUILD_ID_SALT )
118
-
119
- # GCC only prints COLLECT_LTO_WRAPPER when invoked with just "-v", but we want
120
- # the information from "-v -E -" as well, so just include both.
115
+ # Previously, we directly invoked the well-known programs using $(shell ...)
116
+ # to contruct build_id_string. However, that was problematic because:
121
117
#
122
- # '3>&1 1>&2 2>&3 > /dev/null' is supposed to swap stdin and stdout and silence
123
- # stdin, since we only want the stderr output
124
- build_id_string+ =$(shell $(build_CC ) -v < /dev/null 3>&1 1>&2 2>&3 > /dev/null) $(shell $(build_CC ) -v -E - < /dev/null 3>&1 1>&2 2>&3 > /dev/null)
125
- build_id_string+ =$(shell $(build_AR ) --version 2>/dev/null) $(filter AR_% ,$(full_env ) ) ZERO_AR_DATE=$(ZERO_AR_DATE )
126
- build_id_string+ =$(shell $(build_CXX ) -v < /dev/null 3>&1 1>&2 2>&3 > /dev/null) $(shell $(build_CXX ) -v -E - < /dev/null 3>&1 1>&2 2>&3 > /dev/null)
127
- build_id_string+ =$(shell $(build_RANLIB ) --version 2>/dev/null) $(filter RANLIB_% ,$(full_env ) )
128
- build_id_string+ =$(shell $(build_STRIP ) --version 2>/dev/null) $(filter STRIP_% ,$(full_env ) )
129
-
130
- $(host_arch)_$(host_os)_id_string: =$(HOST_ID_SALT )
131
- $(host_arch)_$(host_os)_id_string+ =$(shell $(host_CC ) -v < /dev/null 3>&1 1>&2 2>&3 > /dev/null) $(shell $(host_CC ) -v -E - < /dev/null 3>&1 1>&2 2>&3 > /dev/null)
132
- $(host_arch)_$(host_os)_id_string+ =$(shell $(host_AR ) --version 2>/dev/null) $(filter AR_% ,$(full_env ) ) ZERO_AR_DATE=$(ZERO_AR_DATE )
133
- $(host_arch)_$(host_os)_id_string+ =$(shell $(host_CXX ) -v < /dev/null 3>&1 1>&2 2>&3 > /dev/null) $(shell $(host_CXX ) -v -E - < /dev/null 3>&1 1>&2 2>&3 > /dev/null)
134
- $(host_arch)_$(host_os)_id_string+ =$(shell $(host_RANLIB ) --version 2>/dev/null) $(filter RANLIB_% ,$(full_env ) )
135
- $(host_arch)_$(host_os)_id_string+ =$(shell $(host_STRIP ) --version 2>/dev/null) $(filter STRIP_% ,$(full_env ) )
136
-
137
- ifneq ($(strip $(FORCE_USE_SYSTEM_CLANG ) ) ,)
138
- # Make sure that cache is invalidated when switching between system and
139
- # depends-managed, pinned clang
140
- build_id_string+ =system_clang
141
- $(host_arch)_$(host_os)_id_string+ =system_clang
142
- endif
143
-
144
- build_id_string+=GUIX_ENVIRONMENT =$(realpath $(GUIX_ENVIRONMENT ) )
145
- $(host_arch)_$(host_os)_id_string+=GUIX_ENVIRONMENT =$(realpath $(GUIX_ENVIRONMENT ) )
118
+ # 1. When invoking a shell, GNU Make special-cases exit code 127 (command not
119
+ # found) by not capturing the output but instead passing it through. This is
120
+ # not done for any other exit code.
121
+ #
122
+ # 2. Characters like '#' (from these programs' output) would end up in make
123
+ # variables like build_id_string, which would be wrongly interpreted by make
124
+ # when these variables were used.
125
+ #
126
+ # Therefore, we should avoid having arbitrary strings in make variables where
127
+ # possible. The gen_id script used here hashes the output to construct a
128
+ # "make-safe" id.
129
+ #
130
+ # Also note that these lines need to be:
131
+ #
132
+ # 1. After including {hosts,builders}/*.mk, since they rely on the tool
133
+ # variables (e.g. build_CC, host_STRIP, etc.) to be set.
134
+ #
135
+ # 2. Before including packages/*.mk (excluding packages/packages.mk), since
136
+ # they rely on the build_id variables
137
+ #
138
+ build_id: =$(shell env CC='$(build_CC ) ' CXX='$(build_CXX ) ' AR='$(build_AR ) ' RANLIB='$(build_RANLIB ) ' STRIP='$(build_STRIP ) ' SHA256SUM='$(build_SHA256SUM ) ' DEBUG='$(DEBUG ) ' ./gen_id '$(BUILD_ID_SALT ) ' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT ) ) ')
139
+ $(host_arch)_$(host_os)_id: =$(shell env CC='$(host_CC ) ' CXX='$(host_CXX ) ' AR='$(host_AR ) ' RANLIB='$(host_RANLIB ) ' STRIP='$(host_STRIP ) ' SHA256SUM='$(build_SHA256SUM ) ' DEBUG='$(DEBUG ) ' ./gen_id '$(HOST_ID_SALT ) ' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT ) ) ')
146
140
147
141
qrencode_packages_$(NO_QR) = $(qrencode_packages )
148
142
0 commit comments