Thread: Compile fail on macos big sur
Hi, guys, I encount a problem on compiling pssql, the environment is:
os: macos big sur version 11.5.2 (20G95)
compiler: gcc-11 (Homebrew GCC 11.2.0) 11.2.0
error message:
/usr/local/bin/gcc-11 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 zic.o -L../../src/port -L../../src/common -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -L/usr/local/opt/binutils/lib -Wl,-dead_strip_dylibs -lpgcommon -lpgport -lz -lreadline -lm -o zic
ld: warning: ignoring file ../../src/common/libpgcommon.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../src/port/libpgport.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
"_pg_fprintf", referenced from:
_close_file in zic.o
_usage in zic.o
_memory_exhausted in zic.o
_verror in zic.o
_warning in zic.o
_dolink in zic.o
_writezone in zic.o
...
"_pg_printf", referenced from:
_main in zic.o
"_pg_qsort", referenced from:
_writezone in zic.o
_main in zic.o
"_pg_sprintf", referenced from:
_stringoffset in zic.o
_stringrule in zic.o
_doabbr in zic.o
"_pg_strerror", referenced from:
_close_file in zic.o
_memcheck.part.0 in zic.o
_mkdirs in zic.o
_dolink in zic.o
_writezone in zic.o
_infile in zic.o
_main in zic.o
...
"_pg_vfprintf", referenced from:
_verror in zic.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [zic] Error 1
make[1]: *** [all-timezone-recurse] Error 2
make: *** [all-src-recurse] Error 2
ld: warning: ignoring file ../../src/common/libpgcommon.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../src/port/libpgport.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
"_pg_fprintf", referenced from:
_close_file in zic.o
_usage in zic.o
_memory_exhausted in zic.o
_verror in zic.o
_warning in zic.o
_dolink in zic.o
_writezone in zic.o
...
"_pg_printf", referenced from:
_main in zic.o
"_pg_qsort", referenced from:
_writezone in zic.o
_main in zic.o
"_pg_sprintf", referenced from:
_stringoffset in zic.o
_stringrule in zic.o
_doabbr in zic.o
"_pg_strerror", referenced from:
_close_file in zic.o
_memcheck.part.0 in zic.o
_mkdirs in zic.o
_dolink in zic.o
_writezone in zic.o
_infile in zic.o
_main in zic.o
...
"_pg_vfprintf", referenced from:
_verror in zic.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [zic] Error 1
make[1]: *** [all-timezone-recurse] Error 2
make: *** [all-src-recurse] Error 2
Need help, thanks in advance.
Hi, On 23.09.2021 10:09, zhang listar wrote: > Hi, guys, I encount a problem on compiling pssql, the environment is: > os: macos big sur version 11.5.2 (20G95) > compiler: gcc-11 (Homebrew GCC 11.2.0) 11.2.0 I've just tried building with gcc-11 on Catalina (yes, it's time to upgrade) and it went fine, no warnings. Maybe `git clean -fdx` would help? (Be careful, though, it removes any changes you may have maid.) > /usr/local/bin/gcc-11 -Wall -Wmissing-prototypes -Wpointer-arith > -Wdeclaration-after-statement -Werror=vla -Wendif-labels > -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type > -Wformat-security -fno-strict-aliasing -fwrapv > -fexcess-precision=standard -Wno-format-truncation > -Wno-stringop-truncation -O2 zic.o -L../../src/port -L../../src/common > -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk > -L/usr/local/opt/binutils/lib -Wl,-dead_strip_dylibs -lpgcommon > -lpgport -lz -lreadline -lm -o zic Here is what I have: /usr/local/bin/gcc-11 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O2 zic.o -L../../src/port -L../../src/common -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -Wl,-dead_strip_dylibs -lpgcommon -lpgport -lz -lreadline -lm -o zic Looks the same, and gives no warnings. Just in case, I configured like that: ./configure --prefix=$(cd ..;pwd)/install-gcc-11 --enable-cassert --enable-debug --enable-tap-tests CC=/usr/local/bin/gcc-11 Hope that helps. -- Sergey Shinderuk https://postgrespro.com/
Thanks for your reply, I do make distclean and git clean -fdx, but it does no help.
the code: master, c7aeb775df895db240dcd6f47242f7e08899adfb
It looks like the macos issue, because of the ignoring of some lib, it drives the compiling error.
Sergey Shinderuk <s.shinderuk@postgrespro.ru> 于2021年9月23日周四 下午3:35写道:
Hi,
On 23.09.2021 10:09, zhang listar wrote:
> Hi, guys, I encount a problem on compiling pssql, the environment is:
> os: macos big sur version 11.5.2 (20G95)
> compiler: gcc-11 (Homebrew GCC 11.2.0) 11.2.0
I've just tried building with gcc-11 on Catalina (yes, it's time to
upgrade) and it went fine, no warnings.
Maybe `git clean -fdx` would help? (Be careful, though, it removes any
changes you may have maid.)
> /usr/local/bin/gcc-11 -Wall -Wmissing-prototypes -Wpointer-arith
> -Wdeclaration-after-statement -Werror=vla -Wendif-labels
> -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type
> -Wformat-security -fno-strict-aliasing -fwrapv
> -fexcess-precision=standard -Wno-format-truncation
> -Wno-stringop-truncation -O2 zic.o -L../../src/port -L../../src/common
> -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk
> -L/usr/local/opt/binutils/lib -Wl,-dead_strip_dylibs -lpgcommon
> -lpgport -lz -lreadline -lm -o zic
Here is what I have:
/usr/local/bin/gcc-11 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Werror=vla -Wendif-labels
-Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type
-Wformat-security -fno-strict-aliasing -fwrapv
-fexcess-precision=standard -Wno-format-truncation
-Wno-stringop-truncation -g -O2 zic.o -L../../src/port
-L../../src/common -isysroot
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
-Wl,-dead_strip_dylibs -lpgcommon -lpgport -lz -lreadline -lm -o zic
Looks the same, and gives no warnings.
Just in case, I configured like that:
./configure --prefix=$(cd ..;pwd)/install-gcc-11 --enable-cassert
--enable-debug --enable-tap-tests CC=/usr/local/bin/gcc-11
Hope that helps.
--
Sergey Shinderuk https://postgrespro.com/
On 23.09.2021 10:50, zhang listar wrote: > Thanks for your reply, I do make distclean and git clean -fdx, but it > does no help. > > the code: master, c7aeb775df895db240dcd6f47242f7e08899adfb > It looks like the macos issue, because of the ignoring of some lib, it > drives the compiling error. Maybe you could try adding -v to the problematic gcc command to see what really goes on. I see that gcc calls /usr/bin/ld, not binutils ld installed with Homebrew. I saw an advice to `brew unlink binutils` somewhere.
Thanks. It is the binuitls problem. I do "brew uninstall binutils" and compile successfully.
Actually it is the lib $(which ranlib) -V problem.
The similar issue here: https://github.com/bitcoin/bitcoin/issues/20825
Sergey Shinderuk <s.shinderuk@postgrespro.ru> 于2021年9月23日周四 下午4:03写道:
On 23.09.2021 10:50, zhang listar wrote:
> Thanks for your reply, I do make distclean and git clean -fdx, but it
> does no help.
>
> the code: master, c7aeb775df895db240dcd6f47242f7e08899adfb
> It looks like the macos issue, because of the ignoring of some lib, it
> drives the compiling error.
Maybe you could try adding -v to the problematic gcc command to see what
really goes on.
I see that gcc calls /usr/bin/ld, not binutils ld installed with
Homebrew. I saw an advice to `brew unlink binutils` somewhere.