Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More or less completely rewritten tensorflow-cc port #13028

Merged
merged 148 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from 142 commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
0ab169d
fix build issues occurring from default bazel config being used becau…
Jul 23, 2020
543e19d
[tensorflow-cc] Update CONTROL and ci.baseline.txt
LilyWangL Jul 24, 2020
820c455
fix also applies to windows static build
Jul 24, 2020
9643548
fix debug and static builds as well as library naming for non-linux
Aug 11, 2020
4860a01
upgrade tensorflow from v1.14 to v2.3
Aug 15, 2020
dd6d89f
fix execute process macro
Aug 15, 2020
0d611be
extend overriden execute_process to more than one COMMAND as there ac…
Aug 17, 2020
d3121ce
Merge pull request #1 from microsoft/master
jgehw Aug 17, 2020
ee969d7
merge branch 'fix-execute-process-macro2' into 'fix-static-builds-and…
Aug 17, 2020
ad5ca5f
added another patch required for tensorflow v2.3, fixed path and work…
Aug 18, 2020
c743e49
Revert "incorporate changes from microsoft:master"
jgehw Aug 18, 2020
2571bd1
Merge pull request #2 from jgehw/revert-1-master
jgehw Aug 18, 2020
98ecc0c
Revert "Revert "incorporate changes from microsoft:master""
jgehw Aug 18, 2020
ab8fdf7
Merge branch 'master' of https://github.com/microsoft/vcpkg
Aug 18, 2020
36143ac
Merge branch 'master' of https://github.com/microsoft/vcpkg
Aug 20, 2020
ea07bb9
final fixes for static build + improving out messages
Aug 20, 2020
a12d22f
enabling linux and osx in CI to see if it works now
Aug 20, 2020
6c34a08
Merge branch 'master' into fix-static-builds-and-more
jgehw Aug 20, 2020
6e31cd6
simplified code, fixed version numbers, fixed generated include cmake…
Aug 21, 2020
afc7f1e
fix failing postbuild check on handcrafted empty dummy library by spr…
Aug 21, 2020
898bbbe
remove dead code commit by mistake again
Aug 21, 2020
2ca1f94
Merge branch 'fix-static-builds-and-more' of https://github.com/jgehw…
Aug 21, 2020
1866a82
Merge branch 'master' of https://github.com/microsoft/vcpkg
Aug 21, 2020
350b151
improvements from code review
Aug 21, 2020
630e890
cleaner fix for debug code
Aug 21, 2020
2c66c4b
find pip3 in PATH (PYTHON3_DIR apparently not valid for pip3)
Aug 22, 2020
40954e4
fix error in python helper script
Aug 22, 2020
9451d33
Merge branch 'master' of https://github.com/microsoft/vcpkg
Aug 22, 2020
d198bf1
fix wrong libname in postbuild script
Aug 24, 2020
f6acaeb
fix python detection + switch to python on msys2 (instead of embedded…
Aug 24, 2020
efd0c93
fix order of arguments
jgehw Aug 24, 2020
5c1f7ae
fix command (it may contain spaces such as C:\Program Files\...)
jgehw Aug 25, 2020
3b95e18
revert last commit (root cause for CI failures is something different…
jgehw Aug 25, 2020
bfffec6
fix regex comparision
jgehw Aug 25, 2020
c9d08e9
fix linebreaks in generated file
jgehw Aug 25, 2020
2de4912
merge branch 'fix-execute-process-macro2' into 'fix-static-builds-and…
jgehw Aug 25, 2020
cdfdc65
fix CRT linkage
jgehw Aug 25, 2020
c8c12b8
refactor implemenation to avoid as much code duplication as possible …
jgehw Aug 25, 2020
71cf605
Merge branch 'master' into fix-static-builds-and-more
jgehw Aug 26, 2020
9f67738
Merge branch 'fix-static-builds-and-more' of https://github.com/jgehw…
jgehw Aug 26, 2020
5d09b86
fix version numbers in helper scripts
jgehw Aug 26, 2020
6cb4e5b
enable work-around for Windows until bazel fix is available
jgehw Aug 26, 2020
5376c01
install missing python3-pip on linux
jgehw Aug 26, 2020
692c742
fix linux build by patching
jgehw Aug 28, 2020
fbbde32
Merge branch 'master' of https://github.com/microsoft/vcpkg
jgehw Aug 28, 2020
37c3528
merge branch 'master' into 'fix-static-builds-and-more'
jgehw Aug 28, 2020
1246969
apply timeout feature now available via merged master branch
jgehw Aug 28, 2020
c918214
correct linux build patch
jgehw Aug 28, 2020
e78a3df
improve debug build patches
jgehw Aug 28, 2020
9103128
improve linux patch
jgehw Aug 28, 2020
fc4404a
temporarily add debug to inspect what's going on on macOS CI
jgehw Aug 29, 2020
cc3823d
Merge branch 'master' of https://github.com/microsoft/vcpkg
jgehw Aug 29, 2020
74cc334
remove temporary debug code and fix static linking scripts for linux …
jgehw Aug 30, 2020
ee1082f
fix regex escaping
jgehw Aug 30, 2020
381066a
fix ambiguous match while grepping for the framework link command
jgehw Aug 30, 2020
006a21a
extend fix of ambiguous match while grepping for the framework link c…
jgehw Aug 31, 2020
f7ee6c6
Merge branch 'master' of https://github.com/microsoft/vcpkg
jgehw Aug 31, 2020
b667b99
Merge branch 'master' into fix-static-builds-and-more
jgehw Sep 1, 2020
37f79c6
Merge branch 'master' of https://github.com/microsoft/vcpkg
jgehw Sep 1, 2020
d77a47c
fix what merge of master broke
jgehw Sep 1, 2020
74c4fc8
Merge branch 'master' into fix-static-builds-and-more
jgehw Sep 1, 2020
f81922c
fix more what got broken by merging master
jgehw Sep 1, 2020
f0d1c89
Merge branch 'master' of https://github.com/microsoft/vcpkg into master
jgehw Sep 2, 2020
3d8e2f2
remove "unofficial" from filename
jgehw Sep 2, 2020
2051e9e
added switch do distinct classic and manifest mode when generating co…
jgehw Sep 2, 2020
1241b67
create symlinks for libraries without version number
jgehw Sep 3, 2020
1da9b92
fix linux postbuild script
jgehw Sep 3, 2020
3df3b9b
Merge branch 'master' of https://github.com/microsoft/vcpkg into master
jgehw Sep 3, 2020
900512c
Merge branch 'master' into fix-static-builds-and-more
jgehw Sep 3, 2020
fb609b5
temporarily disable code making problems
jgehw Sep 3, 2020
ec68741
add note for linking on Linux and macOS
jgehw Sep 4, 2020
84af4a0
forget to add README file in previous commit
jgehw Sep 4, 2020
7f599a2
add file forgotton in macro fixing patch
jgehw Sep 4, 2020
067323c
Merge branch 'master' of https://github.com/microsoft/vcpkg into master
jgehw Sep 8, 2020
b8e9523
Merge branch 'master' of https://github.com/microsoft/vcpkg into master
jgehw Sep 10, 2020
bcda036
Merge branch 'master' into fix-static-builds-and-more
jgehw Sep 10, 2020
e4f15a8
fix python library path
jgehw Sep 11, 2020
da3cb5a
fix macOS static link command
jgehw Sep 11, 2020
7273f86
update linkage instructions in README
jgehw Sep 11, 2020
fdc5cf6
Update ports/tensorflow-cc/CONTROL
JackBoosY Sep 14, 2020
05be090
Update ports/tensorflow-cc/portfile.cmake
JackBoosY Sep 14, 2020
faf3447
Update scripts/ci.baseline.txt
JackBoosY Sep 14, 2020
3787012
use vcpkg_execute_required_process
jgehw Sep 14, 2020
0877229
pass C_FLAGS and CXX_FLAGS to bazel
jgehw Sep 14, 2020
eaf1d7c
fix INTERFACE_INCLUDE_DIRECTORIES
jgehw Sep 14, 2020
0a986ac
fix optional c/cxx arguments
jgehw Sep 17, 2020
bb63d8c
also add linker opts
jgehw Sep 22, 2020
79076a2
Merge branch 'pass-cflags-to-bazel' into fix-static-builds-and-more
jgehw Sep 30, 2020
ca81fb9
update README
jgehw Sep 30, 2020
8e16503
merge static libs into one
Oct 1, 2020
8677bdb
update README
Oct 1, 2020
39312c7
Merge branch 'master' of https://github.com/microsoft/vcpkg
Oct 1, 2020
79a26c8
Merge branch 'master' into fix-static-builds-and-more
Oct 1, 2020
6384898
Merge branch 'master' of https://github.com/microsoft/vcpkg into master
jgehw Oct 9, 2020
533895b
Merge branch 'master' into fix-static-builds-and-more
jgehw Oct 9, 2020
2ad839b
Merge branch 'master' of https://github.com/microsoft/vcpkg into master
jgehw Oct 15, 2020
f4e64da
Merge branch 'master' of https://github.com/microsoft/vcpkg into master
jgehw Oct 21, 2020
180925f
quote python path (it might contain spaces that don't get escaped ins…
jgehw Oct 22, 2020
4584d3a
fix python path also for static build
jgehw Oct 24, 2020
49f6f38
add arm(64) as currently unsupported arch
jgehw Oct 24, 2020
a174637
bazel 3.7 is available -> remove workaround
jgehw Oct 24, 2020
292013f
update README, remove necessary c-ares from deps
jgehw Oct 24, 2020
f8e004c
update msys package
Oct 24, 2020
a259f33
Merge branch 'fix-static-builds-and-more' of https://github.com/jgehw…
Oct 24, 2020
0ab5c4e
add uwp specific options, and minor general improvements
Oct 25, 2020
920af34
fix string replace
Oct 25, 2020
6594588
fix control file and windows path separator
Oct 25, 2020
0a22920
revert backslashes-fix -- the root cause was missing .exe extension
Oct 25, 2020
4ef9252
upgrade to tf 2.3.1
Oct 25, 2020
41e2f80
fix hard-coded version
Oct 25, 2020
7fa2689
Merge branch 'master' into fix-static-builds-and-more
jgehw Oct 26, 2020
fe1d24c
Merge branch 'master' of https://github.com/microsoft/vcpkg into master
jgehw Oct 27, 2020
ff1d1c9
Merge branch 'master' into fix-static-builds-and-more
jgehw Oct 27, 2020
f064862
remove uwp work-in-progress code so that PR can be merged
jgehw Oct 27, 2020
4840250
update README and print out usage info in portfile
jgehw Nov 4, 2020
675068f
Update ports/tensorflow-cc/README-linux
jgehw Nov 4, 2020
2c3de43
Update ports/tensorflow-cc/README-linux
jgehw Nov 4, 2020
a7173f2
Update ports/tensorflow-cc/README-linux
jgehw Nov 4, 2020
d500d06
Update ports/tensorflow-cc/README-linux
jgehw Nov 4, 2020
4bc588b
Update ports/tensorflow-cc/README-linux
jgehw Nov 4, 2020
45a721b
Update ports/tensorflow-cc/README-windows
jgehw Nov 4, 2020
afaf836
Update ports/tensorflow-cc/portfile.cmake
jgehw Nov 4, 2020
d565994
Update ports/tensorflow-cc/portfile.cmake
jgehw Nov 4, 2020
ec37f99
Update ports/tensorflow-cc/portfile.cmake
jgehw Nov 4, 2020
7a0d1b7
Update ports/tensorflow-cc/portfile.cmake
jgehw Nov 4, 2020
3766dea
Update ports/tensorflow-cc/portfile.cmake
jgehw Nov 4, 2020
6fb73d6
improve usage hints as discussed in review
jgehw Nov 4, 2020
0712306
add comment
jgehw Nov 4, 2020
f18d6e4
apply changes from review
jgehw Nov 4, 2020
bc2280b
make additional compiler / linker args space-proof
jgehw Nov 4, 2020
92e22cf
Update ports/tensorflow-cc/README-macos
jgehw Nov 5, 2020
50880ac
Update ports/tensorflow-cc/tensorflow-cc-config-shared.cmake.in
jgehw Nov 5, 2020
d9bdd5c
Update ports/tensorflow-cc/tensorflow-cc-config-shared.cmake.in
jgehw Nov 5, 2020
9422a8a
Update ports/tensorflow-cc/README-linux
jgehw Nov 5, 2020
82b8d21
Update ports/tensorflow-cc/README-macos
jgehw Nov 5, 2020
c9bb7c7
apply changes from code review
jgehw Nov 5, 2020
a38c40c
maybe fix the config files
strega-nil Nov 7, 2020
a4b211a
rob.maynard CRs
strega-nil Nov 7, 2020
0f29899
fix windows static lib naming for first part
jgehw Nov 7, 2020
961d5db
Update ports/tensorflow-cc/generate_static_link_cmd_windows.py
jgehw Nov 9, 2020
948faf1
apply rob maynards 1st suggestion
jgehw Nov 9, 2020
901938b
nicole CRs
strega-nil Nov 9, 2020
1c413c8
Merge remote-tracking branch 'upstream/master' into fix-static-builds…
strega-nil Nov 10, 2020
f636962
format/fix-compile
strega-nil Nov 10, 2020
c46795f
fix missing string termination
jgehw Nov 10, 2020
842631e
prefer IMPORTED_LOCATION over IMPORTED_LOCATION_RELEASE to have defau…
jgehw Nov 10, 2020
dd8f4a9
hopefully fix the issue where no libraries are generated
strega-nil Nov 11, 2020
2fae377
final stuff
strega-nil Nov 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ports/tensorflow-cc/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Source: tensorflow-cc
Version: 1.14
Port-Version: 5
Version: 2.3.1
Description: Library for computation using data flow graphs for scalable machine learning
Build-Depends: c-ares
Supports: !x86
Supports: !(x86|arm|uwp)
13 changes: 13 additions & 0 deletions ports/tensorflow-cc/README-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Warning: Static TensorFlow build contains several external dependencies that may cause linking conflicts
(for example, one cannot use both openssl and TensorFlow in the same project, since TensorFlow contains boringssl).

Note: Besides TensorFlow itself, you'll also need to pass its dependencies to the linker:
* libm
* libdl
* libpthread
for example, '-ltensorflow_cc -lm -ldl -lpthread'.

Note: There is no separate libtensorflow_framework.a as it got merged into libtensorflow_cc.a to avoid linking conflicts.

Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to tell the linker to include the whole library:
'-Wl,--whole-archive -ltensorflow_cc -Wl,--no-whole-archive [rest of linker arguments]'
12 changes: 12 additions & 0 deletions ports/tensorflow-cc/README-macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Warning: Static TensorFlow build contains several external dependencies that may cause linking conflicts
(for example, one cannot use both openssl and TensorFlow in the same project, since TensorFlow contains boringssl).

Note: Besides TensorFlow itself, you'll also need to pass its dependencies to the linker:
* CoreFoundation
* Security (only when linking against the whole library, see below)
for example, '-ltensorflow_cc -framework CoreFoundation -framework Security'.

Note: There is no separate libtensorflow_framework.a as it got merged into libtensorflow_cc.a to avoid linking conflicts.

Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to tell the linker to include the whole library:
'-Wl,-force_load,path/to/libtensorflow_cc.a [rest of linker arguments]'
5 changes: 5 additions & 0 deletions ports/tensorflow-cc/README-windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Warning: Static TensorFlow build contains several external dependencies that may cause linking conflicts
(for example, one cannot use both openssl and TensorFlow in the same project, since TensorFlow contains boringssl).

Note: For some TensorFlow features (e.g. OpRegistry), it might be necessary to convince the linker to include the whole library, i.e., link using options
'/WHOLEARCHIVE:tensorflow_cc.lib /WHOLEARCHIVE:tensorflow_cc-part2.lib /WHOLEARCHIVE:tensorflow_cc-part3.lib ...'
28 changes: 0 additions & 28 deletions ports/tensorflow-cc/TensorflowCCConfig.cmake

This file was deleted.

266 changes: 266 additions & 0 deletions ports/tensorflow-cc/change-macros-for-static-lib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
diff --git a/tensorflow/core/platform/macros.h b/tensorflow/core/platform/macros.h
--- a/tensorflow/core/platform/macros.h
+++ b/tensorflow/core/platform/macros.h
@@ -57,16 +57,7 @@
#define TF_SCANF_ATTRIBUTE(string_index, first_to_check)
#endif

-// Control visibility outside .so
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_EXPORT __declspec(dllexport)
-#else
-#define TF_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
+#define TF_EXPORT

#ifdef __has_builtin
#define TF_HAS_BUILTIN(x) __has_builtin(x)

diff --git a/tensorflow/c/c_api.h b/tensorflow/c/c_api.h
--- a/tensorflow/c/c_api.h
+++ b/tensorflow/c/c_api.h
@@ -70,24 +70,7 @@
// and the API just provides high level controls over the number of
// devices of each type.

-// Macro to control visibility of exported symbols in the shared library (.so,
-// .dylib, .dll).
-// This duplicates the TF_EXPORT macro definition in
-// tensorflow/core/platform/macros.h in order to keep this .h file independent
-// of any other includes.
-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#ifdef __cplusplus
extern "C" {

diff --git a/tensorflow/c/c_api_experimental.h b/tensorflow/c/c_api_experimental.h
--- a/tensorflow/c/c_api_experimental.h
+++ b/tensorflow/c/c_api_experimental.h
@@ -28,24 +28,7 @@
// The API here is subject to changes in the future.
// --------------------------------------------------------------------------

-// Macro to control visibility of exported symbols in the shared library (.so,
-// .dylib, .dll).
-// This duplicates the TF_EXPORT macro definition in
-// tensorflow/core/platform/macros.h in order to keep this .h file independent
-// of any other includes.$a
-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#ifdef __cplusplus
extern "C" {

diff --git a/tensorflow/c/c_api_macros.h b/tensorflow/c/c_api_macros.h
--- a/tensorflow/c/c_api_macros.h
+++ b/tensorflow/c/c_api_macros.h
@@ -16,18 +16,6 @@
#ifndef TENSORFLOW_C_C_API_MACROS_H_
#define TENSORFLOW_C_C_API_MACROS_H_

-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#endif // TENSORFLOW_C_C_API_MACROS_H_

diff --git a/tensorflow/c/kernels.h b/tensorflow/c/kernels.h
--- a/tensorflow/c/kernels.h
+++ b/tensorflow/c/kernels.h
@@ -21,24 +21,7 @@
#include "tensorflow/c/tf_datatype.h"
#include "tensorflow/c/tf_status.h"

-// Macro to control visibility of exported symbols in the shared library (.so,
-// .dylib, .dll).
-// This duplicates the TF_EXPORT macro definition in
-// tensorflow/core/platform/macros.h in order to keep this .h file independent
-// of any other includes.
-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#ifdef __cplusplus
extern "C" {

diff --git a/tensorflow/c/ops.h b/tensorflow/c/ops.h
--- a/tensorflow/c/ops.h
+++ b/tensorflow/c/ops.h
@@ -76,19 +76,7 @@
#include "tensorflow/c/tf_datatype.h"
#include "tensorflow/c/tf_status.h"

-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#ifdef __cplusplus
extern "C" {

diff --git a/tensorflow/c/tf_datatype.h b/tensorflow/c/tf_datatype.h
--- a/tensorflow/c/tf_datatype.h
+++ b/tensorflow/c/tf_datatype.h
@@ -18,24 +18,7 @@

#include <stddef.h>

-// Macro to control visibility of exported symbols in the shared library (.so,
-// .dylib, .dll).
-// This duplicates the TF_EXPORT macro definition in
-// tensorflow/core/platform/macros.h in order to keep this .h file independent
-// of any other includes.
-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#ifdef __cplusplus
extern "C" {

diff --git a/tensorflow/c/tf_status.h b/tensorflow/c/tf_status.h
--- a/tensorflow/c/tf_status.h
+++ b/tensorflow/c/tf_status.h
@@ -16,19 +16,7 @@
#ifndef TENSORFLOW_C_TF_STATUS_H_
#define TENSORFLOW_C_TF_STATUS_H_

-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#ifdef __cplusplus
extern "C" {

diff --git a/tensorflow/c/tf_tensor.h b/tensorflow/c/tf_tensor.h
--- a/tensorflow/c/tf_tensor.h
+++ b/tensorflow/c/tf_tensor.h
@@ -22,24 +22,7 @@
#include "tensorflow/c/tf_datatype.h"
#include "tensorflow/c/tf_status.h"

-// Macro to control visibility of exported symbols in the shared library (.so,
-// .dylib, .dll).
-// This duplicates the TF_EXPORT macro definition in
-// tensorflow/core/platform/macros.h in order to keep this .h file independent
-// of any other includes.
-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#ifdef __cplusplus
extern "C" {

diff --git a/tensorflow/c/eager/c_api.h b/tensorflow/c/eager/c_api.h
--- a/tensorflow/c/eager/c_api.h
+++ b/tensorflow/c/eager/c_api.h
@@ -22,24 +22,7 @@

#include "tensorflow/c/c_api.h"

-// Macro to control visibility of exported symbols in the shared library (.so,
-// .dylib, .dll).
-// This duplicates the TF_EXPORT macro definition in
-// tensorflow/core/platform/macros.h in order to keep this .h file independent
-// of any other includes.$a
-#ifdef SWIG
#define TF_CAPI_EXPORT
-#else
-#if defined(_WIN32)
-#ifdef TF_COMPILE_LIBRARY
-#define TF_CAPI_EXPORT __declspec(dllexport)
-#else
-#define TF_CAPI_EXPORT __declspec(dllimport)
-#endif // TF_COMPILE_LIBRARY
-#else
-#define TF_CAPI_EXPORT __attribute__((visibility("default")))
-#endif // _WIN32
-#endif // SWIG

#ifdef __cplusplus
extern "C" {
29 changes: 29 additions & 0 deletions ports/tensorflow-cc/convert_lib_params_linux.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import sys

version = sys.argv[1]

with open(f"libtensorflow_cc.a.{version}-2.params", "w") as f_out:
parts = []
with open(f"libtensorflow_framework.so.{version}-2.params", "r") as f_in:
skip_next = False
for line in f_in:
if skip_next:
skip_next = False
continue
if line.startswith("-o"):
skip_next = True
elif line.startswith("bazel-out"):
f_out.write(line)
parts.append(line)
parts = set(parts)
with open(f"libtensorflow_cc.so.{version}-2.params", "r") as f_in:
skip_next = False
for line in f_in:
if skip_next:
skip_next = False
continue
if line.startswith("-o"):
skip_next = True
elif line.startswith("bazel-out"):
if line not in parts:
f_out.write(line)
27 changes: 27 additions & 0 deletions ports/tensorflow-cc/convert_lib_params_windows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
import sys

file_no = 1
with open("tensorflow_cc.dll-2.params", "r") as f_in:
lib_name = None
acc_size = 0
f_out = open("tensorflow_cc.lib-2.params-part1", "w")
for line in f_in:
if line.startswith("/OUT:"):
lib_name = line
line = line.replace(".dll", ".lib")
f_out.write(line)
elif line.startswith("/WHOLEARCHIVE:"):
line = line[len("/WHOLEARCHIVE:"):]
size = os.stat(f"../../{line.strip()}").st_size
if acc_size + size > 0xFFFFFFFF:
# we need to split the library if it is >4GB, because it's not supported even on x64 Windows
f_out.close()
file_no += 1
f_out = open(f"tensorflow_cc.lib-2.params-part{file_no}", "w")
acc_size = 0
f_out.write(lib_name.replace(".dll", f"-part{file_no}.lib"))
acc_size += size
f_out.write(line)
f_out.close()

Loading