arch/arm64/Makefile.mk: Unset toolchain vars for BL31

This change is for upcoming arm-trusted uprev commit.

TF-A refactors the toolchain detection in [1][2]. After that `AR`,
`CC`, `LD` and other toolchain variables have precedence over
`CROSS_COMPILE`.

Since ChromeOS build system also sets those toolchain variables when
building coreboot, it results that TF-A uses CrOS GCC instead of
coreboot SDK. It needs to unset those variables in order to make
`CROSS_COMPILE` effective.

TF-A upstream changes the default linker from BFD to GCC in [3].
Therefore, temporarily overriding LD as $(LD_arm64} to fix the below
build error.

aarch64-elf-gcc: error: unrecognized command-line option '--emit-relocs'

In addition, TF-A wrapped LD with single quotes to solve Windows path
issue[4]. On MT8173 platform, `--fix-cortex-a53-843419` is appended to
$(LD_arm64} for ERRATA_A53_843419. It results in the below build error.

/bin/sh: 1: --fix-cortex-a53-843419: not found

Since `--fix-cortex-a53-843419` is never passed to TF-A, simply extract
the LD command from $(LD_arm64) by $(word 1, $(LD_arm64)).

[1]: https://review.trustedfirmware.org/c/24921
[2]: https://review.trustedfirmware.org/c/25333
[3]: https://review.trustedfirmware.org/c/26703
[4]: https://review.trustedfirmware.org/c/26737

BUG=b:338420310
TEST=emerge-geralt coreboot
TEST=./util/abuild/abuild -t google/geralt -b geralt -a -x
TEST=./util/abuild/abuild -t google/oak -b elm -a -x
TEST=./util/abuild/abuild -t google/cherry -x -a

Change-Id: Ieac9f96e81e574b87e20cd2df335c36abcb8bb5c
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/82187
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Eric Lai <ericllai@google.com>
This commit is contained in:
Yidi Lin 2024-05-04 17:18:44 +08:00 committed by Yu-Ping Wu
parent a29d06a952
commit 7e3cabec51

View File

@ -179,7 +179,9 @@ BL31 := $(obj)/bl31.elf
$(BL31): $(obj)/build.h
printf " MAKE $(subst $(obj)/,,$(@))\n"
+CROSS_COMPILE="$(CROSS_COMPILE_arm64)" \
+unset AS AR CC CPP OC OD; \
LD=$(word 1, $(LD_arm64)) \
CROSS_COMPILE="$(CROSS_COMPILE_arm64)" \
CFLAGS="$(BL31_CFLAGS)" \
LDFLAGS="$(BL31_LDFLAGS)" \
$(MAKE) -C $(BL31_SOURCE) $(BL31_MAKEARGS) $(BL31_TARGET) DISABLE_PEDANTIC=1