Re: [PATCH] Add helper function for basename

2023-12-13 Thread Mark Wielaard
On Wed, Dec 13, 2023 at 08:29:01AM -0800, Khem Raj wrote:
> On Wed, Dec 13, 2023 at 7:10 AM Mark Wielaard  wrote:
> >
> > Hi Khem,
> >
> > On Tue, 2023-12-12 at 09:16 -0800, Khem Raj wrote:
> > > On Tue, Dec 12, 2023 at 5:18 AM Mark Wielaard  wrote:
> > > > On Sun, 2023-12-10 at 12:20 -0800, Khem Raj wrote:
> > > > > musl does not provide GNU version of basename and lately have removed
> > > > > the definiton from string.h [1] which exposes this problem. It can be
> > > > > made to work by providing a local implementation of basename which
> > > > > implements the GNU basename behavior, this makes it work across C
> > > > > libraries which have POSIX implementation only.
> > > >
> > > > Thanks, this should work, but wouldn't it be easier to add a configure
> > > > test for having basename defined in string.h and then only define
> > > > basename in libeu.h (and build basename.c) if it isn't. So that all the
> > > > code can just keep using basename (we just have to make sure libeu.h is
> > > > included)?
> > >
> > > we could do that but it will not work as expected with older musl releases
> > > where the prototype in string.h will exist.
> >
> > But that is good isn't it? Or did musl define basename in string.h with
> > different semantics (where the given input string is modified)?
> 
> basename was declared like this till lately
> https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Urgh, that is pretty bad. So it declared it with the wrong signature
and then it called an implementation that modified its argument...

> > In the second case various elfutils libraries and tools probably just
> > segfaulted when build/run against musl. And your patch would indeed fix
> > both old and new musl versions. Do people using musl already use some
> > variant of your patch?
> 
> This is not yet tried widely in distros as the musl patch above is
> till new and not part of
> a release yet.

I understand that. But I don't understand how an elfutils build/ran
against current musl even worked given that it would be using the
wrong basename implementation. It seems it cannot without your patch.

Did we just get lucky because most paths don't end with one or more
slashes?

Cheers,

Mark


Re: [PATCH] Add helper function for basename

2023-12-13 Thread Khem Raj
On Wed, Dec 13, 2023 at 7:10 AM Mark Wielaard  wrote:
>
> Hi Khem,
>
> On Tue, 2023-12-12 at 09:16 -0800, Khem Raj wrote:
> > On Tue, Dec 12, 2023 at 5:18 AM Mark Wielaard  wrote:
> > > On Sun, 2023-12-10 at 12:20 -0800, Khem Raj wrote:
> > > > musl does not provide GNU version of basename and lately have removed
> > > > the definiton from string.h [1] which exposes this problem. It can be
> > > > made to work by providing a local implementation of basename which
> > > > implements the GNU basename behavior, this makes it work across C
> > > > libraries which have POSIX implementation only.
> > >
> > > Thanks, this should work, but wouldn't it be easier to add a configure
> > > test for having basename defined in string.h and then only define
> > > basename in libeu.h (and build basename.c) if it isn't. So that all the
> > > code can just keep using basename (we just have to make sure libeu.h is
> > > included)?
> >
> > we could do that but it will not work as expected with older musl releases
> > where the prototype in string.h will exist.
>
> But that is good isn't it? Or did musl define basename in string.h with
> different semantics (where the given input string is modified)?

basename was declared like this till lately
https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

>
> In the second case various elfutils libraries and tools probably just
> segfaulted when build/run against musl. And your patch would indeed fix
> both old and new musl versions. Do people using musl already use some
> variant of your patch?

This is not yet tried widely in distros as the musl patch above is
till new and not part of
a release yet.

>
> Thanks,
>
> Mark


Re: [PATCH] Add helper function for basename

2023-12-13 Thread Mark Wielaard
Hi Khem,

On Tue, 2023-12-12 at 09:16 -0800, Khem Raj wrote:
> On Tue, Dec 12, 2023 at 5:18 AM Mark Wielaard  wrote:
> > On Sun, 2023-12-10 at 12:20 -0800, Khem Raj wrote:
> > > musl does not provide GNU version of basename and lately have removed
> > > the definiton from string.h [1] which exposes this problem. It can be
> > > made to work by providing a local implementation of basename which
> > > implements the GNU basename behavior, this makes it work across C
> > > libraries which have POSIX implementation only.
> > 
> > Thanks, this should work, but wouldn't it be easier to add a configure
> > test for having basename defined in string.h and then only define
> > basename in libeu.h (and build basename.c) if it isn't. So that all the
> > code can just keep using basename (we just have to make sure libeu.h is
> > included)?
> 
> we could do that but it will not work as expected with older musl releases
> where the prototype in string.h will exist.

But that is good isn't it? Or did musl define basename in string.h with
different semantics (where the given input string is modified)?

In the second case various elfutils libraries and tools probably just
segfaulted when build/run against musl. And your patch would indeed fix
both old and new musl versions. Do people using musl already use some
variant of your patch?

Thanks,

Mark


[Bug backends/31142] riscv pass_by_flattened_arg not implemented

2023-12-13 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=31142

--- Comment #3 from Mark Wielaard  ---
(In reply to Robbin Ehn from comment #1)
> I'm no expert in RV ABI, but from 18.2 RVG Calling Convention:
> 
> "Values are returned from functions in integer registers a0 and a1 and
> floating-point registers fa0 and fa1. Floating-point values are returned in
> floating-point registers only if they are primitives or members of a struct
> consisting of only one or two floating-point values. Other return values
> that fit into two pointer-words are returned in a0 and a1. Larger return
> values are passed entirely
> in memory; the caller allocates this memory region and passes a pointer to
> it as an implicit first parameter to the callee."
> 
> AFAICT they should be packed into a0+a1 seen as 8/16 byte field.
> 
> rv32 a0 would be quot and a1 would be rem
> rv64 a0 low 32-bit would be quot and a0 high 32-bit would be rem
> 
> This seems to be inline with what clang do, removes sign extension, shift
> and or the values in.
> 
> Did this help ?

Yes, thanks. I believe I know now which DWARF location description to use for a
function returning a (small) struct containing just integers or just floats.
The code is already there, it is just detecting the struct member types (and
total struct size).

I am not sure what this exactly means for a mix of an integers and floats in a
small struct. Does the calling convention actually handle that? If you have a
struct { int a; float f; } would that be returned with the first piece in a0
and the second piece in fa0? Or would such a return struct be returned entirely
in memory?

-- 
You are receiving this mail because:
You are on the CC list for the bug.