tensorflow / swift-apis

Swift for TensorFlow Deep Learning Library
Apache License 2.0
794 stars 133 forks source link

cmake on MacOS - error: cannot load underlying module for 'XCTest' #1028

Closed mikowals closed 4 years ago

mikowals commented 4 years ago

Using the MacOS development toolchain from 2020-06-25 and the following commands:

cmake -B out -G Ninja -S swift-apis -D USE_BUNDLED_X10=YES -D USE_BUNDLED_CTENSORFLOW=YES  \
            -D CMAKE_Swift_COMPILER=/Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2020-06-25-a.xctoolchain/usr/bin/swiftc

cmake --build out

Gets the output with error:

[2/14] Linking Swift shared library Tests/ExperimentalTests/libExperimentalTests.dylib
FAILED: Tests/ExperimentalTests/libExperimentalTests.dylib                
Tests/ExperimentalTests/CMakeFiles/ExperimentalTests.dir/ComplexTests.swift.o  
Tests/ExperimentalTests/CMakeFiles/ExperimentalTests.dir/XCTestManifests.swift.o swift/ExperimentalTests.swiftmodule
: && /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2020-06-25-a.xctoolchain/usr/bin/swiftc -output-file-   
map Tests/ExperimentalTests/CMakeFiles/ExperimentalTests.dir/Release/output-file-map.json -incremental -j 4 -emit-
library -  o Tests/ExperimentalTests/libExperimentalTests.dylib -module-name ExperimentalTests -module-link-name   
ExperimentalTests -emit-module -emit-module-path swift/ExperimentalTests.swiftmodule -emit-dependencies -
DExperimentalTests_EXPORTS -O -sdk /Applications/Xcode-
beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.16.sdk   -Xllvm -sil-inline-generics -
Xllvm -sil-partial-specialization -I swift /Users/mikowals/projects/swift-source/swift-
apis/Tests/ExperimentalTests/ComplexTests.swift /Users/mikowals/projects/swift-source/swift-
apis/Tests/ExperimentalTests/XCTestManifests.swift  -Xlinker -install_name -Xlinker @rpath/libExperimentalTests.dylib  -L 
/Users/mikowals/projects/swift-source/out/Sources/third_party/Experimental -Xlinker -rpath -Xlinker 
/Users/mikowals/projects/swift-source/out/Sources/third_party/Experimental  
Sources/third_party/Experimental/libExperimental.dylib  -lXCTest && :
/Users/mikowals/projects/swift-source/swift-apis/Tests/ExperimentalTests/ComplexTests.swift:15:8: error: cannot load underlying module for 'XCTest'
import XCTest
   ^
[3/14] Linking Swift shared library Sources/Tensor/libTensor.dylib
ninja: build stopped: subcommand failed.
dan-zheng commented 4 years ago

Does adding -D BUILD_TESTING=NO to the first CMake invocation fix the issue?

Building tests on macOS is not yet supported: https://github.com/tensorflow/swift-apis/pull/1029 updates README instructions with a clarification.

@compnerd: do you know if we can support building tests on macOS?

mikowals commented 4 years ago

Yes, adding -D BUILD_TESTING=NO works. I didn't know testing on macOS wasn't supported. Thanks for updating documentation.

compnerd commented 4 years ago

Yes, it’s possible. There’s two options:

Both of these will require some additional flags (unless we package xctest in the toolchain).