After conducting a further investigation into this issue, I have made
some discoveries. The previous patch successfully resolves the problem
when running the commands `./configure && make && make check` (without
any previous sudo make install or make install). However, it stops at
the 'isolation check' when using the commands `./configure
--enable-tap-tests && make && make check-world`.
To address this, I attempted to apply a similar approach as the previous
patch, resulting in an experimental patch (attached). This new patch
helps progress the 'make-world' process and passes the 'isolation
check', but there are still several remaining issues that need to be
addressed.
Currently, there is a description suggesting a workaround by running a
'make install' command first, but I find it to be somewhat inaccurate.
It would be better to update the existing description to provide more
precise instructions on how to overcome this issue. Here are the changes
I would suggest.
from:
"You can work around that by doing make install before make check. Most
PostgreSQL developers just turn off SIP, though."
to:
"You can execute sudo make install if you do not specify a prefix during
the configure step, or make install without sudo if you do specify a
prefix (assuming proper permissions) before make check. Most PostgreSQL
developers just turn off SIP, though."
Otherwise, following the current description, if you run `./configure
&& make install` you will get error: "mkdir: /usr/local/pgsql:
Permission denied"
Below are the steps I took that led to the discovery of additional issues.
git apply pg_regress_mac_os_x_dyld.patch
./configure
make
make check
... ...
# All 215 tests passed.
./configure --enable-tap-tests
make
make check-world
... ...
echo "# +++ isolation check in src/test/isolation +++"
... ...
dyld[32335]: Library not loaded: /usr/local/pgsql/lib/libpq.5.dylib
Referenced from: <EB3758C5-A87B-36C5-AA29-C1E31AD89E70>
/Users/david/hg/sandbox/postgres/src/test/isolation/isolationtester
Reason: tried: '/usr/local/pgsql/lib/libpq.5.dylib' (no such file),
'/System/Volumes/Preboot/Cryptexes/OS/usr/local/pgsql/lib/libpq.5.dylib'
(no such file), '/usr/local/pgsql/lib/libpq.5.dylib' (no such file),
'/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib'
(no such file, not in dyld cache)
no data was returned by command
""/Users/david/hg/sandbox/postgres/src/test/isolation/isolationtester" -V"
git apply pg_regress_mac_os_x_dyld_isolation_check_only.patch
./configure --enable-tap-tests
make
make check-world
... ...
# All 215 tests passed.
... ...
# +++ isolation check in src/test/isolation +++
... ...
# All 112 tests passed.
echo "# +++ tap check in src/test/modules/brin +++"
... ...
# +++ tap check in src/test/modules/brin +++
t/01_workitems.pl ........ Bailout called. Further testing stopped:
command "initdb -D
/Users/david/hg/sandbox/postgres/src/test/modules/brin/tmp_check/t_01_workitems_tango_data/pgdata
-A trust -N" died with signal 6
t/01_workitems.pl ........ Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
Any thoughts ?
Thank you
David
On 2023-06-16 2:25 p.m., David Zhang wrote:
I have applied the patch to the latest master branch and successfully executed './configure &&
make && make check' on macOS Ventura. However, during the process, a warning was encountered:
"mixing declarations and code is incompatible with standards before C99
[-Wdeclaration-after-statement]". Moving the declaration of 'result' to the beginning like below can
resolve the warning, and it would be better to use a unique variable instead of 'result'.
#ifdef __darwin__
static char extra_envvars[4096];
+int result = -1;
... ...
-int result = snprintf(extra_envvars, sizeof(extra_envvars),
"DYLD_LIBRARY_PATH=%s",
+result = snprintf(extra_envvars, sizeof(extra_envvars), "DYLD_LIBRARY_PATH=%s",
diff --git a/src/common/exec.c b/src/common/exec.c
index f209b934df..8cf2c21a66 100644
--- a/src/common/exec.c
+++ b/src/common/exec.c
@@ -74,6 +74,12 @@ static char *pg_realpath(const char *fname);
static BOOL GetTokenUser(HANDLE hToken, PTOKEN_USER *ppTokenUser);
#endif
+#ifdef __darwin__
+static char extra_envvars[4096];
+#else
+static const char extra_envvars[] = "";
+#endif
+
/*
* validate_exec -- validate "path" as an executable file
*
@@ -330,6 +336,15 @@ find_other_exec(const char *argv0, const char *target,
char cmd[MAXPGPATH];
char line[MAXPGPATH];
+#ifdef __darwin__
+ int result = 1;
+ result = snprintf(extra_envvars, sizeof(extra_envvars),
"DYLD_LIBRARY_PATH=%s",
+ getenv("DYLD_LIBRARY_PATH"));
+ if (result < 0 || result >= sizeof(extra_envvars))
+ {
+ printf("extra_envars too small for DYLD_LIBRARY_PATH");
+ }
+#endif
if (find_my_exec(argv0, retpath) < 0)
return -1;
@@ -344,7 +359,7 @@ find_other_exec(const char *argv0, const char *target,
if (validate_exec(retpath) != 0)
return -1;
- snprintf(cmd, sizeof(cmd), "\"%s\" -V", retpath);
+ snprintf(cmd, sizeof(cmd), "%s \"%s\" -V", extra_envvars, retpath);
if (!pipe_read_line(cmd, line, sizeof(line)))
return -1;