diff options
author | Patryk Duda <pdk@semihalf.com> | 2023-05-04 16:36:23 +0200 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-05 18:20:03 +0000 |
commit | 54aa69fd9605d3bc38b410c8918aea9c8378e4f0 (patch) | |
tree | 63ddb3044b1067f7b095bb2ca0a10d415f040a68 | |
parent | c9058d74c1f63fb6c8918d52c6e2d837158f1ea5 (diff) | |
download | chrome-ec-54aa69fd9605d3bc38b410c8918aea9c8378e4f0.tar.gz |
third_party: Make BoringSSL independent from cryptoc
BoringSSL is a separate cryptography library and doesn't depend on
cryptoc. Until now, lines related to BoringSSL in rules.mk was under
cryptoc config, so it was necessary to enable cryptoc in order to enable
BoringSSL.
Move BoringSSL related lines out of the cryptoc config.
BUG=b:277029648
TEST=make BOARD=bloonchipper
TEST=make BOARD=dartmonkey
Change-Id: If04d38b4998fb3f8e2754658b0f818c1b7f25bac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4505971
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Patryk Duda <patrykd@google.com>
Tested-by: Patryk Duda <patrykd@google.com>
-rw-r--r-- | third_party/rules.mk | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/third_party/rules.mk b/third_party/rules.mk index 888ef41c06..842343b16e 100644 --- a/third_party/rules.mk +++ b/third_party/rules.mk @@ -15,10 +15,6 @@ ifeq ($(CONFIG_LIBCRYPTOC),y) # $ make CRYPTOC_DIR=~/src/cryptoc BOARD=bloonchipper CRYPTOC_DIR ?= ../../third_party/cryptoc -# The boringssl path can be overridden on invocation, as in the following -# example: $ make BORINGSSL_DIR=~/src/boringssl BOARD=bloonchipper -BORINGSSL_DIR ?= ../../third_party/boringssl - # SUPPORT_UNALIGNED indicates to libcryptoc that provided data buffers # may be unaligned and please handle them safely. cmd_libcryptoc = $(MAKE) -C $(CRYPTOC_DIR) \ @@ -29,6 +25,39 @@ cmd_libcryptoc_clean = $(cmd_libcryptoc) -q && echo clean CPPFLAGS += -I$(CRYPTOC_DIR)/include CRYPTOC_LDFLAGS := -L$(out)/cryptoc -lcryptoc +# Conditionally force the rebuilding of libcryptoc.a only if it would be +# changed. +# Note, we use ifndef to ensure the likelyhood of rebuilding is much higher. +# For example, if variable cmd_libcryptoc_clean is modified or blank, +# we will rebuild. +ifneq ($(shell $(cmd_libcryptoc_clean)),clean) +.PHONY: $(out)/cryptoc/libcryptoc.a +endif +# Rewrite the CFLAGS include paths to be absolute, since cryptoc is built +# using a different working directory. This is only relevant because +# cryptoc makes use of stdlibs, which EC provides from the builtin/ directory. +$(out)/cryptoc/libcryptoc.a: CFLAGS := $(patsubst -I%,-I$(abspath %),$(CFLAGS)) +$(out)/cryptoc/libcryptoc.a: + +$(call quiet,libcryptoc,MAKE ) + +# Link RO and RW against cryptoc. +$(out)/RO/ec.RO.elf $(out)/RO/ec.RO_B.elf: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) +$(out)/RO/ec.RO.elf $(out)/RO/ec.RO_B.elf: $(out)/cryptoc/libcryptoc.a +$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) +$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: $(out)/cryptoc/libcryptoc.a + +# Host test executables (including fuzz tests). +$(out)/$(PROJECT).exe: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) +$(out)/$(PROJECT).exe: $(out)/cryptoc/libcryptoc.a + +# On-device tests. +third-party-test-targets=$(foreach test,$(test-list-y),\ + $(out)/RW/$(test).RW.elf $(out)/RO/$(test).RO.elf) +$(third-party-test-targets): LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) +$(third-party-test-targets): $(out)/cryptoc/libcryptoc.a + +endif # CONFIG_LIBCRYPTOC + ifeq ($(CONFIG_BORINGSSL_CRYPTO), y) ifndef CMAKE_SYSTEM_PROCESSOR $(error ERROR: Set CMAKE_SYSTEM_PROCESSOR in core/$(CORE)/toolchain.mk) @@ -37,6 +66,10 @@ ifndef OPENSSL_NO_ASM $(error ERROR: Set OPENSSL_NO_ASM in core/$(CORE)/toolchain.mk) endif +# The boringssl path can be overridden on invocation, as in the following +# example: $ make BORINGSSL_DIR=~/src/boringssl BOARD=bloonchipper +BORINGSSL_DIR ?= ../../third_party/boringssl + BORINGSSL_OUTDIR := $(out)/third_party/boringssl/crypto BORINGSSL_TOOLCHAIN := \ $(shell pwd)/third_party/boringssl/boringssl-toolchain.cmake @@ -69,54 +102,18 @@ CPPFLAGS += -I$(shell pwd)/third_party/boringssl/include # TODO(b/273639386): Remove these workarounds when the upstream supports # better way to disable the filesystem, threads and locks usages. CPPFLAGS += -D__TRUSTY__ -endif - -# Conditionally force the rebuilding of libcryptoc.a only if it would be -# changed. -# Note, we use ifndef to ensure the likelyhood of rebuilding is much higher. -# For example, if variable cmd_libcryptoc_clean is modified or blank, -# we will rebuild. -ifneq ($(shell $(cmd_libcryptoc_clean)),clean) -.PHONY: $(out)/cryptoc/libcryptoc.a -endif -# Rewrite the CFLAGS include paths to be absolute, since cryptoc is built -# using a different working directory. This is only relevant because -# cryptoc makes use of stdlibs, which EC provides from the builtin/ directory. -$(out)/cryptoc/libcryptoc.a: CFLAGS := $(patsubst -I%,-I$(abspath %),$(CFLAGS)) -$(out)/cryptoc/libcryptoc.a: - +$(call quiet,libcryptoc,MAKE ) -# Link RO and RW against cryptoc. -$(out)/RO/ec.RO.elf $(out)/RO/ec.RO_B.elf: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) -$(out)/RO/ec.RO.elf $(out)/RO/ec.RO_B.elf: $(out)/cryptoc/libcryptoc.a -$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) -$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: $(out)/cryptoc/libcryptoc.a -ifeq ($(CONFIG_BORINGSSL_CRYPTO), y) $(out)/RO/ec.RO.elf $(out)/RO/ec.RO_B.elf: LDFLAGS_EXTRA += $(BORINGSSL_LDFLAGS) $(out)/RO/ec.RO.elf $(out)/RO/ec.RO_B.elf: $(BORINGSSL_OUTDIR)/libcrypto.a $(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: LDFLAGS_EXTRA += $(BORINGSSL_LDFLAGS) $(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: $(BORINGSSL_OUTDIR)/libcrypto.a -endif -# Host test executables (including fuzz tests). -$(out)/$(PROJECT).exe: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) -$(out)/$(PROJECT).exe: $(out)/cryptoc/libcryptoc.a -ifeq ($(CONFIG_BORINGSSL_CRYPTO), y) $(out)/$(PROJECT).exe: LDFLAGS_EXTRA += $(BORINGSSL_LDFLAGS) $(out)/$(PROJECT).exe: $(BORINGSSL_OUTDIR)/libcrypto.a -endif -# On-device tests. -third-party-test-targets=$(foreach test,$(test-list-y),\ - $(out)/RW/$(test).RW.elf $(out)/RO/$(test).RO.elf) -$(third-party-test-targets): LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) -$(third-party-test-targets): $(out)/cryptoc/libcryptoc.a -ifeq ($(CONFIG_BORINGSSL_CRYPTO), y) $(third-party-test-targets): LDFLAGS_EXTRA += $(BORINGSSL_LDFLAGS) $(third-party-test-targets): $(BORINGSSL_OUTDIR)/libcrypto.a -endif - -endif # CONFIG_LIBCRYPTOC +endif # CONFIG_BORINGSSL_CRYPTO # Build and link against googletest in *test* builds if configured. ifeq ($(TEST_BUILD),y) |