binutils-gdb linker won't find _libmd_SHA256_Init, etc.

Hello. I'm building esp-quick-toolchain (github.com/earlephilhower/esp-quick-toolchain/) that is used for compiling software for the ESP8266 MCU. Few months ago I succeeded building it only changing the compiler suffix and other minor things in the Makefile (from gcc to gcc9, etc) (this should have been on FreeBSD 12.1).

Last week I tried to build it again only to find out that now an error is produced while linking:
Code:
>>> referenced by check.h:143 (/usr/src/contrib/xz/src/liblzma/check/check.h:143)
>>>               check.o:(lzma_check_init) in archive /usr/lib/liblzma.a

ld: error: undefined symbol: _libmd_SHA256_Update
>>> referenced by check.h:160 (/usr/src/contrib/xz/src/liblzma/check/check.h:160)
>>>               check.o:(lzma_check_update) in archive /usr/lib/liblzma.a

ld: error: undefined symbol: _libmd_SHA256_Final
>>> referenced by check.h:167 (/usr/src/contrib/xz/src/liblzma/check/check.h:167)
>>>               check.o:(lzma_check_finish) in archive /usr/lib/liblzma.a
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[3]: *** [Makefile:1889: gdb] Error 1
gmake[3]: Leaving directory '/home/esp-quick-toolchain/arena.x86_64/binutils-gdb-gnu/gdb'
gmake[2]: *** [Makefile:10118: all-gdb] Error 2
gmake[2]: Leaving directory '/home/esp-quick-toolchain/arena.x86_64/binutils-gdb-gnu'
gmake[1]: *** [Makefile:849: all] Error 2
gmake[1]: Leaving directory '/home/esp-quick-toolchain/arena.x86_64/binutils-gdb-gnu

One problem that comes on my mind is that the binary is produced with GCC, but is linked with the system's ld?

I looked at the binutils port to see for special handling of (lzma?), tried to add --with-system-zlib w/o success.

I'm searching for advice on what steps to take?
Thanks!

Edit: similar problem occured here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247558
I upgraded from 12.1 to 12.2 and I use binary packages.

Edit2: hm, just went to the build dir (arena.x86_64/binutils-gdb-gnu) and gmake succeeded. Probably I should handle configuration and build one by one.
 
Switched to gcc9 and g++9 and it is still the same error:
Code:
  CXXLD  gdb
/usr/local/bin/ld: /usr/lib/liblzma.a(check.o): in function `lzma_sha256_init':
/usr/src/contrib/xz/src/liblzma/check/check.h:143: undefined reference to `_libmd_SHA256_Init'
/usr/local/bin/ld: /usr/lib/liblzma.a(check.o): in function `lzma_sha256_update':
/usr/src/contrib/xz/src/liblzma/check/check.h:160: undefined reference to `_libmd_SHA256_Update'
/usr/local/bin/ld: /usr/lib/liblzma.a(check.o): in function `lzma_sha256_finish':
/usr/src/contrib/xz/src/liblzma/check/check.h:167: undefined reference to `_libmd_SHA256_Final'

Also
Code:
# nm liblzma.a | grep SHA256
U _libmd_SHA256_Final
U _libmd_SHA256_Init
U _libmd_SHA256_Update
 
Good, I found that liblzma changed from FreeBSD 12.1 to 12.2 to use libmd for the SHA256 functions. So I did nm /usr/lib/libmd.a and I found the missing functions.

Now it should be possible to pass the additional (libmd) library to the linker with -lmd, but it doesn't solve the issue. I think that I do not pass it properly?

Am I correct that I only need to define it with -lmd? Not during configuration and not during make?

PS: I do this: CC=gcc9 CXX=g++9 gmake LDFLAGS=-static -lmd
 
Back
Top