tpm2-software / tpm2-tss

OSS implementation of the TCG TPM2 Software Stack (TSS2)
https://tpm2-software.github.io
BSD 2-Clause "Simplified" License
732 stars 360 forks source link

Installation Issues on Mac OS #2629

Open hansm4305 opened 1 year ago

hansm4305 commented 1 year ago

I am trying to install tpm2-tss on mac os using github actions The script used is

DIR="/tmp"
brew update
brew install git gcc@9

export CC=/usr/local/bin/gcc-9
export CXX=/usr/local/bin/g++-9

brew install libucl libcue libcdr libcerf
brew install --cask libcblite

brew install coreutils \
             curl \
             zip \
             unzip \
             wget \
             openssl \
             ninja \
             pkg-config \
             python3 \
             autoconf-archive \
             cmocka \
             libtool \
             automake \
             uthash \
             autoconf \
             doxygen \
             json-c

export PATH="/usr/local/opt/zip/bin:$PATH"
export PATH="/usr/local/opt/unzip/bin:$PATH"
export PATH="/usr/local/opt/openssl@3/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"

echo "Building TPM2-TSS"
mkdir $DIR/third-party
cd $DIR/third-party/
git clone https://github.com/tpm2-software/tpm2-tss.git 
cd $DIR/third-party/tpm2-tss/
git config --global --add safe.directory $DIR/third-party/tpm2-tss
./bootstrap
./configure
make -j$(sysctl -n hw.ncpu)
make install

But I am getting the following error during the installation

Generating file lists: src_vars.mk
aclocal: installing 'm4/ax_ac_append_to_file.m4' from '/usr/local/share/aclocal/ax_ac_append_to_file.m4'
aclocal: installing 'm4/ax_ac_print_to_file.m4' from '/usr/local/share/aclocal/ax_ac_print_to_file.m4'
aclocal: installing 'm4/ax_add_am_macro_static.m4' from '/usr/local/share/aclocal/ax_add_am_macro_static.m4'
aclocal: installing 'm4/ax_add_fortify_source.m4' from '/usr/local/share/aclocal/ax_add_fortify_source.m4'
aclocal: installing 'm4/ax_am_macros_static.m4' from '/usr/local/share/aclocal/ax_am_macros_static.m4'
aclocal: installing 'm4/ax_check_compile_flag.m4' from '/usr/local/share/aclocal/ax_check_compile_flag.m4'
aclocal: installing 'm4/ax_check_enable_debug.m4' from '/usr/local/share/aclocal/ax_check_enable_debug.m4'
aclocal: installing 'm4/ax_check_gnu_make.m4' from '/usr/local/share/aclocal/ax_check_gnu_make.m4'
aclocal: installing 'm4/ax_check_link_flag.m4' from '/usr/local/share/aclocal/ax_check_link_flag.m4'
aclocal: installing 'm4/ax_code_coverage.m4' from '/usr/local/share/aclocal/ax_code_coverage.m4'
aclocal: installing 'm4/ax_file_escapes.m4' from '/usr/local/share/aclocal/ax_file_escapes.m4'
aclocal: installing 'm4/ax_is_release.m4' from '/usr/local/share/aclocal/ax_is_release.m4'
aclocal: installing 'm4/ax_normalize_path.m4' from '/usr/local/share/aclocal/ax_normalize_path.m4'
aclocal: installing 'm4/ax_prog_doxygen.m4' from '/usr/local/share/aclocal/ax_prog_doxygen.m4'
aclocal: installing 'm4/ax_recursive_eval.m4' from '/usr/local/share/aclocal/ax_recursive_eval.m4'
aclocal: installing 'm4/ax_valgrind_check.m4' from '/usr/local/share/aclocal/ax_valgrind_check.m4'
aclocal: installing 'm4/libtool.m4' from '/usr/local/share/aclocal/libtool.m4'
aclocal: installing 'm4/ltdl.m4' from '/usr/local/share/aclocal/ltdl.m4'
aclocal: installing 'm4/ltoptions.m4' from '/usr/local/share/aclocal/ltoptions.m4'
aclocal: installing 'm4/ltsugar.m4' from '/usr/local/share/aclocal/ltsugar.m4'
aclocal: installing 'm4/ltversion.m4' from '/usr/local/share/aclocal/ltversion.m4'
aclocal: installing 'm4/lt~obsolete.m4' from '/usr/local/share/aclocal/lt~obsolete.m4'
aclocal: installing 'm4/pkg.m4' from '/usr/local/share/aclocal/pkg.m4'
glibtoolize: putting auxiliary files in '.'.
glibtoolize: linking file './ltmain.sh'
configure.ac:28: installing './compile'
configure.ac:23: installing './config.guess'
configure.ac:23: installing './config.sub'
configure.ac:12: installing './install-sh'
configure.ac:12: installing './missing'
aminclude_static.am:63: warning: GITIGNOREFILES was already defined in condition TRUE, which includes condition AUTOCONF_CODE_COVERAGE_2019_01_06 and CODE_COVERAGE_ENABLED ...
Makefile.am:56:   'aminclude_static.am' included from here
Makefile.am:52: ... 'GITIGNOREFILES' previously defined here
Makefile.am: error: object 'src/tss2-esys/libtss2_esys_la-esys_crypto_mbed.lo' created by 'src/tss2-esys/esys_crypto_mbed.c' and 'src/tss2-esys//esys_crypto_mbed.c'
Makefile.am: error: object 'src/tss2-esys/libtss2_esys_la-esys_crypto_ossl.lo' created by 'src/tss2-esys/esys_crypto_ossl.c' and 'src/tss2-esys//esys_crypto_ossl.c'
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
autoreconf: error: automake failed with exit status: 1
Error: Process completed with exit code 1.
Paintballworld commented 9 months ago

I have the same exact problem on my MacOS 13.6 (22G120)

AndreasFuchsTPM commented 7 months ago

What version of autoreconf do you run ?

tomoveu commented 3 months ago

@Paintballworld or @hansm4305 , did you solve this issue?

tomoveu commented 3 months ago

@AndreasFuchsTPM similar issue on MacOS Sonoma 14.4.1 when using @hansm4305 install script, please see log below:

aminclude_static.am:63: warning: GITIGNOREFILES was already defined in condition TRUE, which includes condition AUTOCONF_CODE_COVERAGE_2019_01_06 and CODE_COVERAGE_ENABLED ...
Makefile.am:56:   'aminclude_static.am' included from here
Makefile.am:52: ... 'GITIGNOREFILES' previously defined here
Makefile.am: error: object 'src/tss2-esys/libtss2_esys_la-esys_crypto_mbed.lo' created by 'src/tss2-esys/esys_crypto_mbed.c' and 'src/tss2-esys//esys_crypto_mbed.c'
Makefile.am: error: object 'src/tss2-esys/libtss2_esys_la-esys_crypto_ossl.lo' created by 'src/tss2-esys/esys_crypto_ossl.c' and 'src/tss2-esys//esys_crypto_ossl.c'
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
autoreconf: error: automake failed with exit status: 1
checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking build system type... aarch64-apple-darwin23.4.0
checking host system type... aarch64-apple-darwin23.4.0
checking whether to enable debugging... info
checking for gcc... /usr/local/bin/gcc-9
checking whether the C compiler works... no
configure: error: in '/tmp/third-party/tpm2-tss':
configure: error: C compiler cannot create executables
See 'config.log' for more details
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target `install'.  Stop.
dimitomov@Dimis-MacBook-Pro tpm2-tss-install % autoconf --version
autoconf (GNU Autoconf) 2.72
tomoveu commented 3 months ago

Here is the log when trying to use clang Mac's default compiler

checking for systemd-sysusers... no
checking for systemd-tmpfiles... no
checking for useradd... no
checking for groupadd... no
checking for adduser... no
checking for addgroup... no
configure: error: addgroup or groupadd are needed.
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target `install'.  Stop.
dimitomov@Dimis-MacBook-Pro tpm2-tss-install % 
Firstyear commented 1 month ago

You need to install:

brew install autoconf autoconf-archive automake json-c libtool m4 pkg-config
OPTIONAL
 brew install libftdi

Then you hit the user issue, which I also opened in #2876

If you get past the user issue then you get

In file included from src/tss2-tcti/tcti-libtpms.c:23:
In file included from src/tss2-tcti/tcti-libtpms.h:10:
In file included from /opt/homebrew/include/libtpms/tpm_library.h:45:
/opt/homebrew/include/libtpms/tpm_types.h:55:24: error: redefinition of typedef 'BYTE' is a C11 feature [-Werror,-Wtypedef-redefinition]
typedef unsigned char  BYTE;            /* Basic byte used to transmit all character fields.  */
                       ^
./include/tss2/tss2_common.h:19:21: note: previous definition is here
typedef uint8_t     BYTE;
                    ^
src/tss2-tcti/tcti-libtpms.c:97:11: error: call to undeclared function 'posix_fallocate'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    ret = posix_fallocate(state_fd, 0, (off_t) tcti_libtpms->state_mmap_len);
          ^
src/tss2-tcti/tcti-libtpms.c:154:26: error: call to undeclared function 'mremap'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        new_state_mmap = mremap(tcti_libtpms->state_mmap,
                         ^
src/tss2-tcti/tcti-libtpms.c:157:33: error: use of undeclared identifier 'MREMAP_MAYMOVE'
                                MREMAP_MAYMOVE);
                                ^
src/tss2-tcti/tcti-libtpms.c:180:19: error: call to undeclared function 'posix_fallocate'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            ret = posix_fallocate(state_fd, 0, (off_t) tcti_libtpms->state_mmap_len);
                  ^
5 errors generated.
make[1]: *** [src/tss2-tcti/tcti-libtpms.lo] Error 1
make: *** [all] Error 2

Seems like a few barriers here :)