Skip to content

Commit cfe2239

Browse files
committed
let opencv2 work on old wasm runtime
1 parent d003d69 commit cfe2239

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,7 @@ jobs:
19831983
source emsdk/emsdk_env.sh
19841984
cd opencv-${{ env.OPENCV_VERSION }}
19851985
patch -p1 -i ../opencv-2.4.13.7-unsafe-xadd.patch
1986+
patch -p1 -i ../opencv-2.4.13.7-no-local-static.patch
19861987
mkdir build && cd build
19871988
cmake -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
19881989
-DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \
@@ -2006,6 +2007,7 @@ jobs:
20062007
source emsdk/emsdk_env.sh
20072008
cd opencv-${{ env.OPENCV_VERSION }}
20082009
patch -p1 -R -i ../opencv-2.4.13.7-unsafe-xadd.patch
2010+
patch -p1 -R -i ../opencv-2.4.13.7-no-local-static.patch
20092011
mkdir build-threads && cd build-threads
20102012
cmake -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
20112013
-DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
diff -Nuarp opencv-2.4.13.7.orig/modules/core/src/gpumat.cpp opencv-2.4.13.7/modules/core/src/gpumat.cpp
2+
--- opencv-2.4.13.7.orig/modules/core/src/gpumat.cpp 2018-07-02 05:41:56.000000000 +0800
3+
+++ opencv-2.4.13.7/modules/core/src/gpumat.cpp 2021-05-12 13:05:39.939811441 +0800
4+
@@ -222,40 +222,40 @@ static bool loadCudaSupportLib()
5+
6+
#endif
7+
8+
-static GpuFuncTable* gpuFuncTable()
9+
-{
10+
#ifdef DYNAMIC_CUDA_SUPPORT
11+
- static EmptyFuncTable stub;
12+
- static GpuFuncTable* libFuncTable = loadCudaSupportLib() ? gpuFactory(): (GpuFuncTable*)&stub;
13+
- static GpuFuncTable *funcTable = libFuncTable ? libFuncTable : (GpuFuncTable*)&stub;
14+
+static EmptyFuncTable g_GpuFuncTable_stub;
15+
+static GpuFuncTable* g_GpuFuncTable_libFuncTable = loadCudaSupportLib() ? gpuFactory(): (GpuFuncTable*)&g_GpuFuncTable_stub;
16+
+static GpuFuncTable *g_GpuFuncTable_funcTable = g_GpuFuncTable_libFuncTable ? g_GpuFuncTable_libFuncTable : (GpuFuncTable*)&g_GpuFuncTable_stub;
17+
#else
18+
# ifdef USE_CUDA
19+
- static CudaFuncTable impl;
20+
- static GpuFuncTable* funcTable = &impl;
21+
+static CudaFuncTable g_GpuFuncTable_impl;
22+
+static GpuFuncTable* g_GpuFuncTable_funcTable = &g_GpuFuncTable_impl;
23+
#else
24+
- static EmptyFuncTable stub;
25+
- static GpuFuncTable* funcTable = &stub;
26+
+static EmptyFuncTable g_GpuFuncTable_stub;
27+
+static GpuFuncTable* g_GpuFuncTable_funcTable = &g_GpuFuncTable_stub;
28+
#endif
29+
#endif
30+
- return funcTable;
31+
+static GpuFuncTable* gpuFuncTable()
32+
+{
33+
+ return g_GpuFuncTable_funcTable;
34+
}
35+
36+
-static DeviceInfoFuncTable* deviceInfoFuncTable()
37+
-{
38+
#ifdef DYNAMIC_CUDA_SUPPORT
39+
- static EmptyDeviceInfoFuncTable stub;
40+
- static DeviceInfoFuncTable* libFuncTable = loadCudaSupportLib() ? deviceInfoFactory(): (DeviceInfoFuncTable*)&stub;
41+
- static DeviceInfoFuncTable* funcTable = libFuncTable ? libFuncTable : (DeviceInfoFuncTable*)&stub;
42+
+static EmptyDeviceInfoFuncTable g_DeviceInfoFuncTable_stub;
43+
+static DeviceInfoFuncTable* g_DeviceInfoFuncTable_libFuncTable = loadCudaSupportLib() ? deviceInfoFactory(): (DeviceInfoFuncTable*)&g_DeviceInfoFuncTable_stub;
44+
+static DeviceInfoFuncTable* g_DeviceInfoFuncTable_funcTable = g_DeviceInfoFuncTable_libFuncTable ? g_DeviceInfoFuncTable_libFuncTable : (DeviceInfoFuncTable*)&g_DeviceInfoFuncTable_stub;
45+
#else
46+
# ifdef USE_CUDA
47+
- static CudaDeviceInfoFuncTable impl;
48+
- static DeviceInfoFuncTable* funcTable = &impl;
49+
+static CudaDeviceInfoFuncTable g_DeviceInfoFuncTable_impl;
50+
+static DeviceInfoFuncTable* g_DeviceInfoFuncTable_funcTable = &g_DeviceInfoFuncTable_impl;
51+
#else
52+
- static EmptyDeviceInfoFuncTable stub;
53+
- static DeviceInfoFuncTable* funcTable = &stub;
54+
+static EmptyDeviceInfoFuncTable g_DeviceInfoFuncTable_stub;
55+
+static DeviceInfoFuncTable* g_DeviceInfoFuncTable_funcTable = &g_DeviceInfoFuncTable_stub;
56+
#endif
57+
#endif
58+
- return funcTable;
59+
+static DeviceInfoFuncTable* deviceInfoFuncTable()
60+
+{
61+
+ return g_DeviceInfoFuncTable_funcTable;
62+
}
63+
64+
65+
diff -Nuarp opencv-2.4.13.7.orig/modules/core/src/matop.cpp opencv-2.4.13.7/modules/core/src/matop.cpp
66+
--- opencv-2.4.13.7.orig/modules/core/src/matop.cpp 2018-07-02 05:41:56.000000000 +0800
67+
+++ opencv-2.4.13.7/modules/core/src/matop.cpp 2021-05-12 14:09:01.821745993 +0800
68+
@@ -203,10 +203,10 @@ public:
69+
static void makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha=1);
70+
};
71+
72+
+static MatOp_Initializer g_MatOp_initializer;
73+
static MatOp_Initializer* getGlobalMatOpInitializer()
74+
{
75+
- static MatOp_Initializer initializer;
76+
- return &initializer;
77+
+ return &g_MatOp_initializer;
78+
}
79+
80+
static inline bool isIdentity(const MatExpr& e) { return e.op == &g_MatOp_Identity; }

0 commit comments

Comments
 (0)