diff options
| author | Khem Raj <raj.khem@gmail.com> | 2020-01-08 08:42:54 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-01-10 21:18:22 +0000 |
| commit | 019f8d3c0023b3d74790896148c174060cb2a604 (patch) | |
| tree | 4f4cab89e7fcb1b2475100710ffab85dc7392f85 | |
| parent | 1eecc83125ae1dee10537a13620c8355edf1d001 (diff) | |
| download | poky-019f8d3c0023b3d74790896148c174060cb2a604.tar.gz | |
opensbi: Use -ffreestanding compiler options
This usually helps compiler to not use built-in optimizations
for string functions and mem* functions unnecessarily, since OE's
compiler is hosted for linux cross compile, this also means we instruct
it rightly for building a baremetal application
Refresh the patches to apply without fuzz
Fixes linking errors e.g.
platform/qemu/virt/lib/libplatsbi.a(sbi_string.o): in function `sbi_memset':
| /mnt/b/yoe/build/tmp/work/riscv64-yoe-linux/opensbi/0.5-r0/git/lib/sbi/sbi_string.c:102: undefined reference to `memset'
| collect2: error: ld returned 1 exit status
(From OE-Core rev: f599b6c77f3585c8917f4d685689da4cc8a8bf04)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
3 files changed, 31 insertions, 7 deletions
diff --git a/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch b/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch index 9c2d0eb479..74d93618b2 100644 --- a/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch +++ b/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch | |||
| @@ -13,11 +13,9 @@ Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | |||
| 13 | Makefile | 2 -- | 13 | Makefile | 2 -- |
| 14 | 1 file changed, 2 deletions(-) | 14 | 1 file changed, 2 deletions(-) |
| 15 | 15 | ||
| 16 | diff --git a/Makefile b/Makefile | ||
| 17 | index ae68f55..10851fc 100644 | ||
| 18 | --- a/Makefile | 16 | --- a/Makefile |
| 19 | +++ b/Makefile | 17 | +++ b/Makefile |
| 20 | @@ -145,7 +145,6 @@ GENFLAGS += $(firmware-genflags-y) | 18 | @@ -162,7 +162,6 @@ GENFLAGS += $(firmware-genflags-y) |
| 21 | CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 | 19 | CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 |
| 22 | CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls | 20 | CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls |
| 23 | CFLAGS += -mno-save-restore -mstrict-align | 21 | CFLAGS += -mno-save-restore -mstrict-align |
| @@ -25,7 +23,7 @@ index ae68f55..10851fc 100644 | |||
| 25 | CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) | 23 | CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) |
| 26 | CFLAGS += $(GENFLAGS) | 24 | CFLAGS += $(GENFLAGS) |
| 27 | CFLAGS += $(platform-cflags-y) | 25 | CFLAGS += $(platform-cflags-y) |
| 28 | @@ -158,7 +157,6 @@ CPPFLAGS += $(firmware-cppflags-y) | 26 | @@ -176,7 +175,6 @@ CPPFLAGS += $(firmware-cppflags-y) |
| 29 | ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__ | 27 | ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__ |
| 30 | ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls | 28 | ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls |
| 31 | ASFLAGS += -mno-save-restore -mstrict-align | 29 | ASFLAGS += -mno-save-restore -mstrict-align |
| @@ -33,6 +31,3 @@ index ae68f55..10851fc 100644 | |||
| 33 | ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) | 31 | ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) |
| 34 | ASFLAGS += $(GENFLAGS) | 32 | ASFLAGS += $(GENFLAGS) |
| 35 | ASFLAGS += $(platform-asflags-y) | 33 | ASFLAGS += $(platform-asflags-y) |
| 36 | -- | ||
| 37 | 2.20.1 | ||
| 38 | |||
diff --git a/meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patch b/meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patch new file mode 100644 index 0000000000..4899fad6aa --- /dev/null +++ b/meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patch | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | From efa39afecedf75a1f3154c39507bdde2810bc140 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Mon, 6 Jan 2020 18:21:02 -0800 | ||
| 4 | Subject: [PATCH] build: Use -ffreestanding | ||
| 5 | |||
| 6 | this is a stand-alone/baremetal application, therefore demanding | ||
| 7 | -ffreestanding would help it compile with hosted toolchains e.g. ( linux | ||
| 8 | toolchains ), it also ensures that it won't be using platform | ||
| 9 | optimizations like inlining mem* str* functions which gcc might decide | ||
| 10 | especially with wrapper string functions in opensbi code | ||
| 11 | |||
| 12 | Upstream-Status: Accepted [https://github.com/riscv/opensbi/commit/049ad0b3877352527ab470eba33bc767e9b54961] | ||
| 13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 14 | --- | ||
| 15 | Makefile | 2 +- | ||
| 16 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 17 | |||
| 18 | --- a/Makefile | ||
| 19 | +++ b/Makefile | ||
| 20 | @@ -159,7 +159,7 @@ GENFLAGS += $(libsbiutils-genflags-y) | ||
| 21 | GENFLAGS += $(platform-genflags-y) | ||
| 22 | GENFLAGS += $(firmware-genflags-y) | ||
| 23 | |||
| 24 | -CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 | ||
| 25 | +CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2 | ||
| 26 | CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls | ||
| 27 | CFLAGS += -mno-save-restore -mstrict-align | ||
| 28 | CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) | ||
diff --git a/meta/recipes-bsp/opensbi/opensbi_0.5.bb b/meta/recipes-bsp/opensbi/opensbi_0.5.bb index 759bbbfdaa..6a9026254c 100644 --- a/meta/recipes-bsp/opensbi/opensbi_0.5.bb +++ b/meta/recipes-bsp/opensbi/opensbi_0.5.bb | |||
| @@ -11,6 +11,7 @@ inherit autotools-brokensep deploy | |||
| 11 | SRCREV = "be92da280d87c38a2e0adc5d3f43bab7b5468f09" | 11 | SRCREV = "be92da280d87c38a2e0adc5d3f43bab7b5468f09" |
| 12 | SRC_URI = "git://github.com/riscv/opensbi.git \ | 12 | SRC_URI = "git://github.com/riscv/opensbi.git \ |
| 13 | file://0001-Makefile-Don-t-specify-mabi-or-march.patch \ | 13 | file://0001-Makefile-Don-t-specify-mabi-or-march.patch \ |
| 14 | file://0001-build-Use-ffreestanding.patch \ | ||
| 14 | " | 15 | " |
| 15 | 16 | ||
| 16 | S = "${WORKDIR}/git" | 17 | S = "${WORKDIR}/git" |
