Re: [PATCH] icpp remedy

2022-09-14 Thread Gedare Bloom
On Tue, Sep 13, 2022 at 12:42 PM Kuan-Hsun Chen  wrote:
>
> Thanks for the prompt reply. Yes, I will guide Junjie to make a ticket and go 
> through the issue.
>
> >Is there a test case for this?
> Yes, a test case is also ready to be reviewed and can be part of the 
> testsuite to test out ICPP (MrsP should also pass).
>
> > If it applies to 5 or 4.11, there needs to be another ticket to get the fix 
> > back ported.
> So each release version with one ticket? We only check 5.1 in this work. My 
> intuitive guess is that if the functionality does not change over the 
> versions, the remedy should be similar.
> Let us figure it out.
>
> On Tue, Sep 13, 2022 at 8:21 PM Joel Sherrill  wrote:
>>
>>
>>
>> On Tue, Sep 13, 2022, 1:14 PM Kuan-Hsun Chen  wrote:
>>>
>>> (Oh, I just noticed that the patch was submitted faster than my mail to 
>>> share this patch :P).
>>
>>
>> No problem. That's why I asked what the issue was.
>>
>> It needs at least a much better log message. It needs a ticket given the 
>> gravity of the issue. That ticket can explain the situation and include 
>> links. Probably needs a comment above the change explaining what's going on.
>>
>> Is there a test case for this?
>>
>> If it applies to 5 or 4.11, there needs to be another ticket to get the fix 
>> back ported.
>>
>> Great catch. Just need to do a good job on the log, test, ticket(s), etc
>>
>> --joel
>>
>>>
>>> Hi Joel,
>>>
>>> Let me clarify what happened here. In our recent study, we adopt Frama-C to 
>>> formally verify the implementation of ICPP (also MrsP) and note that the 
>>> current flow may lead to a deadlock. The patch is a simple remedy to fix 
>>> the issue.
>>>
>>> The resource’s ceiling is not checked against the thread’s base priority, 
>>> but against its current dynamic priority derived from the task’s priority 
>>> aggregation. However, a resource’s ceiling is required to be set as the 
>>> highest base priority of all tasks that are requesting it. This mismatch 
>>> may lead to a deadlock by denying legitimate nested resource access if 
>>> resources are requested in descending order of priority. So this adaption 
>>> is needed to resolve the issue. A similar issue can also be found in MrsP 
>>> due to the usage of this function. A detailed explanation can be found at 
>>> the end of Section V in the attached preprint, and a toy example is 
>>> provided there to reveal the issue.
>>>

By changing this to check the base priority instead of the dynamic
priority, the mutex seize will now allow a task to acquire a ceiling
mutex even though its dynamic priority is higher than the ceiling. The
specification to check against the base priority of tasks comes from
the ICPP without nested lock behavior as I recall, and I'm not 100%
sure where the requirement comes from that "a resource’s ceiling is
required to be set as the highest base priority of all tasks that are
requesting it" -- is that requirement proved anywhere for ICPP with
nested resources? I'm a little concerned about making this kind of
fundamental change deep within the (shared) locking protocol code,
especially since it primarily seems to cater to a uniprocessor corner
case.

This is a tricky situation, and clearly a lot of work has already gone
into discovering it. I think we need to discuss this patch a bit more.
If I understood correctly, this deadlock can't happen if locks are
always acquired in the increasing priority order. Changing this code
allows for applications to acquire locks in arbitrary priority order.
I'm not sure that is permissible in multiprocessor systems to still
ensure correctness of the locking protocol correctness. It would be
therefore also valid to state this as an explicit requirement for
applications to make correct use of ICPP. The same thing is also true
for MrsP, and for multiprocessor locking protocols in general I
believe it is required for locks to be acquired in priority order? I'd
be inclined to instead say that we should confirm that locks are
acquired in the proper priority ordering as a way to avoid the
identified deadlock situation.

Either way this discussion/patch goes, we should document these issues
in 
https://docs.rtems.org/branches/master/c-user/key_concepts.html#priorityceiling

>>> The verification framework will be presented in EMSOFT this year, which is 
>>> publicly available here: 
>>> https://github.com/tu-dortmund-ls12-rt/Resource-Synchronization-Protocols-Verification-RTEMS

Congrats on the paper. I'll read through it more thoroughly later. For
now I focused only on the outcome of the verification (Section V) and
the discussion of the ICPP / MrsP concerns.

>>> *I notice that Andrew today also sent a patch for a chapter on formal 
>>> verification. Since our result is relevant, I plan to respond to the 
>>> previous thread 
>>> (https://lists.rtems.org/pipermail/devel/2022-July/072167.html).
>>>

Thanks. It's great to see some kind of community forming around this.
I wonder if it would make sense to look 

Re: [PATCH 3/3] devel/gcc: Check and build GNU sed if not available on build host

2022-09-14 Thread Chris Johns
On 14/9/2022 11:31 pm, Joel Sherrill wrote:
> OK. Hopefully this fixes the MIPS issues.

It does on FreeBSD 13.1.

Thanks
Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 3/3] devel/gcc: Check and build GNU sed if not available on build host

2022-09-14 Thread Joel Sherrill
OK. Hopefully this fixes the MIPS issues.

On Wed, Sep 14, 2022 at 2:02 AM  wrote:

> From: Chris Johns 
>
> Closes #2300
> ---
>  bare/config/devel/gnu-default-tools.bset| 6 ++
>  rtems/config/tools/rtems-default-tools.bset | 5 +
>  source-builder/config/gcc-common-1.cfg  | 4 
>  3 files changed, 15 insertions(+)
>
> diff --git a/bare/config/devel/gnu-default-tools.bset
> b/bare/config/devel/gnu-default-tools.bset
> index dab8c5e..f038352 100644
> --- a/bare/config/devel/gnu-default-tools.bset
> +++ b/bare/config/devel/gnu-default-tools.bset
> @@ -6,6 +6,12 @@
>
>  %define gcc_version_message RTEMS bare %{rtems_version}, RSB
> %{_sbgit_id}, Newlib %{newlib_version}
>
> +#
> +# GCC requires a GNU sed so build an internal version if one is not
> +# available
> +#
> +%include textproc/gsed-internal
> +
>  #
>  # Build gdb first to raise the Python install error as early as
>  # possible. GDB needs expat so it needs to be built before gdb.
> diff --git a/rtems/config/tools/rtems-default-tools.bset
> b/rtems/config/tools/rtems-default-tools.bset
> index 7d273cf..8ec6721 100644
> --- a/rtems/config/tools/rtems-default-tools.bset
> +++ b/rtems/config/tools/rtems-default-tools.bset
> @@ -2,6 +2,11 @@
>  # Default tools build
>  #
>
> +# GCC requires a GNU sed so build an internal version if one is not
> +# available
> +#
> +%include textproc/gsed-internal.bset
> +
>  #
>  # Build gdb first to raise the Python install error as early as
>  # possible. GDB needs expat so it needs to be built before gdb.
> diff --git a/source-builder/config/gcc-common-1.cfg
> b/source-builder/config/gcc-common-1.cfg
> index 87ccef1..933202a 100644
> --- a/source-builder/config/gcc-common-1.cfg
> +++ b/source-builder/config/gcc-common-1.cfg
> @@ -165,6 +165,10 @@ URL:  http://gcc.gnu.org/
>  %build
>build_top=$(pwd)
>
> +  %if %{defined _internal_gsed_path}
> +export PATH=%{_internal_gsed_path}/bin:$PATH
> +  %endif
> +
>%{build_directory}
>
>mkdir -p ${build_dir}
> --
> 2.37.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 2/3] textproc/gsed: Add GNU sed build support

2022-09-14 Thread Joel Sherrill
Unfortunately needed on some hosts. OK by me.

On Wed, Sep 14, 2022 at 2:02 AM  wrote:

> From: Chris Johns 
>
> Updates #2300
> ---
>  bare/config/textproc/gsed-4.8.cfg   |  12 +++
>  bare/config/textproc/gsed-internal.bset |  12 +++
>  bare/config/textproc/gsed.bset  |   4 +
>  bare/config/textproc/gsed.cfg   |   8 ++
>  source-builder/config/gsed-1.cfg| 108 
>  5 files changed, 144 insertions(+)
>  create mode 100644 bare/config/textproc/gsed-4.8.cfg
>  create mode 100644 bare/config/textproc/gsed-internal.bset
>  create mode 100644 bare/config/textproc/gsed.bset
>  create mode 100644 bare/config/textproc/gsed.cfg
>  create mode 100644 source-builder/config/gsed-1.cfg
>
> diff --git a/bare/config/textproc/gsed-4.8.cfg
> b/bare/config/textproc/gsed-4.8.cfg
> new file mode 100644
> index 000..8806bef
> --- /dev/null
> +++ b/bare/config/textproc/gsed-4.8.cfg
> @@ -0,0 +1,12 @@
> +#
> +# GNU sed 4.8
> +#
> +
> +%include %{_configdir}/base.cfg
> +
> +%define gsed_version 4.8
> +
> +%hash sha512 sed-%{gsed_version}.tar.gz \
> +
> C94KIhaOMQCwIUKTsTu6CEzM5F/7WGtsV1OPUY52akRDn/vyR4mPK7j1BtBTHTbynAp7cIhJVbqTz8/YhjG/eQ==
> +
> +%include %{_configdir}/gsed-1.cfg
> diff --git a/bare/config/textproc/gsed-internal.bset
> b/bare/config/textproc/gsed-internal.bset
> new file mode 100644
> index 000..e93e1a5
> --- /dev/null
> +++ b/bare/config/textproc/gsed-internal.bset
> @@ -0,0 +1,12 @@
> +#
> +# Internal GNU sed
> +#
> +
> +%define _internal_gsed  yes
> +%define _internal_gsed_path %{_tmppath}/sb-%{_uid}/${SB_PREFIX_CLEAN}
> +%define _disable_collecting yes
> +%define _disable_packaging  yes
> +%define _disable_reporting  yes
> +%define _disable_installing yes
> +
> +%include textproc/gsed.bset
> diff --git a/bare/config/textproc/gsed.bset
> b/bare/config/textproc/gsed.bset
> new file mode 100644
> index 000..68f2e13
> --- /dev/null
> +++ b/bare/config/textproc/gsed.bset
> @@ -0,0 +1,4 @@
> +#
> +# GNU sed
> +#
> +textproc/gsed.cfg
> diff --git a/bare/config/textproc/gsed.cfg b/bare/config/textproc/gsed.cfg
> new file mode 100644
> index 000..8287c74
> --- /dev/null
> +++ b/bare/config/textproc/gsed.cfg
> @@ -0,0 +1,8 @@
> +#
> +# GNU sed has a version option, check for it.
> +# If not found build it.
> +#
> +%define has_gnu_sed %(sed --version > /dev/null 2>&1; echo $?)
> +%if %{has_gnu_sed} != 0
> + %include %{_configdir}/textproc/gsed-4.8.cfg
> +%endif
> diff --git a/source-builder/config/gsed-1.cfg
> b/source-builder/config/gsed-1.cfg
> new file mode 100644
> index 000..828da50
> --- /dev/null
> +++ b/source-builder/config/gsed-1.cfg
> @@ -0,0 +1,108 @@
> +#
> +# GNU sed 1.xx Version 1.
> +#
> +# This configuration file configure's, make's and install's GNU's sed
> +#
> +
> +%if %{release} == %{nil}
> + %define release 1
> +%endif
> +
> +%ifn %{defined _internal_gsed}
> +  %define _internal_gsed no
> +%endif
> +%ifn %{defined _internal_gsed_path}
> +  %define _internal_gsed_path %{_prefix}
> +%endif
> +
> +Name:  gsed-%{gsed_version}-%{_host}-%{release}
> +Summary:   GNU sed v%{gsed_version} for host %{_host}
> +Version:   %{gsed_version}
> +Release:   %{release}
> +URL:  https://www.gnu.org/software/sed/
> +
> +#
> +# Source
> +#
> +%source set gsed https://ftp.gnu.org/gnu/sed/sed-%{gsed_version}.tar.gz
> +
> +#
> +# Remap the install paths if it is an internal build
> +#
> +%if %{_internal_gsed} == yes
> +  %define gsed_prefix %{_internal_gsed_path}
> +%else
> +  %define gsed_prefix %{_prefix}
> +%endif
> +
> +%define gsed_exec_prefix%{gsed_prefix}
> +%define gsed_bindir %{gsed_exec_prefix}/bin
> +%define gsed_sbindir%{gsed_exec_prefix}/sbin
> +%define gsed_libexecdir %{gsed_exec_prefix}/libexec
> +%define gsed_datarootdir%{gsed_prefix}/share
> +%define gsed_datadir%{gsed_datarootdir}
> +%define gsed_sysconfdir %{gsed_prefix}/etc
> +%define gsed_sharedstatedir %{gsed_prefix}/com
> +%define gsed_localstatedir  %{gsed_prefix}/var
> +%define gsed_includedir %{gsed_prefix}/include
> +%define gsed_libdir %{gsed_exec_prefix}/%{_lib}
> +%define gsed_mandir %{gsed_datarootdir}/man
> +%define gsed_infodir%{gsed_datarootdir}/info
> +%define gsed_localedir  %{gsed_datarootdir}/locale
> +
> +#
> +# Prepare the source code.
> +#
> +%prep
> +  build_top=$(pwd)
> +
> +  source_dir_gsed="sed-%{gsed_version}"
> +  %source setup gsed -q -n sed-%{gsed_version}
> +  %patch setup gsed -p1
> +
> +  cd ${build_top}
> +
> +%build
> +  build_top=$(pwd)
> +
> +  %if %{defined _internal_gsed_path}
> +export PATH="%{_internal_gsed_path}/bin:${PATH}"
> +  %endif
> +
> +  %{build_directory}
> +
> +  mkdir -p ${build_dir}
> +  cd ${build_dir}
> +
> +  %{host_build_flags}
> +
> +  ../${source_dir_gsed}/configure \
> +--prefix=%{gsed_prefix} \
> +--bindir=%{gsed_bindir} \
> +--exec_prefix=%{gsed_exec_prefix} \
> +--includedir=%{gsed_includedir} \
> +

Re: [PATCH 3/3] bsps/shared/: Use device tree blob

2022-09-14 Thread Alan Cudmore
Hi Padmarao,
Please see my inline comments below

On Wed, Sep 14, 2022 at 12:51 AM  wrote:

> Hi Alan,
>
> > On Tue, 2022-09-13 at 23:57 -0400, Alan Cudmore wrote:
> >
> > Hi Padmarao,
> > I am working on a RISC-V bsp variant for the Kendryte K210 and I am
> > also using an included DTB. For my k210 bsp, I changed
> > riscv/shared/start/start.S to set the address of the DTB array before
> > calling bsp_fdt_copy. If we change start.S to handle the following
> > three cases, we would not have to change the bsp_fdt_copy function.
> > The three cases are:
> > - no FDT, I assume griscv bsp
> > - uboot - a0 in contains the address of the u-boot loaded DTB
> > - polarfire, k210 and others - set a0 to the address of the included
> > DTB array
> > I think it's better to keep this function generic and not have to
> > conditionally ignore the input parameter.
> >
>
> Yes, Initially I thought same but don't want to include conditional
> statements in the startup code so moved to bsp_fdt_copy().
>
> Can we try like below in the startup code? so that it can support all
> three cases.
>
> #ifdef BSP_DTB_IS_SUPPORTED
> #include BSP_DTB_HEADER_PATH
> #endif
>

For including the DTB header, I have a file similar to the microblaze_fpga
bsp:
https://git.rtems.org/rtems/tree/bsps/microblaze/microblaze_fpga/fdt/bsp_fdt.c
Perhaps after your changes are in the tree we can consider promoting this
feature and option to bsps/shared for riscv, microblaze and future bsps
that need a DTB.


>
> #ifdef BSP_START_COPY_FDT_FROM_U_BOOT
> #ifdef BSP_DTB_IS_SUPPORT
> LADDR a0, system_dtb
> #else
> mv  a0, a1
> #endif
> callbsp_fdt_copy
> #endif
>
> I added your dtb options to my build, and tried this code in start.S. It
works for me.
Once your polarfire BSP is in, then it will be much easier for k210 support
- in fact it may just be a few lines of code and selection of options.
Thanks!
Alan


> Regards
> Padmarao
>
> > Thanks,
> > Alan
> >
> >
> > On Thu, Sep 8, 2022 at 11:44 AM Padmarao Begari <
> > padmarao.beg...@microchip.com> wrote:
> > > If the bsp is integrated and supported a device tree
> > > blob(dtb) then use dtb instead of using it from the U-Boot.
> > > ---
> > >  bsps/shared/start/bsp-fdt.c | 11 ++-
> > >  1 file changed, 10 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/bsps/shared/start/bsp-fdt.c b/bsps/shared/start/bsp-
> > > fdt.c
> > > index 75a1ea41c9..7e1a698896 100644
> > > --- a/bsps/shared/start/bsp-fdt.c
> > > +++ b/bsps/shared/start/bsp-fdt.c
> > > @@ -32,6 +32,10 @@
> > >  #include 
> > >  #include 
> > >
> > > +#ifdef BSP_DTB_IS_SUPPORTED
> > > +#include BSP_DTB_HEADER_PATH
> > > +#endif
> > > +
> > >  #ifndef BSP_FDT_IS_SUPPORTED
> > >  #warning "BSP FDT support indication not defined"
> > >  #endif
> > > @@ -51,7 +55,12 @@ bsp_fdt_blob[BSP_FDT_BLOB_SIZE_MAX /
> > > sizeof(uint32_t)];
> > >
> > >  void bsp_fdt_copy(const void *src)
> > >  {
> > > +#ifdef BSP_DTB_IS_SUPPORTED
> > > +const volatile uint32_t *s = (const uint32_t *) system_dtb;
> > > +#else
> > >const volatile uint32_t *s = (const uint32_t *) src;
> > > +#endif
> > > +
> > >  #ifdef BSP_FDT_BLOB_COPY_TO_READ_ONLY_LOAD_AREA
> > >uint32_t *d = (uint32_t *) ((uintptr_t) _fdt_blob[0]
> > >  - (uintptr_t) bsp_section_rodata_begin
> > > @@ -61,7 +70,7 @@ void bsp_fdt_copy(const void *src)
> > >  #endif
> > >
> > >if (s != d) {
> > > -size_t m = MIN(sizeof(bsp_fdt_blob), fdt_totalsize(src));
> > > +size_t m = MIN(sizeof(bsp_fdt_blob), fdt_totalsize(s));
> > >  size_t aligned_size = roundup2(m, CPU_CACHE_LINE_BYTES);
> > >  size_t n = (m + sizeof(*d) - 1) / sizeof(*d);
> > >  size_t i;
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 3/3] bsps/shared/: Use device tree blob

2022-09-14 Thread Alan Cudmore
Sorry for not thinking this through, but I think I have a more portable
solution for handling the included DTB:
1. In bsps/shared/start/bsp-fdt.c, include the header as you had originally
proposed.
2. Also bsps/shared/start/bsp-fdt.c, change bsp_fdt_get to return either
_fdt_blob[0] for the u-boot option, or just system_dtb for the DTB
option.
3. in bsps/riscv/shared/start.S - no change is needed for the fdt copy.
This is only needed if the device tree is loaded by u-boot and needs to be
copied. No need to call it for the embedded DTB.
To make this work, you would need to have the following in config.ini for
the polarfire (and eventually k210) bsp variant:
BSP_START_COPY_FDT_FROM_U_BOOT=False
BSP_DTB_IS_SUPPORTED=True
I'm not sure if the BSP_DTB_IS_SUPPORTED option should be moved to the
shared section of the specs, but I think it might - in this case the
default might be False.
Same with the BSP_DTB_HEADER_PATH option - but I'm not sure what a good
default would be for that.

I think this would set up the microblaze_fpga to use the same shared code
and options, and we could eliminate the
bsps/microblaze/microblaze_fpga/fdt/bsp_fdt.c file later.

Below are the diffs for bsps/shared/start/bsp-fdt.c that is working on my
k210 board. Again, sorry for any confusion, what I have now is just a
slight change to your original proposal. (changing bsp_fdt_get instead of
bsp_fdt_copy).
Thanks,
Alan
diff --git a/bsps/shared/start/bsp-fdt.c b/bsps/shared/start/bsp-fdt.c
index 75a1ea41c9..6e2a0b82db 100644
--- a/bsps/shared/start/bsp-fdt.c
+++ b/bsps/shared/start/bsp-fdt.c
@@ -36,6 +36,10 @@
 #warning "BSP FDT support indication not defined"
 #endif

+#ifdef BSP_DTB_IS_SUPPORTED
+   #include BSP_DTB_HEADER_PATH
+#endif
+
 #ifndef BSP_FDT_BLOB_SIZE_MAX
 #define BSP_FDT_BLOB_SIZE_MAX 0
 #endif
@@ -76,5 +80,9 @@ void bsp_fdt_copy(const void *src)

 const void *bsp_fdt_get(void)
 {
+#if BSP_DTB_IS_SUPPORTED
+  return system_dtb;
+#else
   return _fdt_blob[0];
+#endif
 }



On Wed, Sep 14, 2022 at 9:16 AM Alan Cudmore  wrote:

> Hi Padmarao,
> Please see my inline comments below
>
> On Wed, Sep 14, 2022 at 12:51 AM  wrote:
>
>> Hi Alan,
>>
>> > On Tue, 2022-09-13 at 23:57 -0400, Alan Cudmore wrote:
>> >
>> > Hi Padmarao,
>> > I am working on a RISC-V bsp variant for the Kendryte K210 and I am
>> > also using an included DTB. For my k210 bsp, I changed
>> > riscv/shared/start/start.S to set the address of the DTB array before
>> > calling bsp_fdt_copy. If we change start.S to handle the following
>> > three cases, we would not have to change the bsp_fdt_copy function.
>> > The three cases are:
>> > - no FDT, I assume griscv bsp
>> > - uboot - a0 in contains the address of the u-boot loaded DTB
>> > - polarfire, k210 and others - set a0 to the address of the included
>> > DTB array
>> > I think it's better to keep this function generic and not have to
>> > conditionally ignore the input parameter.
>> >
>>
>> Yes, Initially I thought same but don't want to include conditional
>> statements in the startup code so moved to bsp_fdt_copy().
>>
>> Can we try like below in the startup code? so that it can support all
>> three cases.
>>
>> #ifdef BSP_DTB_IS_SUPPORTED
>> #include BSP_DTB_HEADER_PATH
>> #endif
>>
>
> For including the DTB header, I have a file similar to the microblaze_fpga
> bsp:
>
> https://git.rtems.org/rtems/tree/bsps/microblaze/microblaze_fpga/fdt/bsp_fdt.c
> Perhaps after your changes are in the tree we can consider promoting this
> feature and option to bsps/shared for riscv, microblaze and future bsps
> that need a DTB.
>
>
>>
>> #ifdef BSP_START_COPY_FDT_FROM_U_BOOT
>> #ifdef BSP_DTB_IS_SUPPORT
>> LADDR a0, system_dtb
>> #else
>> mv  a0, a1
>> #endif
>> callbsp_fdt_copy
>> #endif
>>
>> I added your dtb options to my build, and tried this code in start.S. It
> works for me.
> Once your polarfire BSP is in, then it will be much easier for k210
> support - in fact it may just be a few lines of code and selection of
> options.
> Thanks!
> Alan
>
>
>> Regards
>> Padmarao
>>
>> > Thanks,
>> > Alan
>> >
>> >
>> > On Thu, Sep 8, 2022 at 11:44 AM Padmarao Begari <
>> > padmarao.beg...@microchip.com> wrote:
>> > > If the bsp is integrated and supported a device tree
>> > > blob(dtb) then use dtb instead of using it from the U-Boot.
>> > > ---
>> > >  bsps/shared/start/bsp-fdt.c | 11 ++-
>> > >  1 file changed, 10 insertions(+), 1 deletion(-)
>> > >
>> > > diff --git a/bsps/shared/start/bsp-fdt.c b/bsps/shared/start/bsp-
>> > > fdt.c
>> > > index 75a1ea41c9..7e1a698896 100644
>> > > --- a/bsps/shared/start/bsp-fdt.c
>> > > +++ b/bsps/shared/start/bsp-fdt.c
>> > > @@ -32,6 +32,10 @@
>> > >  #include 
>> > >  #include 
>> > >
>> > > +#ifdef BSP_DTB_IS_SUPPORTED
>> > > +#include BSP_DTB_HEADER_PATH
>> > > +#endif
>> > > +
>> > >  #ifndef BSP_FDT_IS_SUPPORTED
>> > >  #warning "BSP FDT 

[PATCH 3/3] devel/gcc: Check and build GNU sed if not available on build host

2022-09-14 Thread chrisj
From: Chris Johns 

Closes #2300
---
 bare/config/devel/gnu-default-tools.bset| 6 ++
 rtems/config/tools/rtems-default-tools.bset | 5 +
 source-builder/config/gcc-common-1.cfg  | 4 
 3 files changed, 15 insertions(+)

diff --git a/bare/config/devel/gnu-default-tools.bset 
b/bare/config/devel/gnu-default-tools.bset
index dab8c5e..f038352 100644
--- a/bare/config/devel/gnu-default-tools.bset
+++ b/bare/config/devel/gnu-default-tools.bset
@@ -6,6 +6,12 @@
 
 %define gcc_version_message RTEMS bare %{rtems_version}, RSB %{_sbgit_id}, 
Newlib %{newlib_version}
 
+#
+# GCC requires a GNU sed so build an internal version if one is not
+# available
+#
+%include textproc/gsed-internal
+
 #
 # Build gdb first to raise the Python install error as early as
 # possible. GDB needs expat so it needs to be built before gdb.
diff --git a/rtems/config/tools/rtems-default-tools.bset 
b/rtems/config/tools/rtems-default-tools.bset
index 7d273cf..8ec6721 100644
--- a/rtems/config/tools/rtems-default-tools.bset
+++ b/rtems/config/tools/rtems-default-tools.bset
@@ -2,6 +2,11 @@
 # Default tools build
 #
 
+# GCC requires a GNU sed so build an internal version if one is not
+# available
+#
+%include textproc/gsed-internal.bset
+
 #
 # Build gdb first to raise the Python install error as early as
 # possible. GDB needs expat so it needs to be built before gdb.
diff --git a/source-builder/config/gcc-common-1.cfg 
b/source-builder/config/gcc-common-1.cfg
index 87ccef1..933202a 100644
--- a/source-builder/config/gcc-common-1.cfg
+++ b/source-builder/config/gcc-common-1.cfg
@@ -165,6 +165,10 @@ URL:  http://gcc.gnu.org/
 %build
   build_top=$(pwd)
 
+  %if %{defined _internal_gsed_path}
+export PATH=%{_internal_gsed_path}/bin:$PATH
+  %endif
+
   %{build_directory}
 
   mkdir -p ${build_dir}
-- 
2.37.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/3] textproc/gsed: Add GNU sed build support

2022-09-14 Thread chrisj
From: Chris Johns 

Updates #2300
---
 bare/config/textproc/gsed-4.8.cfg   |  12 +++
 bare/config/textproc/gsed-internal.bset |  12 +++
 bare/config/textproc/gsed.bset  |   4 +
 bare/config/textproc/gsed.cfg   |   8 ++
 source-builder/config/gsed-1.cfg| 108 
 5 files changed, 144 insertions(+)
 create mode 100644 bare/config/textproc/gsed-4.8.cfg
 create mode 100644 bare/config/textproc/gsed-internal.bset
 create mode 100644 bare/config/textproc/gsed.bset
 create mode 100644 bare/config/textproc/gsed.cfg
 create mode 100644 source-builder/config/gsed-1.cfg

diff --git a/bare/config/textproc/gsed-4.8.cfg 
b/bare/config/textproc/gsed-4.8.cfg
new file mode 100644
index 000..8806bef
--- /dev/null
+++ b/bare/config/textproc/gsed-4.8.cfg
@@ -0,0 +1,12 @@
+#
+# GNU sed 4.8
+#
+
+%include %{_configdir}/base.cfg
+
+%define gsed_version 4.8
+
+%hash sha512 sed-%{gsed_version}.tar.gz \
+
C94KIhaOMQCwIUKTsTu6CEzM5F/7WGtsV1OPUY52akRDn/vyR4mPK7j1BtBTHTbynAp7cIhJVbqTz8/YhjG/eQ==
+
+%include %{_configdir}/gsed-1.cfg
diff --git a/bare/config/textproc/gsed-internal.bset 
b/bare/config/textproc/gsed-internal.bset
new file mode 100644
index 000..e93e1a5
--- /dev/null
+++ b/bare/config/textproc/gsed-internal.bset
@@ -0,0 +1,12 @@
+#
+# Internal GNU sed
+#
+
+%define _internal_gsed  yes
+%define _internal_gsed_path %{_tmppath}/sb-%{_uid}/${SB_PREFIX_CLEAN}
+%define _disable_collecting yes
+%define _disable_packaging  yes
+%define _disable_reporting  yes
+%define _disable_installing yes
+
+%include textproc/gsed.bset
diff --git a/bare/config/textproc/gsed.bset b/bare/config/textproc/gsed.bset
new file mode 100644
index 000..68f2e13
--- /dev/null
+++ b/bare/config/textproc/gsed.bset
@@ -0,0 +1,4 @@
+#
+# GNU sed
+#
+textproc/gsed.cfg
diff --git a/bare/config/textproc/gsed.cfg b/bare/config/textproc/gsed.cfg
new file mode 100644
index 000..8287c74
--- /dev/null
+++ b/bare/config/textproc/gsed.cfg
@@ -0,0 +1,8 @@
+#
+# GNU sed has a version option, check for it.
+# If not found build it.
+#
+%define has_gnu_sed %(sed --version > /dev/null 2>&1; echo $?)
+%if %{has_gnu_sed} != 0
+ %include %{_configdir}/textproc/gsed-4.8.cfg
+%endif
diff --git a/source-builder/config/gsed-1.cfg b/source-builder/config/gsed-1.cfg
new file mode 100644
index 000..828da50
--- /dev/null
+++ b/source-builder/config/gsed-1.cfg
@@ -0,0 +1,108 @@
+#
+# GNU sed 1.xx Version 1.
+#
+# This configuration file configure's, make's and install's GNU's sed
+#
+
+%if %{release} == %{nil}
+ %define release 1
+%endif
+
+%ifn %{defined _internal_gsed}
+  %define _internal_gsed no
+%endif
+%ifn %{defined _internal_gsed_path}
+  %define _internal_gsed_path %{_prefix}
+%endif
+
+Name:  gsed-%{gsed_version}-%{_host}-%{release}
+Summary:   GNU sed v%{gsed_version} for host %{_host}
+Version:   %{gsed_version}
+Release:   %{release}
+URL:  https://www.gnu.org/software/sed/
+
+#
+# Source
+#
+%source set gsed https://ftp.gnu.org/gnu/sed/sed-%{gsed_version}.tar.gz
+
+#
+# Remap the install paths if it is an internal build
+#
+%if %{_internal_gsed} == yes
+  %define gsed_prefix %{_internal_gsed_path}
+%else
+  %define gsed_prefix %{_prefix}
+%endif
+
+%define gsed_exec_prefix%{gsed_prefix}
+%define gsed_bindir %{gsed_exec_prefix}/bin
+%define gsed_sbindir%{gsed_exec_prefix}/sbin
+%define gsed_libexecdir %{gsed_exec_prefix}/libexec
+%define gsed_datarootdir%{gsed_prefix}/share
+%define gsed_datadir%{gsed_datarootdir}
+%define gsed_sysconfdir %{gsed_prefix}/etc
+%define gsed_sharedstatedir %{gsed_prefix}/com
+%define gsed_localstatedir  %{gsed_prefix}/var
+%define gsed_includedir %{gsed_prefix}/include
+%define gsed_libdir %{gsed_exec_prefix}/%{_lib}
+%define gsed_mandir %{gsed_datarootdir}/man
+%define gsed_infodir%{gsed_datarootdir}/info
+%define gsed_localedir  %{gsed_datarootdir}/locale
+
+#
+# Prepare the source code.
+#
+%prep
+  build_top=$(pwd)
+
+  source_dir_gsed="sed-%{gsed_version}"
+  %source setup gsed -q -n sed-%{gsed_version}
+  %patch setup gsed -p1
+
+  cd ${build_top}
+
+%build
+  build_top=$(pwd)
+
+  %if %{defined _internal_gsed_path}
+export PATH="%{_internal_gsed_path}/bin:${PATH}"
+  %endif
+
+  %{build_directory}
+
+  mkdir -p ${build_dir}
+  cd ${build_dir}
+
+  %{host_build_flags}
+
+  ../${source_dir_gsed}/configure \
+--prefix=%{gsed_prefix} \
+--bindir=%{gsed_bindir} \
+--exec_prefix=%{gsed_exec_prefix} \
+--includedir=%{gsed_includedir} \
+--libdir=%{gsed_libdir} \
+--libexecdir=%{gsed_libexecdir} \
+--mandir=%{gsed_mandir} \
+--infodir=%{gsed_infodir} \
+--datadir=%{gsed_datadir} \
+--build=%{_build} --host=%{_host}
+
+  %{__make} %{?_smp_mflags} all
+
+  cd ${build_top}
+
+%install
+  build_top=$(pwd)
+
+  %{__rmdir} $SB_BUILD_ROOT
+
+  cd ${build_dir}
+
+  %if %{_internal_gsed} == yes
+%{__make} install
+  %else
+%{__make} 

[PATCH 1/3] sb/setbuilder: Do not install if --no-install option is used

2022-09-14 Thread chrisj
From: Chris Johns 

- This is a bug introduced in the recent bset tar file changes
---
 source-builder/sb/setbuilder.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py
index 67b66f5..f24ac87 100644
--- a/source-builder/sb/setbuilder.py
+++ b/source-builder/sb/setbuilder.py
@@ -560,7 +560,8 @@ class buildset:
 buildroot = path.join(b.config.expand('%{buildroot}'), 
prefix)
 if self.staging():
 prefix = b.config.expand('%{stagingroot}')
-self.install(self.install_mode(), b.name(), buildroot, 
prefix)
+if not self.opts.no_install():
+self.install(self.install_mode(), b.name(), 
buildroot, prefix)
 #
 # Sizes ...
 #
-- 
2.37.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[RSB] Build GNU sed if not available on host

2022-09-14 Thread chrisj
Hi,

These patches add support to build GNU sed if it is not avaliable on
a host. GCC requires GNU sed or weird things happen. Ticket #2300
details a MIPS build failure that has existed in GCC for years
where the multilib processing depends on GNU sed.

The simplest solution is to check and if sed is not GNU build it.
This happens on MacOS and FreeBSD.

The patches also include a fix for the --no-install option.

Chris


___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel