opensbi: Use -ffree-standing compiler options
PATCH 1/1 opensbi: Use -ffree-standing 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
--- ...Makefile-Don-t-specify-mabi-or-march.patch | 9 ++---- .../files/0001-build-Use-ffreestanding.patch | 28 +++++++++++++++++++ meta/recipes-bsp/opensbi/opensbi_0.5.bb | 1 + 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patch
meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch +2 -7
@@ -13,11 +13,9 @@ Signed-off-by: Alistair Francis <[email protected]> Makefile | 2 -- 1 file changed, 2 deletions(-) -diff --git a/Makefile b/Makefile -index ae68f55..10851fc 100644 --- a/Makefile +++ b/Makefile -@@ -145,7 +145,6 @@ GENFLAGS += $(firmware-genflags-y) +@@ -162,7 +162,6 @@ GENFLAGS += $(firmware-genflags-y) CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls CFLAGS += -mno-save-restore -mstrict-align
@@ -25,7 +23,7 @@ index ae68f55..10851fc 100644 CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) CFLAGS += $(GENFLAGS) CFLAGS += $(platform-cflags-y) -@@ -158,7 +157,6 @@ CPPFLAGS += $(firmware-cppflags-y) +@@ -176,7 +175,6 @@ CPPFLAGS += $(firmware-cppflags-y) ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__ ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls ASFLAGS += -mno-save-restore -mstrict-align
@@ -33,6 +31,3 @@ index ae68f55..10851fc 100644 ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) ASFLAGS += $(GENFLAGS) ASFLAGS += $(platform-asflags-y) --- -2.20.1 -
meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patch new file +28 -0
@@ -0,0 +1,28 @@ +From efa39afecedf75a1f3154c39507bdde2810bc140 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 6 Jan 2020 18:21:02 -0800 +Subject: [PATCH] build: Use -ffreestanding + +this is a stand-alone/baremetal application, therefore demanding +-ffreestanding would help it compile with hosted toolchains e.g. ( linux +toolchains ), it also ensures that it won't be using platform +optimizations like inlining mem* str* functions which gcc might decide +especially with wrapper string functions in opensbi code + +Upstream-Status: Submitted [https://lists.infradead.org/pipermail/opensbi/2020-January/000887.html] +Signed-off-by: Khem Raj <[email protected]> +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/Makefile ++++ b/Makefile +@@ -159,7 +159,7 @@ GENFLAGS += $(libsbiutils-genflags-y) + GENFLAGS += $(platform-genflags-y) + GENFLAGS += $(firmware-genflags-y) + +-CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 ++CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2 + CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls + CFLAGS += -mno-save-restore -mstrict-align + CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
meta/recipes-bsp/opensbi/opensbi_0.5.bb +1 -0
@@ -11,6 +11,7 @@ inherit autotools-brokensep deploy SRCREV = "be92da280d87c38a2e0adc5d3f43bab7b5468f09" SRC_URI = "git://github.com/riscv/opensbi.git \ file://0001-Makefile-Don-t-specify-mabi-or-march.patch \ + file://0001-build-Use-ffreestanding.patch \ " S = "${WORKDIR}/git"
Signature · 1 line
2.24.1
PATCH 1/1 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
--- ...Makefile-Don-t-specify-mabi-or-march.patch | 9 ++---- .../files/0001-build-Use-ffreestanding.patch | 28 +++++++++++++++++++ meta/recipes-bsp/opensbi/opensbi_0.5.bb | 1 + 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patch
meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch +2 -7
@@ -13,11 +13,9 @@ Signed-off-by: Alistair Francis <[email protected]> Makefile | 2 -- 1 file changed, 2 deletions(-) -diff --git a/Makefile b/Makefile -index ae68f55..10851fc 100644 --- a/Makefile +++ b/Makefile -@@ -145,7 +145,6 @@ GENFLAGS += $(firmware-genflags-y) +@@ -162,7 +162,6 @@ GENFLAGS += $(firmware-genflags-y) CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls CFLAGS += -mno-save-restore -mstrict-align
@@ -25,7 +23,7 @@ index ae68f55..10851fc 100644 CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) CFLAGS += $(GENFLAGS) CFLAGS += $(platform-cflags-y) -@@ -158,7 +157,6 @@ CPPFLAGS += $(firmware-cppflags-y) +@@ -176,7 +175,6 @@ CPPFLAGS += $(firmware-cppflags-y) ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__ ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls ASFLAGS += -mno-save-restore -mstrict-align
@@ -33,6 +31,3 @@ index ae68f55..10851fc 100644 ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) ASFLAGS += $(GENFLAGS) ASFLAGS += $(platform-asflags-y) --- -2.20.1 -
meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patch new file +28 -0
@@ -0,0 +1,28 @@ +From efa39afecedf75a1f3154c39507bdde2810bc140 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 6 Jan 2020 18:21:02 -0800 +Subject: [PATCH] build: Use -ffreestanding + +this is a stand-alone/baremetal application, therefore demanding +-ffreestanding would help it compile with hosted toolchains e.g. ( linux +toolchains ), it also ensures that it won't be using platform +optimizations like inlining mem* str* functions which gcc might decide +especially with wrapper string functions in opensbi code + +Upstream-Status: Submitted [https://lists.infradead.org/pipermail/opensbi/2020-January/000887.html] +Signed-off-by: Khem Raj <[email protected]> +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/Makefile ++++ b/Makefile +@@ -159,7 +159,7 @@ GENFLAGS += $(libsbiutils-genflags-y) + GENFLAGS += $(platform-genflags-y) + GENFLAGS += $(firmware-genflags-y) + +-CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 ++CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2 + CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls + CFLAGS += -mno-save-restore -mstrict-align + CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
meta/recipes-bsp/opensbi/opensbi_0.5.bb +1 -0
@@ -11,6 +11,7 @@ inherit autotools-brokensep deploy SRCREV = "be92da280d87c38a2e0adc5d3f43bab7b5468f09" SRC_URI = "git://github.com/riscv/opensbi.git \ file://0001-Makefile-Don-t-specify-mabi-or-march.patch \ + file://0001-build-Use-ffreestanding.patch \ " S = "${WORKDIR}/git"
Signature · 1 line
2.24.1
Accidentally sent ignore this one. Use the other patch.
Quoted 103 lines · Khem Raj
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 statusSigned-off-by Khem Raj <[email protected]>--- ...Makefile-Don-t-specify-mabi-or-march.patch | 9 ++---- .../files/0001-build-Use-ffreestanding.patch | 28 +++++++++++++++++++ meta/recipes-bsp/opensbi/opensbi_0.5.bb | 1 + 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patchmeta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch +2
-7@@ -13,11 +13,9 @@ Signed-off-by: Alistair Francis <[email protected]> Makefile | 2 -- 1 file changed, 2 deletions(-) -diff --git a/Makefile b/Makefile -index ae68f55..10851fc 100644 --- a/Makefile +++ b/Makefile -@@ -145,7 +145,6 @@ GENFLAGS += $(firmware-genflags-y) +@@ -162,7 +162,6 @@ GENFLAGS += $(firmware-genflags-y) CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls CFLAGS += -mno-save-restore -mstrict-align@@ -25,7 +23,7 @@ index ae68f55..10851fc 100644 CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) CFLAGS += $(GENFLAGS) CFLAGS += $(platform-cflags-y) -@@ -158,7 +157,6 @@ CPPFLAGS += $(firmware-cppflags-y) +@@ -176,7 +175,6 @@ CPPFLAGS += $(firmware-cppflags-y) ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__ ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls ASFLAGS += -mno-save-restore -mstrict-align@@ -33,6 +31,3 @@ index ae68f55..10851fc 100644 ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) ASFLAGS += $(GENFLAGS) ASFLAGS += $(platform-asflags-y) --- -2.20.1 -meta/recipes-bsp/opensbi/files/0001-build-Use-ffreestanding.patch new file +28
-0@@ -0,0 +1,28 @@ +From efa39afecedf75a1f3154c39507bdde2810bc140 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 6 Jan 2020 18:21:02 -0800 +Subject: [PATCH] build: Use -ffreestanding + +this is a stand-alone/baremetal application, therefore demanding +-ffreestanding would help it compile with hosted toolchains e.g. ( linux +toolchains ), it also ensures that it won't be using platform +optimizations like inlining mem* str* functions which gcc might decide +especially with wrapper string functions in opensbi code + +Upstream-Status: Submitted [https://lists.infradead.org/pipermail/opensbi/2020-January/000887.html] +Signed-off-by: Khem Raj <[email protected]> +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/Makefile ++++ b/Makefile +@@ -159,7 +159,7 @@ GENFLAGS += $(libsbiutils-genflags-y) + GENFLAGS += $(platform-genflags-y) + GENFLAGS += $(firmware-genflags-y) + +-CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 ++CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2 + CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls + CFLAGS += -mno-save-restore -mstrict-align + CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)meta/recipes-bsp/opensbi/opensbi_0.5.bb +1
-1@@ -11,6 +11,7 @@ inherit autotools-brokensep deploy SRCREV = "be92da280d87c38a2e0adc5d3f43bab7b5468f09" SRC_URI = "git://github.com/riscv/opensbi.git \ file://0001-Makefile-Don-t-specify-mabi-or-march.patch \ + file://0001-build-Use-ffreestanding.patch \ " S = "${WORKDIR}/git" --2.24.1