diff mbox series

Makefile: Don't specify mabi or march

Message ID 20201019224108.99481-1-alistair.francis@wdc.com
State Superseded
Headers show
Series Makefile: Don't specify mabi or march | expand

Commit Message

Alistair Francis Oct. 19, 2020, 10:41 p.m. UTC
To avoid
    can't link double-float modules with soft-float modules
errors when building 32-bit openSBI don't specify mabi or march.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 Makefile | 2 --
 1 file changed, 2 deletions(-)

Comments

Jessica Clarke Oct. 19, 2020, 10:56 p.m. UTC | #1
On 19 Oct 2020, at 23:41, Alistair Francis <alistair.francis@wdc.com> wrote:
> 
> To avoid
>    can't link double-float modules with soft-float modules
> errors when building 32-bit openSBI don't specify mabi or march.

What happens if you want to build for a different ABI or ISA string
deliberately? Especially with something like Clang where every compiler
is a cross-compiler. Users should be able to specify an ABI or ISA
string if they want and have it honoured, either via
PLATFORM_RISCV_ABI/ISA or by using += for CFLAGS everywhere rather than
overwriting it entirely (which is the more standard thing to do for
software that isn't RISC-V-specific).

Jess

> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
> Makefile | 2 --
> 1 file changed, 2 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index a231881..3f819d9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -196,7 +196,6 @@ GENFLAGS	+=	$(firmware-genflags-y)
> 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		+=	-mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
> CFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
> CFLAGS		+=	$(GENFLAGS)
> CFLAGS		+=	$(platform-cflags-y)
> @@ -210,7 +209,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
> -ASFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
> ASFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
> ASFLAGS		+=	$(GENFLAGS)
> ASFLAGS		+=	$(platform-asflags-y)
> -- 
> 2.28.0
> 
> 
> -- 
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
Alistair Francis Oct. 19, 2020, 11:02 p.m. UTC | #2
On Mon, 2020-10-19 at 23:56 +0100, Jessica Clarke wrote:
> On 19 Oct 2020, at 23:41, Alistair Francis <alistair.francis@wdc.com>
> wrote:
> > To avoid
> >    can't link double-float modules with soft-float modules
> > errors when building 32-bit openSBI don't specify mabi or march.
> 
> What happens if you want to build for a different ABI or ISA string
> deliberately? Especially with something like Clang where every
> compiler
> is a cross-compiler. Users should be able to specify an ABI or ISA
> string if they want and have it honoured, either via
> PLATFORM_RISCV_ABI/ISA or by using += for CFLAGS everywhere rather
> than
> overwriting it entirely (which is the more standard thing to do for
> software that isn't RISC-V-specific).

A user could do that by specifying their own CFLAGS when building to
allow them to specify a ISA or ABI.

Currently no platform set PLATFORM_RISCV_ABI as it defaults to ilp32 or
lp64.

No platform also sets PLATFORM_RISCV_ISA which is always rv32/64imafdc.

Alistair

> 
> Jess
> 
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > ---
> > Makefile | 2 --
> > 1 file changed, 2 deletions(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index a231881..3f819d9 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -196,7 +196,6 @@ GENFLAGS	+=	$(firmware-genflags-y)
> > 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		+=	-mabi=$(PLATFORM_RISCV_ABI)
> > -march=$(PLATFORM_RISCV_ISA)
> > CFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
> > CFLAGS		+=	$(GENFLAGS)
> > CFLAGS		+=	$(platform-cflags-y)
> > @@ -210,7 +209,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
> > -ASFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI)
> > -march=$(PLATFORM_RISCV_ISA)
> > ASFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
> > ASFLAGS		+=	$(GENFLAGS)
> > ASFLAGS		+=	$(platform-asflags-y)
> > -- 
> > 2.28.0
> > 
> > 
> > -- 
> > opensbi mailing list
> > opensbi@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/opensbi
Jessica Clarke Oct. 19, 2020, 11:05 p.m. UTC | #3
On 20 Oct 2020, at 00:02, Alistair Francis <alistair.francis@wdc.com> wrote:
> 
> On Mon, 2020-10-19 at 23:56 +0100, Jessica Clarke wrote:
>> On 19 Oct 2020, at 23:41, Alistair Francis <alistair.francis@wdc.com>
>> wrote:
>>> To avoid
>>>   can't link double-float modules with soft-float modules
>>> errors when building 32-bit openSBI don't specify mabi or march.
>> 
>> What happens if you want to build for a different ABI or ISA string
>> deliberately? Especially with something like Clang where every
>> compiler
>> is a cross-compiler. Users should be able to specify an ABI or ISA
>> string if they want and have it honoured, either via
>> PLATFORM_RISCV_ABI/ISA or by using += for CFLAGS everywhere rather
>> than
>> overwriting it entirely (which is the more standard thing to do for
>> software that isn't RISC-V-specific).
> 
> A user could do that by specifying their own CFLAGS when building to
> allow them to specify a ISA or ABI.

Makefile:196:CFLAGS		=	-g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2

That doesn't work so well with user-supplied CFLAGS.

> Currently no platform set PLATFORM_RISCV_ABI as it defaults to ilp32 or
> lp64.

We do. We have new ABIs for our extension (see cheri-cpu.org).

> No platform also sets PLATFORM_RISCV_ISA which is always rv32/64imafdc.

We do.

Jess

>>> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
>>> ---
>>> Makefile | 2 --
>>> 1 file changed, 2 deletions(-)
>>> 
>>> diff --git a/Makefile b/Makefile
>>> index a231881..3f819d9 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -196,7 +196,6 @@ GENFLAGS	+=	$(firmware-genflags-y)
>>> 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		+=	-mabi=$(PLATFORM_RISCV_ABI)
>>> -march=$(PLATFORM_RISCV_ISA)
>>> CFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
>>> CFLAGS		+=	$(GENFLAGS)
>>> CFLAGS		+=	$(platform-cflags-y)
>>> @@ -210,7 +209,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
>>> -ASFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI)
>>> -march=$(PLATFORM_RISCV_ISA)
>>> ASFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
>>> ASFLAGS		+=	$(GENFLAGS)
>>> ASFLAGS		+=	$(platform-asflags-y)
>>> -- 
>>> 2.28.0
>>> 
>>> 
>>> -- 
>>> opensbi mailing list
>>> opensbi@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/opensbi
Alistair Francis Oct. 19, 2020, 11:32 p.m. UTC | #4
On Tue, 2020-10-20 at 00:05 +0100, Jessica Clarke wrote:
> On 20 Oct 2020, at 00:02, Alistair Francis <alistair.francis@wdc.com>
> wrote:
> > On Mon, 2020-10-19 at 23:56 +0100, Jessica Clarke wrote:
> > > On 19 Oct 2020, at 23:41, Alistair Francis <
> > > alistair.francis@wdc.com>
> > > wrote:
> > > > To avoid
> > > >   can't link double-float modules with soft-float modules
> > > > errors when building 32-bit openSBI don't specify mabi or
> > > > march.
> > > 
> > > What happens if you want to build for a different ABI or ISA
> > > string
> > > deliberately? Especially with something like Clang where every
> > > compiler
> > > is a cross-compiler. Users should be able to specify an ABI or
> > > ISA
> > > string if they want and have it honoured, either via
> > > PLATFORM_RISCV_ABI/ISA or by using += for CFLAGS everywhere
> > > rather
> > > than
> > > overwriting it entirely (which is the more standard thing to do
> > > for
> > > software that isn't RISC-V-specific).
> > 
> > A user could do that by specifying their own CFLAGS when building
> > to
> > allow them to specify a ISA or ABI.
> 
> Makefile:196:CFLAGS		=	-g -Wall -Werror -ffreestanding
> -nostdlib -fno-strict-aliasing -O2

Ah, I didn't realise this. I'll change it to a +=

> 
> That doesn't work so well with user-supplied CFLAGS.
> 
> > Currently no platform set PLATFORM_RISCV_ABI as it defaults to
> > ilp32 or
> > lp64.
> 
> We do. We have new ABIs for our extension (see cheri-cpu.org).

Ah ok. Maybe it's worth upstreamign the cheri implementaiton then?

Alistair

> 
> > No platform also sets PLATFORM_RISCV_ISA which is always
> > rv32/64imafdc.
> 
> We do.
> 
> Jess
> 
> > > > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > > > ---
> > > > Makefile | 2 --
> > > > 1 file changed, 2 deletions(-)
> > > > 
> > > > diff --git a/Makefile b/Makefile
> > > > index a231881..3f819d9 100644
> > > > --- a/Makefile
> > > > +++ b/Makefile
> > > > @@ -196,7 +196,6 @@ GENFLAGS	+=	$(firmware-genflags-y)
> > > > 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		+=	-mabi=$(PLATFORM_RISCV_ABI)
> > > > -march=$(PLATFORM_RISCV_ISA)
> > > > CFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
> > > > CFLAGS		+=	$(GENFLAGS)
> > > > CFLAGS		+=	$(platform-cflags-y)
> > > > @@ -210,7 +209,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
> > > > -ASFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI)
> > > > -march=$(PLATFORM_RISCV_ISA)
> > > > ASFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
> > > > ASFLAGS		+=	$(GENFLAGS)
> > > > ASFLAGS		+=	$(platform-asflags-y)
> > > > -- 
> > > > 2.28.0
> > > > 
> > > > 
> > > > -- 
> > > > opensbi mailing list
> > > > opensbi@lists.infradead.org
> > > > http://lists.infradead.org/mailman/listinfo/opensbi
Jessica Clarke Oct. 19, 2020, 11:38 p.m. UTC | #5
On 20 Oct 2020, at 00:32, Alistair Francis <Alistair.Francis@wdc.com> wrote:
> On Tue, 2020-10-20 at 00:05 +0100, Jessica Clarke wrote:
>> On 20 Oct 2020, at 00:02, Alistair Francis <alistair.francis@wdc.com>
>> wrote:
>>> On Mon, 2020-10-19 at 23:56 +0100, Jessica Clarke wrote:
>>>> On 19 Oct 2020, at 23:41, Alistair Francis <
>>>> alistair.francis@wdc.com>
>>>> wrote:
>>>>> To avoid
>>>>>  can't link double-float modules with soft-float modules
>>>>> errors when building 32-bit openSBI don't specify mabi or
>>>>> march.
>>>> 
>>>> What happens if you want to build for a different ABI or ISA
>>>> string
>>>> deliberately? Especially with something like Clang where every
>>>> compiler
>>>> is a cross-compiler. Users should be able to specify an ABI or
>>>> ISA
>>>> string if they want and have it honoured, either via
>>>> PLATFORM_RISCV_ABI/ISA or by using += for CFLAGS everywhere
>>>> rather
>>>> than
>>>> overwriting it entirely (which is the more standard thing to do
>>>> for
>>>> software that isn't RISC-V-specific).
>>> 
>>> A user could do that by specifying their own CFLAGS when building
>>> to
>>> allow them to specify a ISA or ABI.
>> 
>> Makefile:196:CFLAGS		=	-g -Wall -Werror -ffreestanding
>> -nostdlib -fno-strict-aliasing -O2
> 
> Ah, I didn't realise this. I'll change it to a +=

Thanks. Same goes for AFLAGS, and I didn't check LDFLAGS etc.

>> That doesn't work so well with user-supplied CFLAGS.
>> 
>>> Currently no platform set PLATFORM_RISCV_ABI as it defaults to
>>> ilp32 or
>>> lp64.
>> 
>> We do. We have new ABIs for our extension (see cheri-cpu.org).
> 
> Ah ok. Maybe it's worth upstreamign the cheri implementaiton then?

We never really finished it properly and have been stuck on BBL. Well,
in theory it works, but it just hasn't seen the same amount of testing
as it's not in day-to-day use. I don't think it makes much sense to
upstream the very CHERI-specific bits (instructions, configuration,
etc) since it's ultimately a research architecture for now and we do
want to be able to make breaking changes, but there may well be things
we can upstream that make our fork's diff smaller (the nature of the
architecture and software model means that we routinely find
integer/pointer confusion in projects and can upstream many of our
diffs as simple code quality improvements to use the right type). I do
know it required substantially less hacking than BBL though to get
something that booted, especially in the build system.

Jess
Anup Patel Oct. 20, 2020, 3:52 a.m. UTC | #6
On Tue, Oct 20, 2020 at 4:22 AM Alistair Francis
<alistair.francis@wdc.com> wrote:
>
> To avoid
>     can't link double-float modules with soft-float modules
> errors when building 32-bit openSBI don't specify mabi or march.

We have a lot of users (including me) who use multilib toolchain to compile
OpenSBI for desired mabi and march. In fact, I have one common toolchain
for ilp32, ilp32d, lp64, and lp64d.

By removing "-mabi" and "-march", we are enforcing users to depend on
default mabi and march of toolchain. This means we can't use multilib
toolchain for OpenSBI.

I would suggest to add a separate makefile option (e.g.
PLATFORM_USE_TOOLCHAIN_MABI, PLATFORM_USE_TOOLCHAIN_MARCH)
which when enabled will skip specifying "-mabi" and "-march" in various
compiler/assembler/linker flags.

Regards,
Anup

>
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
>  Makefile | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index a231881..3f819d9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -196,7 +196,6 @@ GENFLAGS    +=      $(firmware-genflags-y)
>  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         +=      -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
>  CFLAGS         +=      -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
>  CFLAGS         +=      $(GENFLAGS)
>  CFLAGS         +=      $(platform-cflags-y)
> @@ -210,7 +209,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
> -ASFLAGS                +=      -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
>  ASFLAGS                +=      -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
>  ASFLAGS                +=      $(GENFLAGS)
>  ASFLAGS                +=      $(platform-asflags-y)
> --
> 2.28.0
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel Oct. 20, 2020, 4:33 a.m. UTC | #7
On Tue, Oct 20, 2020 at 9:22 AM Anup Patel <anup@brainfault.org> wrote:
>
> On Tue, Oct 20, 2020 at 4:22 AM Alistair Francis
> <alistair.francis@wdc.com> wrote:
> >
> > To avoid
> >     can't link double-float modules with soft-float modules
> > errors when building 32-bit openSBI don't specify mabi or march.
>
> We have a lot of users (including me) who use multilib toolchain to compile
> OpenSBI for desired mabi and march. In fact, I have one common toolchain
> for ilp32, ilp32d, lp64, and lp64d.
>
> By removing "-mabi" and "-march", we are enforcing users to depend on
> default mabi and march of toolchain. This means we can't use multilib
> toolchain for OpenSBI.
>
> I would suggest to add a separate makefile option (e.g.
> PLATFORM_USE_TOOLCHAIN_MABI, PLATFORM_USE_TOOLCHAIN_MARCH)
> which when enabled will skip specifying "-mabi" and "-march" in various
> compiler/assembler/linker flags.

Here's a change which will work for your case as well as with multilib
toolchains:


diff --git a/Makefile b/Makefile
index a231881..dd5f4ce 100644
--- a/Makefile
+++ b/Makefile
@@ -94,6 +94,8 @@ DTC           =       dtc

 # Guess the compillers xlen
 OPENSBI_CC_XLEN := $(shell TMP=`$(CC) -dumpmachine | sed
's/riscv\([0-9][0-9]\).*/\1/'`; echo $${TMP})
+OPENSBI_CC_ABI := $(shell TMP=`$(CC) -v 2>&1 | sed -n
's/.*\(with\-abi=\([a-zA-Z0-9]*\)\).*/\2/p'`; echo $${TMP})
+OPENSBI_CC_ISA := $(shell TMP=`$(CC) -v 2>&1 | sed -n
's/.*\(with\-arch=\([a-zA-Z0-9]*\)\).*/\2/p'`; echo $${TMP})

 # Setup platform XLEN
 ifndef PLATFORM_RISCV_XLEN
@@ -143,14 +145,22 @@ deps-y+=$(firmware-objs-path-y:.o=.dep)

 # Setup platform ABI, ISA and Code Model
 ifndef PLATFORM_RISCV_ABI
-  ifeq ($(PLATFORM_RISCV_XLEN), 32)
-    PLATFORM_RISCV_ABI = ilp$(PLATFORM_RISCV_XLEN)
+  ifndef PLATFORM_USE_TOOLCHAIN_ABI
+    ifeq ($(PLATFORM_RISCV_XLEN), 32)
+      PLATFORM_RISCV_ABI = ilp$(PLATFORM_RISCV_XLEN)
+    else
+      PLATFORM_RISCV_ABI = lp$(PLATFORM_RISCV_XLEN)
+    endif
   else
-    PLATFORM_RISCV_ABI = lp$(PLATFORM_RISCV_XLEN)
+    PLATFORM_RISCV_ABI = $(OPENSBI_CC_ABI)
   endif
 endif
 ifndef PLATFORM_RISCV_ISA
-  PLATFORM_RISCV_ISA = rv$(PLATFORM_RISCV_XLEN)imafdc
+  ifndef PLATFORM_USE_TOOLCHAIN_ISA
+    PLATFORM_RISCV_ISA = rv$(PLATFORM_RISCV_XLEN)imafdc
+  else
+    PLATFORM_RISCV_ISA = $(OPENSBI_CC_ISA)
+  endif
 endif
 ifndef PLATFORM_RISCV_CODE_MODEL
   PLATFORM_RISCV_CODE_MODEL = medany


Regards,
Anup

>
> Regards,
> Anup
>
> >
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > ---
> >  Makefile | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index a231881..3f819d9 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -196,7 +196,6 @@ GENFLAGS    +=      $(firmware-genflags-y)
> >  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         +=      -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
> >  CFLAGS         +=      -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
> >  CFLAGS         +=      $(GENFLAGS)
> >  CFLAGS         +=      $(platform-cflags-y)
> > @@ -210,7 +209,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
> > -ASFLAGS                +=      -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
> >  ASFLAGS                +=      -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
> >  ASFLAGS                +=      $(GENFLAGS)
> >  ASFLAGS                +=      $(platform-asflags-y)
> > --
> > 2.28.0
> >
> >
> > --
> > opensbi mailing list
> > opensbi@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/opensbi
Andreas Schwab Oct. 20, 2020, 7:27 a.m. UTC | #8
On Okt 19 2020, Alistair Francis wrote:

> On Tue, 2020-10-20 at 00:05 +0100, Jessica Clarke wrote:
>> Makefile:196:CFLAGS		=	-g -Wall -Werror -ffreestanding
>> -nostdlib -fno-strict-aliasing -O2
>
> Ah, I didn't realise this. I'll change it to a +=

That won't work with `make CFLAGS=foo'.

Andreas.
Andreas Schwab Oct. 20, 2020, 7:30 a.m. UTC | #9
On Okt 19 2020, Alistair Francis wrote:

> To avoid
>     can't link double-float modules with soft-float modules
> errors when building 32-bit openSBI don't specify mabi or march.

What version of binutils are you using?

Andreas.
Alistair Francis Oct. 21, 2020, 12:53 a.m. UTC | #10
On Tue, 2020-10-20 at 09:30 +0200, Andreas Schwab wrote:
> On Okt 19 2020, Alistair Francis wrote:
> 
> > To avoid
> >     can't link double-float modules with soft-float modules
> > errors when building 32-bit openSBI don't specify mabi or march.
> 
> What version of binutils are you using?

I'm using 2.35.

Alistair

> 
> Andreas.
>
Alistair Francis Oct. 21, 2020, 12:55 a.m. UTC | #11
On Tue, 2020-10-20 at 00:38 +0100, Jessica Clarke wrote:
> On 20 Oct 2020, at 00:32, Alistair Francis <Alistair.Francis@wdc.com>
> wrote:
> > On Tue, 2020-10-20 at 00:05 +0100, Jessica Clarke wrote:
> > > On 20 Oct 2020, at 00:02, Alistair Francis <
> > > alistair.francis@wdc.com>
> > > wrote:
> > > > On Mon, 2020-10-19 at 23:56 +0100, Jessica Clarke wrote:
> > > > > On 19 Oct 2020, at 23:41, Alistair Francis <
> > > > > alistair.francis@wdc.com>
> > > > > wrote:
> > > > > > To avoid
> > > > > >  can't link double-float modules with soft-float modules
> > > > > > errors when building 32-bit openSBI don't specify mabi or
> > > > > > march.
> > > > > 
> > > > > What happens if you want to build for a different ABI or ISA
> > > > > string
> > > > > deliberately? Especially with something like Clang where
> > > > > every
> > > > > compiler
> > > > > is a cross-compiler. Users should be able to specify an ABI
> > > > > or
> > > > > ISA
> > > > > string if they want and have it honoured, either via
> > > > > PLATFORM_RISCV_ABI/ISA or by using += for CFLAGS everywhere
> > > > > rather
> > > > > than
> > > > > overwriting it entirely (which is the more standard thing to
> > > > > do
> > > > > for
> > > > > software that isn't RISC-V-specific).
> > > > 
> > > > A user could do that by specifying their own CFLAGS when
> > > > building
> > > > to
> > > > allow them to specify a ISA or ABI.
> > > 
> > > Makefile:196:CFLAGS		=	-g -Wall -Werror
> > > -ffreestanding
> > > -nostdlib -fno-strict-aliasing -O2
> > 
> > Ah, I didn't realise this. I'll change it to a +=
> 
> Thanks. Same goes for AFLAGS, and I didn't check LDFLAGS etc.
> 
> > > That doesn't work so well with user-supplied CFLAGS.
> > > 
> > > > Currently no platform set PLATFORM_RISCV_ABI as it defaults to
> > > > ilp32 or
> > > > lp64.
> > > 
> > > We do. We have new ABIs for our extension (see cheri-cpu.org).
> > 
> > Ah ok. Maybe it's worth upstreamign the cheri implementaiton then?
> 
> We never really finished it properly and have been stuck on BBL. 

That is annoying.

> Well,
> in theory it works, but it just hasn't seen the same amount of
> testing
> as it's not in day-to-day use. I don't think it makes much sense to
> upstream the very CHERI-specific bits (instructions, configuration,
> etc) since it's ultimately a research architecture for now and we do
> want to be able to make breaking changes, but there may well be 

Agreed, but I'm sure at least some of it could be upstreamed. That
helps us at least build test other platforms.

> things
> we can upstream that make our fork's diff smaller (the nature of the
> architecture and software model means that we routinely find
> integer/pointer confusion in projects and can upstream many of our
> diffs as simple code quality improvements to use the right type). I 

That would be great!

> do
> know it required substantially less hacking than BBL though to get
> something that booted, especially in the build system.

I'm glad to hear that :)

Alistair

> 
> Jess
>
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index a231881..3f819d9 100644
--- a/Makefile
+++ b/Makefile
@@ -196,7 +196,6 @@  GENFLAGS	+=	$(firmware-genflags-y)
 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		+=	-mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
 CFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
 CFLAGS		+=	$(GENFLAGS)
 CFLAGS		+=	$(platform-cflags-y)
@@ -210,7 +209,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
-ASFLAGS		+=	-mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
 ASFLAGS		+=	-mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
 ASFLAGS		+=	$(GENFLAGS)
 ASFLAGS		+=	$(platform-asflags-y)