Skip to content

stdlib: remove unnecessarily complex library detection #29062

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

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions stdlib/public/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ endif()
# SWIFT_ENABLE_TENSORFLOW
if(SWIFT_BUILD_STDLIB)
add_subdirectory(Python)
endif()

# SWIFT_ENABLE_TENSORFLOW
# Note: Python should be built before TensorFlow because Python is a
# dependency for `numpy.ndarray` bridging to `ShapedArray`/`Tensor`.
if(SWIFT_BUILD_STDLIB AND SWIFT_ENABLE_TENSORFLOW)
# TODO: Add TensorFlow support for iOS/Raspberry Pi.
add_subdirectory(CTensorFlow)
add_subdirectory(TensorFlow)
# Note: Python should be built before TensorFlow because Python is a
# dependency for `numpy.ndarray` bridging to `ShapedArray`/`Tensor`.
if(SWIFT_ENABLE_TENSORFLOW)
# TODO: Add TensorFlow support for iOS/Raspberry Pi.
add_subdirectory(CTensorFlow)
add_subdirectory(TensorFlow)
endif()
endif()
# SWIFT_ENABLE_TENSORFLOW END

if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR)
add_subdirectory(Reflection)
Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#
#===----------------------------------------------------------------------===#

set(SWIFT_PYTHON_EXISTS TRUE PARENT_SCOPE)

set(SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES)
if(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY)
list(APPEND SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES SHARED)
Expand Down
9 changes: 1 addition & 8 deletions stdlib/public/TensorFlow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ if (TENSORFLOW_SWIFT_APIS)
endforeach()
endif()

# When Python exists, PythonConversion.swift imports it, so it must be
# available at link time.
set(TENSORFLOW_DEPENDS_PYTHON)
if (SWIFT_PYTHON_EXISTS)
list(APPEND TENSORFLOW_DEPENDS_PYTHON SWIFT_MODULE_DEPENDS Python)
endif()

add_swift_target_library(swiftTensorFlow ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
"${SOURCES}"

Expand All @@ -67,7 +60,7 @@ add_swift_target_library(swiftTensorFlow ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_
SWIFT_MODULE_DEPENDS_CYGWIN Glibc
SWIFT_MODULE_DEPENDS_HAIKU Glibc
SWIFT_MODULE_DEPENDS_WINDOWS MSVCRT
${TENSORFLOW_DEPENDS_PYTHON}
SWIFT_MODULE_DEPENDS Python
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, making Python an explicit (rather than informal) dependency of TensorFlow is good.

However, only a small portion of TensorFlow depends on Python. Eventually, we may want to add a TensorFlow+Python module. Related discussion on "cross-import overlays".

Perhaps the Python dependency issue will go away or change in nature when TensorFlow is no longer built as part of the standard library: tensorflow/swift-apis#488.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely would be nice to have the ability to not have Python used. However, I think that we currently do not have that ability so this is simply structuring the code to be simpler in light of that. I think that when the time comes, providing a user controllable knob to enable the dependency is a better approach. The user knows what they want, we do not need to infer it, and that still would avoid the ad-hoc state tracking.

SWIFT_COMPILE_FLAGS "${swift_stdlib_compile_flags}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
INSTALL_IN_COMPONENT stdlib
Expand Down