axlearn icon indicating copy to clipboard operation
axlearn copied to clipboard

Bazel Build fails when installing Tensorflow text

Open NarasimhanKovalai opened this issue 1 year ago • 1 comments

Related issue https://github.com/apple/axlearn/issues/892.

I am trying to install the dependencies of axlearn repository on M1 air arm64 (macOS sequoia 15.5). I am following the setup instructions at https://github.com/apple/axlearn/blob/main/docs/01-start.md. Specifically the following chunk :

# Install the arm64 version of Miniforge3 + Python 3.10.
curl -L -o miniforge.sh https://github.com/conda-forge/miniforge/releases/download/24.7.1-0/Miniforge3-24.7.1-0-MacOSX-arm64.sh
bash miniforge.sh -u

# Create a conda environment.
conda create -n axlearn python=3.10
conda activate axlearn

# Install tensorflow following https://developer.apple.com/metal/tensorflow-plugin.
conda install -c apple tensorflow-deps

# If you do NOT have bazel installed.
# Note that the default ./oss_scripts/install_bazel.sh installs the x86 version.
brew install bazelisk

# Manually build tensorflow-text until a collaborator build is available.
# This was tested using clang version 15 - you may get non-working wheels with earlier versions of clang.
mkdir ~/builds && git clone https://github.com/tensorflow/text.git ~/builds/text
# Install tensorflow prior to building.
pip install 'tensorflow==2.17.1'
cd ~/builds/text && git checkout v2.17.0

# Build tensorflow-text.
./oss_scripts/run_build.sh
pip install ./tensorflow_text-2.17.0-cp310-cp310-macosx_*_arm64.whl 

I am facing some error related to tensorflow text specifically related to zutil.h. The logs are below for reference:

click to view detailed logs
  INFO: Build options --action_env and --enable_runfiles have changed, discarding analysis cache.
  INFO: Analyzed target //oss_scripts/pip_package:build_pip_package (248 packages loaded, 23164 targets configured).
  INFO: Found 1 target...
  ERROR: /private/var/tmp/_bazel_username/3048229dd667c6eb5e6330a6b8f832cf/external/zlib/BUILD.bazel:5:11: Compiling zutil.c [for tool] failed: (Exit 1): wrapped_clang failed: error executing command (from target @zlib//:zlib) external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG '-DNS_BLOCK_ASSERTIONS=1' ... (remaining 34 arguments skipped)
  In file included from external/zlib/zutil.c:8:
  external/zlib/zutil.h:170:11: warning: 'OS_CODE' macro redefined [-Wmacro-redefined]
    170 | #  define OS_CODE 19
        |           ^
  external/zlib/zutil.h:141:11: note: previous definition is here
    141 | #  define OS_CODE  7
        |           ^
  In file included from external/zlib/zutil.c:10:
  In file included from external/zlib/gzguts.h:21:
  In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/stdio.h:61:
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/_stdio.h:318:7: error: expected identifier or '('
    318 | FILE    *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fdopen));
        |          ^
  external/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
    147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
        |                                 ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h:26:16: note: expanded from macro 'NULL'
     26 | #define NULL ((void*)0)
        |                ^
  In file included from external/zlib/zutil.c:10:
  In file included from external/zlib/gzguts.h:21:
  In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/stdio.h:61:
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/_stdio.h:318:7: error: expected ')'
  external/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
    147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
        |                                 ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h:26:16: note: expanded from macro 'NULL'
     26 | #define NULL ((void*)0)
        |                ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/_stdio.h:318:7: note: to match this '('
  external/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
    147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
        |                                 ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h:26:15: note: expanded from macro 'NULL'
     26 | #define NULL ((void*)0)
        |               ^
  In file included from external/zlib/zutil.c:10:
  In file included from external/zlib/gzguts.h:21:
  In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/stdio.h:61:
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/_stdio.h:318:7: error: expected ')'
    318 | FILE    *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fdopen));
        |          ^
  external/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
    147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
        |                                 ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h:26:22: note: expanded from macro 'NULL'
     26 | #define NULL ((void*)0)
        |                      ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/_stdio.h:318:7: note: to match this '('
  external/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
    147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
        |                                 ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h:26:14: note: expanded from macro 'NULL'
     26 | #define NULL ((void*)0)
        |              ^
  external/zlib/zutil.c:135:22: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
    135 | const char * ZEXPORT zError(err)
        |                      ^
  external/zlib/zutil.c:307:22: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
    307 | voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
        |                      ^
  external/zlib/zutil.c:317:20: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
    317 | void ZLIB_INTERNAL zcfree(opaque, ptr)
        |                    ^
  4 warnings and 3 errors generated.
  Error in child process '/usr/bin/xcrun'. 1
  Target //oss_scripts/pip_package:build_pip_package failed to build
  Use --verbose_failures to see the command lines of failed build steps.
  INFO: Elapsed time: 5.137s, Critical Path: 2.45s
  INFO: 1447 processes: 1447 internal.
  FAILED: Build did NOT complete successfully
  ERROR: Build failed. Not running target
  zsh: no matches found: ./tensorflow_text-2.17.0-cp310-cp310-macosx_*_arm64.whl

Did anyone else face this issue? Any help on resolving it will be helpful.

Library Details for reproducing issue :

  • clang (Xcode toolchain) : 17
  • bazel : 6.5.0
  • Xcode 16.4 Build version 16F6

NarasimhanKovalai avatar Jul 26 '25 22:07 NarasimhanKovalai

Apparently, using tensorflow-text 2.18.1 and updating Xcode tools worked for me.

NarasimhanKovalai avatar Jul 27 '25 07:07 NarasimhanKovalai