public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] Using ekd2-libc with C++20
@ 2024-02-16 10:00 pawel.karczewski via groups.io
  2024-02-16 17:26 ` Michael D Kinney
  2024-02-16 20:06 ` Pedro Falcato
  0 siblings, 2 replies; 7+ messages in thread
From: pawel.karczewski via groups.io @ 2024-02-16 10:00 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]

Hi,

I'm successfully building C++20 project with edk2 under the GCC compiler.
Currently I'm trying to add edk2-libc to this project, but encountered issue with <string.h> header.

```
edk2/StdLib/Include/string.h:487:19: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register] register char **stringp
```

Why `strsep(register char **stringp, register const char *delim)` parameters has register storage class-class specifier?
C standard states the `register` keyword is only hint for the compiler and the extent to which such
suggestions are effective is implementation-defined. Do you see any real performance improvements thanks to this?

As I can see FreeBSD libc and musl do not have `register` keyword in signature of this function.

How do you think, may we remove `register` keyword from headers in Include directory?

Second option I see is to add
```
#ifdef __cplusplus
#define register
#endif
```

Of course I may submit patch for this change.

Paweł


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115541): https://edk2.groups.io/g/devel/message/115541
Mute This Topic: https://groups.io/mt/104393456/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 2162 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Using ekd2-libc with C++20
  2024-02-16 10:00 [edk2-devel] Using ekd2-libc with C++20 pawel.karczewski via groups.io
@ 2024-02-16 17:26 ` Michael D Kinney
  2024-02-16 20:02   ` Pedro Falcato
  2024-02-16 20:06 ` Pedro Falcato
  1 sibling, 1 reply; 7+ messages in thread
From: Michael D Kinney @ 2024-02-16 17:26 UTC (permalink / raw)
  To: devel@edk2.groups.io, pawel.karczewski@solidigm.com,
	Jayaprakash, N
  Cc: Kinney, Michael D

[-- Attachment #1: Type: text/plain, Size: 1799 bytes --]

I think adding a #define to define register to nothings makes sense.

If this is something that is tied to a specific C++ version, then it could be further qualified with a version value.

Mike

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of pawel.karczewski via groups.io
Sent: Friday, February 16, 2024 2:00 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] Using ekd2-libc with C++20

Hi,

I'm successfully building C++20 project with edk2 under the GCC compiler.
Currently I'm trying to add edk2-libc to this project, but encountered issue with <string.h> header.

```
edk2/StdLib/Include/string.h:487:19: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register] register char **stringp
```

Why `strsep(register char **stringp, register const char *delim)` parameters has register storage class-class specifier?
C standard states the `register` keyword is only hint for the compiler and the extent to which such
suggestions are effective is implementation-defined. Do you see any real performance improvements thanks to this?

As I can see FreeBSD libc and musl do not have `register` keyword in signature of this function.

How do you think, may we remove `register` keyword from headers in Include directory?

Second option I see is to add
```
#ifdef __cplusplus
#define register
#endif
```

Of course I may submit patch for this change.

Paweł



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115545): https://edk2.groups.io/g/devel/message/115545
Mute This Topic: https://groups.io/mt/104393456/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 5911 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Using ekd2-libc with C++20
  2024-02-16 17:26 ` Michael D Kinney
@ 2024-02-16 20:02   ` Pedro Falcato
  0 siblings, 0 replies; 7+ messages in thread
From: Pedro Falcato @ 2024-02-16 20:02 UTC (permalink / raw)
  To: devel, michael.d.kinney; +Cc: pawel.karczewski@solidigm.com, Jayaprakash, N

On Fri, Feb 16, 2024 at 5:26 PM Michael D Kinney
<michael.d.kinney@intel.com> wrote:
>
> I think adding a #define to define register to nothings makes sense.

No, the correct fix is to remove 'register' from the parameters. It
does not change the ABI, nor the API, nor are the parameters
"register"-ified in the C or C++ standards.

AFAIK the only side effect of 'register' (on modern compilers, aka
GCC/clang/MSVC, etc) is that you can't grab its address
(https://godbolt.org/z/cx9zf9n9n). But that's not a problem in this
case.

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115552): https://edk2.groups.io/g/devel/message/115552
Mute This Topic: https://groups.io/mt/104393456/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Using ekd2-libc with C++20
  2024-02-16 10:00 [edk2-devel] Using ekd2-libc with C++20 pawel.karczewski via groups.io
  2024-02-16 17:26 ` Michael D Kinney
@ 2024-02-16 20:06 ` Pedro Falcato
  2024-02-16 20:48   ` Michael D Kinney
  2024-02-17  2:09   ` Pedro Falcato
  1 sibling, 2 replies; 7+ messages in thread
From: Pedro Falcato @ 2024-02-16 20:06 UTC (permalink / raw)
  To: devel, pawel.karczewski

On Fri, Feb 16, 2024 at 2:46 PM pawel.karczewski via groups.io
<pawel.karczewski=solidigm.com@groups.io> wrote:
>
> Hi,
>
> I'm successfully building C++20 project with edk2 under the GCC compiler.
> Currently I'm trying to add edk2-libc to this project, but encountered issue with <string.h> header.
>
> ```
> edk2/StdLib/Include/string.h:487:19: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register] register char **stringp
> ```
>
> Why `strsep(register char **stringp, register const char *delim)` parameters has register storage class-class specifier?
> C standard states the `register` keyword is only hint for the compiler and the extent to which such
> suggestions are effective is implementation-defined. Do you see any real performance improvements thanks to this?

Considering the file is Copyright(C) University of California (and the
SCCS tags suggest 1993, which places it around 4.4BSD), this very much
looks like a historical artifact (of old UNIX and bad compilers). I
certainly doubt any compiler capable of building EDK2 changes its
codegen because of it (and certainly not the calling convention, at
least in all ABIs I know of).

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115553): https://edk2.groups.io/g/devel/message/115553
Mute This Topic: https://groups.io/mt/104393456/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Using ekd2-libc with C++20
  2024-02-16 20:06 ` Pedro Falcato
@ 2024-02-16 20:48   ` Michael D Kinney
  2024-02-16 21:29     ` Michael D Kinney
  2024-02-17  2:09   ` Pedro Falcato
  1 sibling, 1 reply; 7+ messages in thread
From: Michael D Kinney @ 2024-02-16 20:48 UTC (permalink / raw)
  To: devel@edk2.groups.io, pedro.falcato@gmail.com,
	pawel.karczewski@solidigm.com
  Cc: Kinney, Michael D

The other option is update build to ignore -Werror=register

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Pedro
> Falcato
> Sent: Friday, February 16, 2024 12:06 PM
> To: devel@edk2.groups.io; pawel.karczewski@solidigm.com
> Subject: Re: [edk2-devel] Using ekd2-libc with C++20
> 
> On Fri, Feb 16, 2024 at 2:46 PM pawel.karczewski via groups.io
> <pawel.karczewski=solidigm.com@groups.io> wrote:
> >
> > Hi,
> >
> > I'm successfully building C++20 project with edk2 under the GCC
> compiler.
> > Currently I'm trying to add edk2-libc to this project, but
> encountered issue with <string.h> header.
> >
> > ```
> > edk2/StdLib/Include/string.h:487:19: error: ISO C++17 does not allow
> ‘register’ storage class specifier [-Werror=register] register char
> **stringp
> > ```
> >
> > Why `strsep(register char **stringp, register const char *delim)`
> parameters has register storage class-class specifier?
> > C standard states the `register` keyword is only hint for the
> compiler and the extent to which such
> > suggestions are effective is implementation-defined. Do you see any
> real performance improvements thanks to this?
> 
> Considering the file is Copyright(C) University of California (and the
> SCCS tags suggest 1993, which places it around 4.4BSD), this very much
> looks like a historical artifact (of old UNIX and bad compilers). I
> certainly doubt any compiler capable of building EDK2 changes its
> codegen because of it (and certainly not the calling convention, at
> least in all ABIs I know of).
> 
> --
> Pedro
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115554): https://edk2.groups.io/g/devel/message/115554
Mute This Topic: https://groups.io/mt/104393456/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Using ekd2-libc with C++20
  2024-02-16 20:48   ` Michael D Kinney
@ 2024-02-16 21:29     ` Michael D Kinney
  0 siblings, 0 replies; 7+ messages in thread
From: Michael D Kinney @ 2024-02-16 21:29 UTC (permalink / raw)
  To: devel@edk2.groups.io, pedro.falcato@gmail.com,
	pawel.karczewski@solidigm.com
  Cc: Kinney, Michael D

-Wregister (C++ and Objective-C++ only)
Warn on uses of the register storage class specifier, except when it is part of the GNU Variables in Specified Registers extension. The use of the register keyword as storage class specifier has been deprecated in C++11 and removed in C++17. Enabled by default with -std=c++17.


I think adding -Wno-register to [BuildOptions] for GCC CC_FLAGS in edk2-libc/StdLib/StdLib.inc may help.

Mike


> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Friday, February 16, 2024 12:49 PM
> To: devel@edk2.groups.io; pedro.falcato@gmail.com;
> pawel.karczewski@solidigm.com
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: RE: [edk2-devel] Using ekd2-libc with C++20
> 
> The other option is update build to ignore -Werror=register
> 
> Mike
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Pedro
> > Falcato
> > Sent: Friday, February 16, 2024 12:06 PM
> > To: devel@edk2.groups.io; pawel.karczewski@solidigm.com
> > Subject: Re: [edk2-devel] Using ekd2-libc with C++20
> >
> > On Fri, Feb 16, 2024 at 2:46 PM pawel.karczewski via groups.io
> > <pawel.karczewski=solidigm.com@groups.io> wrote:
> > >
> > > Hi,
> > >
> > > I'm successfully building C++20 project with edk2 under the GCC
> > compiler.
> > > Currently I'm trying to add edk2-libc to this project, but
> > encountered issue with <string.h> header.
> > >
> > > ```
> > > edk2/StdLib/Include/string.h:487:19: error: ISO C++17 does not
> allow
> > ‘register’ storage class specifier [-Werror=register] register char
> > **stringp
> > > ```
> > >
> > > Why `strsep(register char **stringp, register const char *delim)`
> > parameters has register storage class-class specifier?
> > > C standard states the `register` keyword is only hint for the
> > compiler and the extent to which such
> > > suggestions are effective is implementation-defined. Do you see any
> > real performance improvements thanks to this?
> >
> > Considering the file is Copyright(C) University of California (and
> the
> > SCCS tags suggest 1993, which places it around 4.4BSD), this very
> much
> > looks like a historical artifact (of old UNIX and bad compilers). I
> > certainly doubt any compiler capable of building EDK2 changes its
> > codegen because of it (and certainly not the calling convention, at
> > least in all ABIs I know of).
> >
> > --
> > Pedro
> >
> >
> > 
> >



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115558): https://edk2.groups.io/g/devel/message/115558
Mute This Topic: https://groups.io/mt/104393456/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Using ekd2-libc with C++20
  2024-02-16 20:06 ` Pedro Falcato
  2024-02-16 20:48   ` Michael D Kinney
@ 2024-02-17  2:09   ` Pedro Falcato
  1 sibling, 0 replies; 7+ messages in thread
From: Pedro Falcato @ 2024-02-17  2:09 UTC (permalink / raw)
  To: devel, pawel.karczewski

On Fri, Feb 16, 2024 at 8:06 PM Pedro Falcato <pedro.falcato@gmail.com> wrote:
>
> On Fri, Feb 16, 2024 at 2:46 PM pawel.karczewski via groups.io
> <pawel.karczewski=solidigm.com@groups.io> wrote:
> >
> > Hi,
> >
> > I'm successfully building C++20 project with edk2 under the GCC compiler.
> > Currently I'm trying to add edk2-libc to this project, but encountered issue with <string.h> header.
> >
> > ```
> > edk2/StdLib/Include/string.h:487:19: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register] register char **stringp
> > ```
> >
> > Why `strsep(register char **stringp, register const char *delim)` parameters has register storage class-class specifier?
> > C standard states the `register` keyword is only hint for the compiler and the extent to which such
> > suggestions are effective is implementation-defined. Do you see any real performance improvements thanks to this?
>
> Considering the file is Copyright(C) University of California (and the
> SCCS tags suggest 1993, which places it around 4.4BSD), this very much
> looks like a historical artifact (of old UNIX and bad compilers). I
> certainly doubt any compiler capable of building EDK2 changes its
> codegen because of it (and certainly not the calling convention, at
> least in all ABIs I know of).

I was bored and had to check :)

Old 4.4BSD string.h:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/src/include/string.h

So we can see that it didn't even have the register specifier in the
declaration.

However, in the definition:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/src/lib/libc/string/strsep.c
We can see that 'register' was present there, for what I assume was
handholding the compiler into keeping the arg variables in registers
on old UNIX (they did that *a lot*, even back in the original UNIX C
versions).

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115564): https://edk2.groups.io/g/devel/message/115564
Mute This Topic: https://groups.io/mt/104393456/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-17  2:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-16 10:00 [edk2-devel] Using ekd2-libc with C++20 pawel.karczewski via groups.io
2024-02-16 17:26 ` Michael D Kinney
2024-02-16 20:02   ` Pedro Falcato
2024-02-16 20:06 ` Pedro Falcato
2024-02-16 20:48   ` Michael D Kinney
2024-02-16 21:29     ` Michael D Kinney
2024-02-17  2:09   ` Pedro Falcato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox