Pthread issue during Snapcraft build

When tpm2-tss library is built during Snapcraft build step using make, it produces the following error.

I have installed autoconf-archive, libpthread-stubs0-dev and libc6-dev as build dependencies but the issue still occurs. The same process runs successfully during native build but when I try to run the make build as a part of Snapcraft build step this error occurs. I am running the following commands to build and install the library.

./configure --with-udevrulesdir=/etc/udev/rules.d
make -j$(nproc)
make install
sed -i "s/tss/$(whoami)/gi" /etc/udev/rules.d/tpm-udev.rules
udevadm control --reload-rules && sudo udevadm trigger
apt install tpm2-tools

The error occurs at line 2.

Turns out Snapcraft overrides env variables like CXXFLAGS and LDFLAGS on its own to set -isystem directories. Resetting them fixed the issue. Thanks for all the help.