Need clarification on compilation errors in PG 16.2

Started by Pradeep Kumarover 1 year ago8 messages
#1Pradeep Kumar
spradeepkumar29@gmail.com

Hi ,
While we try to install PG 16.2 from the source code in macbook we getting
this following errors
```

*explicit_bzero.c:22:9: error: call to undeclared function 'memset_s'; ISO
C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration] (void) memset_s(buf, len, 0,
len); ^explicit_bzero.c:22:9: note: did you mean
'memset'?/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/string.h:74:7:
note: 'memset' declared herevoid memset(void __b, int __c, size_t
__len); ^1 error generated.make[2]: *** [explicit_bzero.o] Error
1make[2]: *** Waiting for unfinished jobs....make[1]: ***
[all-port-recurse] Error 2make: *** [all-src-recurse] Error 2*
```
then I changed the function memset_s(buf, len, 0, len) to memset(buf, 0,
len) and it's working. need a clarification on this?

Thanks and regards
Pradeep

#2Daniel Gustafsson
daniel@yesql.se
In reply to: Pradeep Kumar (#1)
Re: Need clarification on compilation errors in PG 16.2

On 28 May 2024, at 07:37, Pradeep Kumar <spradeepkumar29@gmail.com> wrote:

This requires more information to be shared in order to figure out what could
be happening.

```
explicit_bzero.c:22:9: error: call to undeclared function 'memset_s'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
(void) memset_s(buf, len, 0, len);
^

This codepath would only be reached if the buildsystem determined that memset_s
was available so something is fairly wrong here. Did you change any builfiles
after running configure? Re-install or upgrade XCode after running configure?

then I changed the function memset_s(buf, len, 0, len) to memset(buf, 0, len) and it's working. need a clarification on this?

memset_s and memset have the same prototype, and are functionally equivalent,
but memset_s have certain properties which are required in this codepath.

--
Daniel Gustafsson

#3Pradeep Kumar
spradeepkumar29@gmail.com
In reply to: Daniel Gustafsson (#2)
Re: Need clarification on compilation errors in PG 16.2

Hi,

This codepath would only be reached if the buildsystem determined that

memset_s

was available so something is fairly wrong here. Did you change any

builfiles

after running configure? Re-install or upgrade XCode after running

configure?

I didn't touch any of the buildfiles , even didn't touch the PG's source
code and didn't reinstall or upgrade Xcode. Just configure the PG and gave
'make' and I got this error.

memset_s and memset have the same prototype, and are functionally

equivalent,

but memset_s have certain properties which are required in this codepath.

Ok

Thanks and regards

On Tue, May 28, 2024 at 11:52 AM Daniel Gustafsson <daniel@yesql.se> wrote:

Show quoted text

On 28 May 2024, at 07:37, Pradeep Kumar <spradeepkumar29@gmail.com>

wrote:

This requires more information to be shared in order to figure out what
could
be happening.

```
explicit_bzero.c:22:9: error: call to undeclared function 'memset_s';

ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]

(void) memset_s(buf, len, 0, len);
^

This codepath would only be reached if the buildsystem determined that
memset_s
was available so something is fairly wrong here. Did you change any
builfiles
after running configure? Re-install or upgrade XCode after running
configure?

then I changed the function memset_s(buf, len, 0, len) to memset(buf, 0,

len) and it's working. need a clarification on this?

memset_s and memset have the same prototype, and are functionally
equivalent,
but memset_s have certain properties which are required in this codepath.

--
Daniel Gustafsson

#4Pradeep Kumar
spradeepkumar29@gmail.com
In reply to: Pradeep Kumar (#1)
Re: Need clarification on compilation errors in PG 16.2

Hi Long,

In fact, whether the HAVE_MEMSET_S macro is defined determines whether the

implementation

of the explicit_bzero() function calls memset_s() or memset(). This macro

is undefined by default

in pg_config.h, so check to see if your build environment has a

HAVE_MEMSET_S macro defined.

Yes it was defined in "pg_config.h"
/* Define to 1 if you have the `memset_s' function. */
#define HAVE_MEMSET_S 1

Thanks

On Tue, May 28, 2024 at 12:27 PM Long Song <songlong88@126.com> wrote:

Show quoted text

Hi Pradeep,

At 2024-05-28 12:37:08, "Pradeep Kumar" <spradeepkumar29@gmail.com> wrote:

Hi ,
While we try to install PG 16.2 from the source code in macbook we

getting this following errors

```

explicit_bzero.c:22:9: error: call to undeclared function 'memset_s';

ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]

(void) memset_s(buf, len, 0, len);
^
explicit_bzero.c:22:9: note: did you mean 'memset'?

/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/string.h:74:7:
note: 'memset' declared here

void memset(void __b, int __c, size_t __len);
^
1 error generated.
make[2]: *** [explicit_bzero.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-port-recurse] Error 2
make: *** [all-src-recurse] Error 2

```
then I changed the function memset_s(buf, len, 0, len) to memset(buf, 0,

len) and it's working. need a clarification on this?
In fact, whether the HAVE_MEMSET_S macro is defined determines whether the
implementation
of the explicit_bzero() function calls memset_s() or memset(). This macro
is undefined by default
in pg_config.h, so check to see if your build environment has a
HAVE_MEMSET_S macro defined.

Best Regards,
Long

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Pradeep Kumar (#4)
Re: Need clarification on compilation errors in PG 16.2

Pradeep Kumar <spradeepkumar29@gmail.com> writes:

Yes it was defined in "pg_config.h"
/* Define to 1 if you have the `memset_s' function. */
#define HAVE_MEMSET_S 1

That's correct for recent versions of macOS. I see you are
building against a recent SDK:

/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/string.h

but I wonder if maybe the actual OS version is back-rev?

regards, tom lane

#6Daniel Gustafsson
daniel@yesql.se
In reply to: Tom Lane (#5)
Re: Need clarification on compilation errors in PG 16.2

On 28 May 2024, at 22:51, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Pradeep Kumar <spradeepkumar29@gmail.com> writes:

Yes it was defined in "pg_config.h"
/* Define to 1 if you have the `memset_s' function. */
#define HAVE_MEMSET_S 1

That's correct for recent versions of macOS. I see you are
building against a recent SDK:

/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/string.h

but I wonder if maybe the actual OS version is back-rev?

Skimming the releases on https://opensource.apple.com/releases/ it seems that
memset_s has been available since Mavericks (10.9) AFAICT.

--
Daniel Gustafsson

#7Pradeep Kumar
spradeepkumar29@gmail.com
In reply to: Tom Lane (#5)
Re: Need clarification on compilation errors in PG 16.2

Hello Tom,

That's correct for recent versions of macOS. I see you are
building against a recent SDK:

/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/string.h

but I wonder if maybe the actual OS version is back-rev?

Currently Im using "MacOSX14.4.sdk" , path is
"/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/string.h".
When I go through the header file and search for the memset_s(), I found
that library is defined in a conditional macro refer below, am I breaking
the macro below?

#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
#include <sys/_types/_rsize_t.h>
#include <sys/_types/_errno_t.h>

__BEGIN_DECLS
errno_t memset_s(void *__s, rsize_t __smax, int __c, rsize_t __n)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
__END_DECLS
#endif

Thanks and Regards
Pradeep

On Wed, May 29, 2024 at 2:21 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Pradeep Kumar <spradeepkumar29@gmail.com> writes:

Yes it was defined in "pg_config.h"
/* Define to 1 if you have the `memset_s' function. */
#define HAVE_MEMSET_S 1

That's correct for recent versions of macOS. I see you are
building against a recent SDK:

/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/string.h

but I wonder if maybe the actual OS version is back-rev?

regards, tom lane

#8Pradeep Kumar
spradeepkumar29@gmail.com
In reply to: Pradeep Kumar (#7)
Re: Need clarification on compilation errors in PG 16.2

Hi,

I found out that for using memset() library is not referred from
"/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/string.h"
, it referred from
"/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/secure/_string.h",
in that file didn't defined the memset_s() macro.

Thanks and regards
Pradeep

On Wed, May 29, 2024 at 11:30 AM Pradeep Kumar <spradeepkumar29@gmail.com>
wrote:

Show quoted text

Hello Tom,

That's correct for recent versions of macOS. I see you are
building against a recent SDK:

/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/string.h

but I wonder if maybe the actual OS version is back-rev?

Currently Im using "MacOSX14.4.sdk" , path is
"/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/string.h".
When I go through the header file and search for the memset_s(), I found
that library is defined in a conditional macro refer below, am I breaking
the macro below?

#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
#include <sys/_types/_rsize_t.h>
#include <sys/_types/_errno_t.h>

__BEGIN_DECLS
errno_t memset_s(void *__s, rsize_t __smax, int __c, rsize_t __n)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
__END_DECLS
#endif

Thanks and Regards
Pradeep

On Wed, May 29, 2024 at 2:21 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Pradeep Kumar <spradeepkumar29@gmail.com> writes:

Yes it was defined in "pg_config.h"
/* Define to 1 if you have the `memset_s' function. */
#define HAVE_MEMSET_S 1

That's correct for recent versions of macOS. I see you are
building against a recent SDK:

/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/string.h

but I wonder if maybe the actual OS version is back-rev?

regards, tom lane