The repository '@llvm_zlib' could not be resolved and referenced by '@llvm-project//llvm:Support'
Hi @BealZephyr ,

Thanks for reporting the issue. The problem might be related to `zlib` version.  To confirm that could you try build with TF2.10 version and confirm whether it works ?

Alternatively please replace the below code in master branch
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/workspace2.bzl#LL578C1-L585C1
with 
https://github.com/tensorflow/tensorflow/blob/r2.10/tensorflow/workspace2.bzl#L564-L571 

and also the below line from master branch
https://github.com/tensorflow/tensorflow/blob/master/third_party/png.BUILD#LL64C1
to 
https://github.com/tensorflow/tensorflow/blob/r2.10/third_party/png.BUILD#L64

After the above changes try to build again and let us know the outcome.

Thanks! Hi @SuryanarayanaY ,

Thank you for your prompt response. I followed your recommendations and tried to build with [TF2.10](https://github.com/tensorflow/tensorflow/tree/r2.10), but it still failed. The error message appears as follows:

```
ERROR: /workdir2/tensorflow/tensorflow/compiler/mlir/hlo/BUILD:2091:11: no such target '@llvm-project//mlir:AsmParser': target 'AsmParser' not declared in package 'mlir' (did you mean 'Parser'?) defined by /root/.cache/bazel/_bazel_root/1bd8bd6e381aed66bea8b87fef9055ba/external/llvm-project/mlir/BUILD.bazel and referenced by '//tensorflow/compiler/mlir/hlo:propagate_static_shapes_to_kernel'
ERROR: Analysis of target '//tensorflow/compiler/mlir:tf-opt' failed; build aborted:
INFO: Elapsed time: 0.493s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (2 packages loaded, 0 targets configured)
```
I also tried to build with [master](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir) branch by replacing workspace2.bzl and png.BUILD, and I encountered the following error:

```
ERROR: /root/.cache/bazel/_bazel_root/1bd8bd6e381aed66bea8b87fef9055ba/external/llvm-project/llvm/BUILD.bazel:184:11: no such package '@llvm_zstd//': The repository '@llvm_zstd' could not be resolved: Repository '@llvm_zstd' is not defined and referenced by '@llvm-project//llvm:Support'
WARNING: Download from https://golang.org/dl/?mode=json&include=all failed: class java.io.IOException connect timed out
ERROR: Analysis of target '//tensorflow/compiler/mlir:tf-opt' failed; build aborted:
INFO: Elapsed time: 0.302s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)
    currently loading: tensorflow/lite/schema
    Fetching repository @stablehlo; starting
```
I tried a lot, but it didn't work. .Can you take a look at it for me？ I just want to mention that I had the same problem as @BealZephyr and the suggested change (which I see are already implmented on the main branch) did not help.  HI, Same problem as the OP. In my case, the error message is as follows: 

``` 
 no such package '@llvm_zlib//': The repository '@llvm_zlib' could not be resolved: Repository '@llvm_zlib' is not defined and referenced by '@llvm-project//llvm:Support'
ERROR: Analysis of target '//tensorflow/compiler/mlir:tf-opt' failed; build aborted:

``` Related to #62384  > ```
>  no such package '@llvm_zlib//': The repository '@llvm_zlib' could not be resolved: Repository '@llvm_zlib' is not defined and referenced by '@llvm-project//llvm:Support'
> ERROR: Analysis of target '//tensorflow/compiler/mlir:tf-opt' failed; build aborted:
> ```

I am getting the same error.

Since tensorflow is compiled with `clang-17`. I thought if I checkout the tag `llvmorg-17.0.6` in `llvm-project`, it might work. Still no luck. 

How do we do this? This could be a possible workaround?

https://github.com/tensorflow/tensorflow/issues/69367#issuecomment-2155693927
<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Build/Install

### Have you reproduced the bug with TF nightly?

No

### Source

source

### Tensorflow Version

master

### Custom Code

Yes

### OS Platform and Distribution

Linux Ubuntu 18.04

### Mobile device

_No response_

### Python version

3.9

### Bazel version

6.1.0

### GCC/Compiler version

7.5.0

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

tf-opt Build failure!

### Standalone code to reproduce the issue

```shell
build MLIR:
 -G Ninja ../llvm \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON\
-DCMAKE_C_COMPILER=/home/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang\
-DCMAKE_CXX_COMPILER=/home/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang++ \
-DLLVM_ENABLE_ZLIB=ON\
-DLLVM_ENABLE_ZLIB=ON\
-DLLVM_ENABLE_ZSTD=ON

bazel build:
bazel build --override_repository="llvm-raw=${LLVM_SRC}"   \
-c opt tensorflow/compiler/mlir:tf-opt```



### Relevant log output

```shell
ERROR: /root/.cache/bazel/_bazel_root/58adfe0c0193ce259b2b32549c3d3a4f/external/llvm-project/llvm/BUILD.bazel:184:11: no such package '@llvm_zlib//': The repository '@llvm_zlib' could not be resolved: Repository '@llvm_zlib' is not defined and referenced by '@llvm-project//llvm:Support'
ERROR: Analysis of target '//tensorflow/compiler/mlir:tf-opt' failed; build aborted:
INFO: Elapsed time: 2.104s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (198 packages loaded, 3560 targets configured)
```
</details>