Skip to content

Commit bc07842

Browse files
committed
Merge branch 'pr-3436-leaks' (Fixes #3436 and #3451)
2 parents bcfc748 + c631885 commit bc07842

File tree

10 files changed

+64
-21
lines changed

10 files changed

+64
-21
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ doc/xml-c
3838
doc/xml-java
3939
doc/xml-dotnet
4040
convert_graphdef_memmapped_format
41+
native_client/swift/deepspeech_ios.framework/deepspeech_ios

native_client/BUILD

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Description: Deepspeech native client library.
22

3-
load("@org_tensorflow//tensorflow:tensorflow.bzl", "tf_cc_shared_object")
3+
load("@org_tensorflow//tensorflow:tensorflow.bzl", "tf_cc_shared_object", "tf_copts", "lrt_if_needed")
44
load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda")
55
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
6+
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_static_framework")
67

78
load(
89
"@org_tensorflow//tensorflow/lite:build_def.bzl",
@@ -110,8 +111,8 @@ cc_library(
110111
],
111112
)
112113

113-
tf_cc_shared_object(
114-
name = "libdeepspeech.so",
114+
cc_library(
115+
name = "deepspeech_bundle",
115116
srcs = [
116117
"deepspeech.cc",
117118
"deepspeech.h",
@@ -130,7 +131,7 @@ tf_cc_shared_object(
130131
"tfmodelstate.cc",
131132
],
132133
}),
133-
copts = select({
134+
copts = tf_copts() + select({
134135
# -fvisibility=hidden is not required on Windows, MSCV hides all declarations by default
135136
"//tensorflow:windows": ["/w"],
136137
# -Wno-sign-compare to silent a lot of warnings from tensorflow itself,
@@ -143,7 +144,7 @@ tf_cc_shared_object(
143144
"//native_client:tflite": ["-DUSE_TFLITE"],
144145
"//conditions:default": ["-UUSE_TFLITE"],
145146
}) + tflite_copts(),
146-
linkopts = select({
147+
linkopts = lrt_if_needed() + select({
147148
"//tensorflow:macos": [],
148149
"//tensorflow:ios": ["-fembed-bitcode"],
149150
"//tensorflow:linux_x86_64": LINUX_LINKOPTS,
@@ -203,6 +204,19 @@ tf_cc_shared_object(
203204
]) + [":decoder"],
204205
)
205206

207+
tf_cc_shared_object(
208+
name = "libdeepspeech.so",
209+
deps = [":deepspeech_bundle"],
210+
)
211+
212+
ios_static_framework(
213+
name = "deepspeech_ios",
214+
deps = [":deepspeech_bundle"],
215+
families = ["iphone", "ipad"],
216+
minimum_os_version = "9.0",
217+
linkopts = ["-lstdc++"],
218+
)
219+
206220
genrule(
207221
name = "libdeepspeech_so_dsym",
208222
srcs = [":libdeepspeech.so"],
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Pull in version from outside
2+
version = File.read(File.join(__dir__, "../../training/deepspeech_training/VERSION")).split("\n")[0]
3+
4+
Pod::Spec.new do |s|
5+
s.name = "deepspeech-ios"
6+
s.version = version
7+
s.summary = "DeepSpeech"
8+
s.homepage = "https://github.com/mozilla/DeepSpeech"
9+
s.license = "Mozilla Public License 2.0"
10+
s.authors = "Mozilla et al."
11+
12+
s.platforms = { :ios => "9.0" }
13+
s.source = { :git => "https://github.com/mozilla/DeepSpeech.git", :tag => "v#{s.version}" }
14+
15+
# Assuming taskcluster build location. Depending on your Xcode setup, this might be in
16+
# build/Release-iphoneos/deepspeech_ios.framework instead.
17+
s.vendored_frameworks = "native_client/swift/DerivedData/Build/Products/Release-iphoneos/deepspeech_ios.framework"
18+
s.source_files = "native_client/swift/deepspeech_ios/**/*.{h,m,mm,swift}"
19+
end

native_client/swift/deepspeech_ios.xcodeproj/project.pbxproj

+20-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
505B137224960D550007DADA /* deepspeech_ios.h in Headers */ = {isa = PBXBuildFile; fileRef = 505B136424960D550007DADA /* deepspeech_ios.h */; settings = {ATTRIBUTES = (Public, ); }; };
1212
505B137D24961AF20007DADA /* deepspeech.h in Headers */ = {isa = PBXBuildFile; fileRef = 505B137C24961AF20007DADA /* deepspeech.h */; settings = {ATTRIBUTES = (Private, ); }; };
1313
505B137F24961BA70007DADA /* DeepSpeech.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505B137E24961BA70007DADA /* DeepSpeech.swift */; };
14-
507CD39B24B61FA100409BBB /* libdeepspeech.so in Frameworks */ = {isa = PBXBuildFile; fileRef = 507CD39A24B61FA100409BBB /* libdeepspeech.so */; };
14+
AD2FD0F925678F8800314F2E /* deepspeech_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2FD0F825678F8800314F2E /* deepspeech_ios.framework */; };
1515
/* End PBXBuildFile section */
1616

1717
/* Begin PBXContainerItemProxy section */
@@ -45,15 +45,15 @@
4545
505B137B249619C90007DADA /* deepspeech_ios.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = deepspeech_ios.modulemap; sourceTree = "<group>"; };
4646
505B137C24961AF20007DADA /* deepspeech.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = deepspeech.h; path = ../../deepspeech.h; sourceTree = "<group>"; };
4747
505B137E24961BA70007DADA /* DeepSpeech.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepSpeech.swift; sourceTree = "<group>"; };
48-
507CD39A24B61FA100409BBB /* libdeepspeech.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libdeepspeech.so; sourceTree = "<group>"; };
48+
AD2FD0F825678F8800314F2E /* deepspeech_ios.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = deepspeech_ios.framework; sourceTree = "<group>"; };
4949
/* End PBXFileReference section */
5050

5151
/* Begin PBXFrameworksBuildPhase section */
5252
505B135E24960D550007DADA /* Frameworks */ = {
5353
isa = PBXFrameworksBuildPhase;
5454
buildActionMask = 2147483647;
5555
files = (
56-
507CD39B24B61FA100409BBB /* libdeepspeech.so in Frameworks */,
56+
AD2FD0F925678F8800314F2E /* deepspeech_ios.framework in Frameworks */,
5757
);
5858
runOnlyForDeploymentPostprocessing = 0;
5959
};
@@ -101,7 +101,7 @@
101101
505B1380249620C60007DADA /* Frameworks */ = {
102102
isa = PBXGroup;
103103
children = (
104-
507CD39A24B61FA100409BBB /* libdeepspeech.so */,
104+
AD2FD0F825678F8800314F2E /* deepspeech_ios.framework */,
105105
);
106106
name = Frameworks;
107107
sourceTree = "<group>";
@@ -243,6 +243,7 @@
243243
505B137324960D550007DADA /* Debug */ = {
244244
isa = XCBuildConfiguration;
245245
buildSettings = {
246+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
246247
ALWAYS_SEARCH_USER_PATHS = NO;
247248
CLANG_ANALYZER_NONNULL = YES;
248249
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@@ -296,8 +297,10 @@
296297
MTL_FAST_MATH = YES;
297298
ONLY_ACTIVE_ARCH = YES;
298299
SDKROOT = iphoneos;
300+
STRIP_SWIFT_SYMBOLS = NO;
299301
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
300302
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
303+
SWIFT_VERSION = 5.0;
301304
VERSIONING_SYSTEM = "apple-generic";
302305
VERSION_INFO_PREFIX = "";
303306
};
@@ -306,6 +309,7 @@
306309
505B137424960D550007DADA /* Release */ = {
307310
isa = XCBuildConfiguration;
308311
buildSettings = {
312+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
309313
ALWAYS_SEARCH_USER_PATHS = NO;
310314
CLANG_ANALYZER_NONNULL = YES;
311315
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@@ -352,8 +356,10 @@
352356
MTL_ENABLE_DEBUG_INFO = NO;
353357
MTL_FAST_MATH = YES;
354358
SDKROOT = iphoneos;
359+
STRIP_SWIFT_SYMBOLS = NO;
355360
SWIFT_COMPILATION_MODE = wholemodule;
356361
SWIFT_OPTIMIZATION_LEVEL = "-O";
362+
SWIFT_VERSION = 5.0;
357363
VALIDATE_PRODUCT = YES;
358364
VERSIONING_SYSTEM = "apple-generic";
359365
VERSION_INFO_PREFIX = "";
@@ -372,6 +378,10 @@
372378
DYLIB_COMPATIBILITY_VERSION = 1;
373379
DYLIB_CURRENT_VERSION = 1;
374380
DYLIB_INSTALL_NAME_BASE = "@rpath";
381+
FRAMEWORK_SEARCH_PATHS = (
382+
"$(inherited)",
383+
"$(PROJECT_DIR)",
384+
);
375385
INFOPLIST_FILE = deepspeech_ios/Info.plist;
376386
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
377387
LD_RUNPATH_SEARCH_PATHS = (
@@ -386,6 +396,7 @@
386396
);
387397
MODULEMAP_FILE = deepspeech_ios/deepspeech_ios.modulemap;
388398
PRODUCT_BUNDLE_IDENTIFIER = "org.mozilla.deepspeech-ios";
399+
OTHER_LDFLAGS = "-lstdc++";
389400
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
390401
SKIP_INSTALL = YES;
391402
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -406,6 +417,10 @@
406417
DYLIB_COMPATIBILITY_VERSION = 1;
407418
DYLIB_CURRENT_VERSION = 1;
408419
DYLIB_INSTALL_NAME_BASE = "@rpath";
420+
FRAMEWORK_SEARCH_PATHS = (
421+
"$(inherited)",
422+
"$(PROJECT_DIR)",
423+
);
409424
INFOPLIST_FILE = deepspeech_ios/Info.plist;
410425
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
411426
LD_RUNPATH_SEARCH_PATHS = (
@@ -420,6 +435,7 @@
420435
);
421436
MODULEMAP_FILE = deepspeech_ios/deepspeech_ios.modulemap;
422437
PRODUCT_BUNDLE_IDENTIFIER = "org.mozilla.deepspeech-ios";
438+
OTHER_LDFLAGS = "-lstdc++";
423439
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
424440
SKIP_INSTALL = YES;
425441
SWIFT_VERSION = 5.0;

native_client/swift/deepspeech_ios.xcodeproj/xcshareddata/xcschemes/deepspeech_ios.xcscheme

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
buildConfiguration = "Debug"
4545
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4646
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
47+
disableMainThreadChecker = "YES"
4748
launchStyle = "0"
4849
useCustomWorkingDirectory = "NO"
4950
ignoresPersistentStateOnLaunch = "NO"

native_client/swift/deepspeech_ios_test.xcodeproj/project.pbxproj

-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
504EC34424CF4EFD0073C22E /* AudioContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC34224CF4EFD0073C22E /* AudioContext.swift */; };
1212
504EC34524CF4F4F0073C22E /* deepspeech_ios.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 507CD3A024B61FE400409BBB /* deepspeech_ios.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1313
507CD3A124B61FE400409BBB /* deepspeech_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 507CD3A024B61FE400409BBB /* deepspeech_ios.framework */; };
14-
507CD3A324B61FEB00409BBB /* libdeepspeech.so in Frameworks */ = {isa = PBXBuildFile; fileRef = 507CD3A224B61FEA00409BBB /* libdeepspeech.so */; };
15-
507CD3A424B61FFC00409BBB /* libdeepspeech.so in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 507CD3A224B61FEA00409BBB /* libdeepspeech.so */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
1614
50F787F32497683900D52237 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F787F22497683900D52237 /* AppDelegate.swift */; };
1715
50F787F52497683900D52237 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F787F42497683900D52237 /* SceneDelegate.swift */; };
1816
50F787F72497683900D52237 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F787F62497683900D52237 /* ContentView.swift */; };
@@ -48,7 +46,6 @@
4846
dstSubfolderSpec = 10;
4947
files = (
5048
504EC34524CF4F4F0073C22E /* deepspeech_ios.framework in Embed Frameworks */,
51-
507CD3A424B61FFC00409BBB /* libdeepspeech.so in Embed Frameworks */,
5249
);
5350
name = "Embed Frameworks";
5451
runOnlyForDeploymentPostprocessing = 0;
@@ -81,7 +78,6 @@
8178
isa = PBXFrameworksBuildPhase;
8279
buildActionMask = 2147483647;
8380
files = (
84-
507CD3A324B61FEB00409BBB /* libdeepspeech.so in Frameworks */,
8581
507CD3A124B61FE400409BBB /* deepspeech_ios.framework in Frameworks */,
8682
);
8783
runOnlyForDeploymentPostprocessing = 0;

native_client/swift/deepspeech_ios_test/SpeechRecognitionImpl.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class SpeechRecognitionImpl : NSObject, AVCaptureAudioDataOutputSampleBufferDele
2626
private var audioData = Data()
2727

2828
override init() {
29-
let modelPath = Bundle.main.path(forResource: "deepspeech-0.7.4-models", ofType: "tflite")!
30-
let scorerPath = Bundle.main.path(forResource: "deepspeech-0.7.4-models", ofType: "scorer")!
29+
let modelPath = Bundle.main.path(forResource: "deepspeech-0.9.1-models", ofType: "tflite")!
30+
let scorerPath = Bundle.main.path(forResource: "deepspeech-0.9.1-models", ofType: "scorer")!
3131

3232
model = try! DeepSpeechModel(modelPath: modelPath)
3333
try! model.enableExternalScorer(scorerPath: scorerPath)

taskcluster/ios-build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ source $(dirname "$0")/tc-tests-utils.sh
99
source $(dirname "$0")/tf_tc-vars.sh
1010

1111
BAZEL_TARGETS="
12-
//native_client:libdeepspeech.so
12+
//native_client:deepspeech_ios
1313
"
1414

1515
if [ "${arch}" = "--arm64" ]; then

taskcluster/ios-package.sh

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ mkdir -p ${TASKCLUSTER_ARTIFACTS} || true
1010

1111
cp ${DS_ROOT_TASK}/DeepSpeech/ds/tensorflow/bazel*.log ${TASKCLUSTER_ARTIFACTS}/
1212

13-
package_native_client "native_client.tar.xz"
14-
15-
package_libdeepspeech_as_zip "libdeepspeech.zip"
16-
1713
case $arch in
1814
"--x86_64")
1915
release_folder="Release-iphonesimulator"

taskcluster/tc-build-utils.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ do_nuget_build()
340340
do_deepspeech_ios_framework_build()
341341
{
342342
arch=$1
343-
cp ${DS_TFDIR}/bazel-bin/native_client/libdeepspeech.so ${DS_DSDIR}/native_client/swift/libdeepspeech.so
343+
unzip ${DS_TFDIR}/bazel-bin/native_client/deepspeech_ios.zip -d ${DS_DSDIR}/native_client/swift
344344
cd ${DS_DSDIR}/native_client/swift
345345
case $arch in
346346
"--x86_64")

0 commit comments

Comments
 (0)