Hello! Here is an information for whom it can help and also for the port maintainer. To fix the build add path /usr/local/llvm-devel/lib/clang/16/include to /usr/ports/science/py-tensorflow/files/freebsd/cc_toolchain_config.bzl on line 228 So it looks now like this: cxx_builtin_include_directories = ["/usr/local/llvm-devel/lib/clang/16.0.0", "/usr/local/llvm-devel/lib/clang/16/include", "/usr/include/c++/v1", "/usr/local/include", "/usr/include"] That path contains builtin headers for native optimizations. I also did a hack for abseil library: fetch https://raw.githubusercontent.com/abseil/abseil-cpp/master/absl/meta/type_traits.h -o /usr/local/include/absl/meta/type_traits.h Because that file was almost completely rewritten by authors. And current ports version does not support clang 16.
I also have a problem: ld: error: version script assignment of 'local' to symbol 'jdiv_round_up' failed: symbol not defined ld: error: version script assignment of 'local' to symbol 'jround_up' failed: symbol not defined ld: error: version script assignment of 'local' to symbol 'jzero_far' failed: symbol not defined clang-16: error: linker command failed with exit code 1 (use -v to see invocation) Because jpeg-turbo version is not compatible. Didn't fix it yet
To fix it just remove jdiv_round_up, jround_up and jzero_far lines from /usr/ports/science/py-tensorflow/work-py39/tensorflow-2.9.1/tensorflow/tf_framework_version_script.lds
The next error: ld: error: version script assignment of 'global' to symbol 'init_pywrap_tensorflow_lite_calibration_wrapper' failed: symbol not defined ld: error: version script assignment of 'global' to symbol 'init__pywrap_tensorflow_lite_calibration_wrapper' failed: symbol not defined
Well, commented lines 2889 and 2890 in /usr/ports/science/py-tensorflow/work-py39/tensorflow-2.9.1/tensorflow/tensorflow.bzl The build continues. Do not know if it breaks anything..
The next error: ld: error: version script assignment of 'tensorflow' to symbol 'init_pywrap_tensorflow_internal' failed: symbol not defined ld: error: version script assignment of 'tensorflow' to symbol '_init_pywrap_tensorflow_internal' failed: symbol not defined
Created attachment 241069 [details] Patch 1
Created attachment 241070 [details] Patch 2
Created attachment 241071 [details] Patch 3
(In reply to Ivan from comment #4) This is not needed anymore. Use the patches
Created attachment 241072 [details] Patch 4
Finally, I did it! These patches are required to build. Please update the port.
I hope the maintainer will update the port.
Thanks Ivan, I will run the build.
Created attachment 241223 [details] Consolidated and applicable diff. Hi, I have also trying to get TF running for a while, well spotted. Patches are a bit messy, trying to apply to $WRKDIR, I've managed to generate a diff that can be applied to the port tree and it builds fine in poudriere -- now I'm trying to get stuff running.
Thanks Matthieu! Are you sure you want to switch this port to llvm17?
I dont really want, but for a reason py-tensorflow is build with llvm-devel and now that llvm 16 is released, the llvm-devel port is future llvm 17. Indeed the port could switch to devel/llvm16 ? That would ease my rebuilds :)
Oh, I see now. Yes, switching to devel/llvm16 is much preferable. Who can do this?
devel/llvm16 would be preferred. You can submit a patch for this, if possible.
Created attachment 241226 [details] Consolidated and applicable diff + USE llvm:16 rather llvm-devel I think this should do it. I've switched llvm-devel from BUILD_DEPENDS to the USE, I think hardcoding to 16 both in Makefile and patches is a bit crude, I'll try maybe later to rather have USE= llvm:min:16 and sed the right version in the files. I'm submitting the patch early without full testing, I apologize, the build will take some time even for my work computer (I have to build both llvm16 and tensorflow without any ccaching now), but I thought better submit it when I'm working on this :)
Thanks Matthieu. The patch looks good! Have you stumbled over the abseil library problem?
Any llvm version > 16 will work, it was needed for CPU optimizations at the time when I worked on it last. For the patches I wouldn't hardcode /usr/local, but rather use %%LOCALBASE%% in the patch files and use sed to correct to whatever $LOCALBASE someone has set in their enviroment.
Yeah, it is even LLVM_PREFIX and some LLVM_VERSION substitions, I'll have a look while llvm16 is still building.
Created attachment 241227 [details] Consolidated and applicable diff + USE llvm:16 rather llvm-devel Ho, there was even already a substitution command ready, this becomes quite easy to update then. devel/llvm16 is still building, I'll post an update unless somebody is quicker than me to validate or find something wrong.
Matthieu's patch looks great. Please test it
(In reply to Ivan from comment #24) Ok, thank you. Will test.
Committed. Thank you, guys, for unbreaking the TensorFlow port!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=576c2c36a8135b6162c4b644e49f9bd3a1d4e925 commit 576c2c36a8135b6162c4b644e49f9bd3a1d4e925 Author: Yuri Victorovich <yuri@FreeBSD.org> AuthorDate: 2023-04-01 00:29:09 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2023-04-01 00:32:32 +0000 science/py-tensorflow: Unbreak build PR: 270411 Submitted by: Ivan <ivan@drm.su>, Matthieu Volat <mazhe@alkumuna.eu> Approved by: portmgr (unbreak) science/py-tensorflow/Makefile | 14 +++++++----- .../files/freebsd/cc_toolchain_config.bzl | 9 ++++---- science/py-tensorflow/files/patch-tensorflow_BUILD | 19 +++++++++++----- .../files/patch-tensorflow_java_BUILD (new) | 10 +++++++++ .../files/patch-tensorflow_lite_BUILD (new) | 10 +++++++++ .../patch-tensorflow_lite_build_def.bzl (new) | 10 +++++++++ .../files/patch-tensorflow_lite_c_BUILD (new) | 10 +++++++++ ...sorflow_lite_delegates_flex_build_def.bzl (new) | 10 +++++++++ ...w_lite_delegates_hexagon_hexagon_nn_BUILD (new) | 10 +++++++++ .../files/patch-tensorflow_tensorflow.bzl (new) | 26 ++++++++++++++++++++++ ...ensorflow_tf_framework_version_script.lds (new) | 12 ++++++++++ 11 files changed, 126 insertions(+), 14 deletions(-)
Amazing! Thanks! PS: May be bump the version up in a new bug here?
(In reply to Ivan from comment #28) +1