build/rebuild-backend.mk
author Nick Alexander <nalexander@mozilla.com>
Fri, 12 Oct 2018 22:38:44 +0000
changeset 499408 91300d29898b1a1102e1b62164aeee1f56b2ee86
parent 392025 03804db09cf364ff228fc61409702d9a86d44ade
child 530370 5cc56532ff4a4b2b896f84e4b6e7889837acb42d
permissions -rw-r--r--
Bug 1489443 - Set GCC_USE_GNU_LD based on linker kind. r=froydnj The desired outcome of this change is that we'll set `-Wl,--version-script` based on linker kind and not on the output of `$LINKER -v`. This is a cheap way to address a simple problem that has a complicated ideal solution. The underlying issue is that in some situations, when targeting Android, a macOS system `ld` is interrogated to determine if a cross-compiling linker "is GNU ld" and a particular linker feature is set in that situation. The macOS system `ld` doesn't pass the "is GNU ld" test, and the linker feature isn't set; that causes link failures, even though the actual linker has nothing to do with the system `ld`. The ideal solution is to test for linker capabilities dynamically. We do a lot of that in old-configure.in, and we don't do any of that in toolchain.configure. Rather than start testing in toolchain.configure, we hard-code: a cheap solution to the immediate problem. Differential Revision: https://phabricator.services.mozilla.com/D8471

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

BACKEND_GENERATION_SCRIPT ?= config.status

# A traditional rule would look like this:
#    backend.%:
#        @echo do stuff
#
# But with -j<n>, and multiple items in BUILD_BACKEND_FILES, the command would
# run multiple times in parallel.
#
# "Fortunately", make has some weird semantics for pattern rules: if there are
# multiple targets in a pattern rule and each of them is matched at most once,
# the command will only run once. So:
#     backend%RecursiveMakeBackend backend%FasterMakeBackend:
#         @echo do stuff
#     backend: backend.RecursiveMakeBackend backend.FasterMakeBackend
# would only execute the command once.
#
# Credit where due: http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file/3077254#3077254
$(subst .,%,$(BUILD_BACKEND_FILES)):
	@echo 'Build configuration changed. Regenerating backend.'
	$(PYTHON) $(BACKEND_GENERATION_SCRIPT)

define build_backend_rule
$(1): $$(wildcard $$(shell cat $(1).in))

endef
$(foreach file,$(BUILD_BACKEND_FILES),$(eval $(call build_backend_rule,$(file))))