replacing libgloss in msp430-elf

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

replacing libgloss in msp430-elf

Peter Bigot-4
Starting a new thread since this is off-topic for "MSP430 simulator in gdb".

The discussion is how to take advantage of newlib's libc
infrastructure while replacing the system interface that is by default
provided by libgloss: i.e. implementations of
read()/write()/sbrk()/gettimeofday() and other functions that
interface with a host environment (hardware, OS framework, simulator,
whatever).

The msp430-elf port appears to make this difficult in two ways:

1) gcc has a hard-coded LIB_SPEC that automatically adds -lnosys
whenever  the user fails to specify the simulator as the target.  The
need in the situation being discussed is to provide an alternative
implementation to -lnosys.  I've worked around this by removing
%{!msim:-lnosys} from LIB_SPEC and building a new toolchain.

2) The msp430 port of newlib is nearly unique in discarding the
libnosys implementation provided by newlib in favor of its own
crippled implementation.  (Of the dozen+ supported newlib targets
spu-* is the only other one that does this).  I've worked around this
by patching the msp430 target to remove the CIO-based -lnosys provided
libgloss/msp430/Makefile.in and instead keep the default
config_libnosys=true, leveraging the standard libgloss stub system
function implementation.

I've verified that with this toolchain I can use the newlib standard
option -specs=nosys.specs to link applications with the stubbed
version from libgloss for cases where I don't want to replace the
implementation.  I've also done enough testing to be convinced I can
provide an alternative implementation of the system interface
functions, as is normally permitted by newlib.

However, the changes necessary to make this work require building a
special version of the toolchain with modified upstream sources.
Works for me; not really acceptable to most users.  So presumably this
isn't the way I'm supposed to do this.

How am I supposed to do this?

Peter

On Thu, Jun 5, 2014 at 6:09 AM, Peter Bigot <[hidden email]> wrote:

> On Tue, Jun 3, 2014 at 6:35 PM, DJ Delorie <[hidden email]> wrote:
>>
>>> You can do that with the RH newlib as long as you don't link in
>>> libgloss's versions of the low-level routines - i.e. remove -lgloss
>>> from your link line and add -lbspacm.
>>
>> To clarify: don't link in -lnosys if you're not compiling with "-msim"
>> or don't link in -lsim if you are compiling with "-msim"
>>
>> Both of these are linked at the same point as libc and libgcc, by the
>> gcc driver, depending on whether or not you use the -msim option.
>
> Yes, first impressions suggest if I could get rid of libgloss entirely
> I could do what I want.
>
> But since gcc's LIB_SPEC helpfully adds -lnosys for me at no extra
> charge when I don't use -msim, how can I avoid linking it in?
>
> Peter

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

DJ Delorie

The reason msp430 is different is because CIO *can* be used on real
hardware, to communicate through a hardware debugger or emulator pod.

Perhaps moving the cio-enabled nosys to a libcio.a?  Then we'd need a
-mcio option to gcc to enable it, but could default to doing the
generic nosys thing...

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

Peter Bigot-4
On Thu, Jun 5, 2014 at 4:48 PM, DJ Delorie <[hidden email]> wrote:
>
> The reason msp430 is different is because CIO *can* be used on real
> hardware, to communicate through a hardware debugger or emulator pod.
>
> Perhaps moving the cio-enabled nosys to a libcio.a?  Then we'd need a
> -mcio option to gcc to enable it, but could default to doing the
> generic nosys thing...

I like that approach; it makes clear that the system interface is
still CIO even when not using -msim, and it gives application
developers the appropriate level of control when CIO is not desired.
Making selection of -mcio a positive decision (not default) also helps
reveal when an application unintentionally introduces dependencies
such as calls to sbrk (malloc) for newlib internal data structures
that most mspgcc developers would be surprised to find happening (they
did not occur with the same functions in msp430-libc).

What needs to be done to get this into place?  Do you need an
enhancement request in gcc and/or newlib bugzilla?

Peer

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

Peter Bigot-4
Ping.

On Thu, Jun 5, 2014 at 5:55 PM, Peter Bigot <[hidden email]> wrote:

> On Thu, Jun 5, 2014 at 4:48 PM, DJ Delorie <[hidden email]> wrote:
>>
>> The reason msp430 is different is because CIO *can* be used on real
>> hardware, to communicate through a hardware debugger or emulator pod.
>>
>> Perhaps moving the cio-enabled nosys to a libcio.a?  Then we'd need a
>> -mcio option to gcc to enable it, but could default to doing the
>> generic nosys thing...
>
> I like that approach; it makes clear that the system interface is
> still CIO even when not using -msim, and it gives application
> developers the appropriate level of control when CIO is not desired.
> Making selection of -mcio a positive decision (not default) also helps
> reveal when an application unintentionally introduces dependencies
> such as calls to sbrk (malloc) for newlib internal data structures
> that most mspgcc developers would be surprised to find happening (they
> did not occur with the same functions in msp430-libc).
>
> What needs to be done to get this into place?  Do you need an
> enhancement request in gcc and/or newlib bugzilla?

Absent any coordinated action on this, I'm going to send patches to
newlib to remove the special-case override of libnosys in msp430
libgloss, and to gcc to eliminate the automatic addition of -lnosys
when -msim is absent in gcc.

Peter

------------------------------------------------------------------------------
Slashdot TV.  Video for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

nick clifton
Hi Peter

> Ping.

[DJ is on vacation, so I am standing in for him...]

>>> Perhaps moving the cio-enabled nosys to a libcio.a?  Then we'd need a
>>> -mcio option to gcc to enable it, but could default to doing the
>>> generic nosys thing...
>>
>> I like that approach; it makes clear that the system interface is
>> still CIO even when not using -msim, and it gives application
>> developers the appropriate level of control when CIO is not desired.
>> Making selection of -mcio a positive decision (not default) also helps
>> reveal when an application unintentionally introduces dependencies
>> such as calls to sbrk (malloc) for newlib internal data structures
>> that most mspgcc developers would be surprised to find happening (they
>> did not occur with the same functions in msp430-libc).
>>
>> What needs to be done to get this into place?  Do you need an
>> enhancement request in gcc and/or newlib bugzilla?

Yes - if you want Red Hat to do this.  But of course you can do the work
yourself if you prefer.

> Absent any coordinated action on this, I'm going to send patches to
> newlib to remove the special-case override of libnosys in msp430
> libgloss, and to gcc to eliminate the automatic addition of -lnosys
> when -msim is absent in gcc.

Both of which are perfectly reasonable, and I see no reason why they
should not be accepted.

Cheers
   Nick



------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

Peter Bigot-4
On Mon, Sep 22, 2014 at 2:17 AM, Nicholas Clifton <[hidden email]> wrote:
> Hi Peter
>
>> Ping.
>
>
> [DJ is on vacation, so I am standing in for him...]

Thanks for responding.

>
>>>> Perhaps moving the cio-enabled nosys to a libcio.a?  Then we'd need a
>>>> -mcio option to gcc to enable it, but could default to doing the
>>>> generic nosys thing...
>>>
>>>
>>> I like that approach; it makes clear that the system interface is
>>> still CIO even when not using -msim, and it gives application
>>> developers the appropriate level of control when CIO is not desired.
>>> Making selection of -mcio a positive decision (not default) also helps
>>> reveal when an application unintentionally introduces dependencies
>>> such as calls to sbrk (malloc) for newlib internal data structures
>>> that most mspgcc developers would be surprised to find happening (they
>>> did not occur with the same functions in msp430-libc).
>>>
>>> What needs to be done to get this into place?  Do you need an
>>> enhancement request in gcc and/or newlib bugzilla?
>
>
> Yes - if you want Red Hat to do this.  But of course you can do the work
> yourself if you prefer.

That would seem to be the most likely path to success.

>> Absent any coordinated action on this, I'm going to send patches to
>> newlib to remove the special-case override of libnosys in msp430
>> libgloss, and to gcc to eliminate the automatic addition of -lnosys
>> when -msim is absent in gcc.
>
>
> Both of which are perfectly reasonable, and I see no reason why they should
> not be accepted.

gcc: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg01809.html
newlib: https://sourceware.org/ml/newlib/2014/msg00465.html

I'd appreciate it if you or DJ would shepherd these through: I don't
think anybody on either list is likely to merge them otherwise.
Thanks.

Peter

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

nick clifton
Hi Peter,

> gcc: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg01809.html
> newlib: https://sourceware.org/ml/newlib/2014/msg00465.html
>
> I'd appreciate it if you or DJ would shepherd these through: I don't
> think anybody on either list is likely to merge them otherwise.

Both patches have now been approved and applied to the mainline sources.

Cheers
   Nick

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

Peter Bigot-4
On Mon, Sep 22, 2014 at 10:49 AM, Nicholas Clifton <[hidden email]> wrote:

> Hi Peter,
>
>> gcc: https://gcc.gnu.org/ml/gcc-patches/2014-09/msg01809.html
>> newlib: https://sourceware.org/ml/newlib/2014/msg00465.html
>>
>> I'd appreciate it if you or DJ would shepherd these through: I don't
>> think anybody on either list is likely to merge them otherwise.
>
>
> Both patches have now been approved and applied to the mainline sources.
>
> Cheers
>   Nick

Thank you very much.  For the first time I have a working msp430-elf
toolchain built from upstream sources with no patches (and it's gcc
5.0.0).

I looked at the changes to gcc 4.9.1 that are in the TI msp430-elf
2.0.0 (Red Hat GNUPro 14r1) which add full support for 20-bit
addresses and are not upstreamed yet.  They seem pretty pervasive:
major changes to the set of supported integer types.

It's not really feasible to extract those changes and apply them to a
non-bundled source directory since the base version isn't exactly GCC
4.9.1.    If you or TI could provide information on whether those
patches are likely to get refactored and merged upstream, and any
timeline information that's available, I think most folks here would
be interested.

Peter

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

DJ Delorie

> It's not really feasible to extract those changes and apply them to a
> non-bundled source directory since the base version isn't exactly GCC
> 4.9.1.    If you or TI could provide information on whether those
> patches are likely to get refactored and merged upstream, and any
> timeline information that's available, I think most folks here would
> be interested.

You need my __intN patch set, currently being reviewed upstream.  Some
parts have been approved and applied, but you still need the main
conversion (3/5, pending libg++ review) and the msp430-specific part
(5/5, just waiting on part 3/5).  This patch set is based on the
TI-specific patch in their 4.9 sources.

https://gcc.gnu.org/ml/gcc-patches/2014-08/threads.html#01398

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: replacing libgloss in msp430-elf

Peter Bigot-4
On Mon, Sep 22, 2014 at 11:40 AM, DJ Delorie <[hidden email]> wrote:

>
>> It's not really feasible to extract those changes and apply them to a
>> non-bundled source directory since the base version isn't exactly GCC
>> 4.9.1.    If you or TI could provide information on whether those
>> patches are likely to get refactored and merged upstream, and any
>> timeline information that's available, I think most folks here would
>> be interested.
>
> You need my __intN patch set, currently being reviewed upstream.  Some
> parts have been approved and applied, but you still need the main
> conversion (3/5, pending libg++ review) and the msp430-specific part
> (5/5, just waiting on part 3/5).  This patch set is based on the
> TI-specific patch in their 4.9 sources.
>
> https://gcc.gnu.org/ml/gcc-patches/2014-08/threads.html#01398

Thanks.  As it's in-progress, I'll just wait until it appears in the
tree.  I mostly don't use 20-bit on msp430-elf: it takes up too much
space compared to mspgcc since (AFAIK) there's no compact/medium modes
so lots of things like size_t take 32 bits of memory when they could
take 16 for most applications.  If I need more memory for a project I
use ARM processors where I don't have to deal with split address
spaces.

FWIW: There are one or two unverified bug reports from me in gcc's
bugzilla that I'd hit doing 20-bit support in mspgcc that can probably
be closed now that part 2/5 (PRECISION != BITSIZE) is in.

Peter

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users