@@ -159,6 +159,14 @@ local function is_unistd_platform_flag(f)
159159 return type (f ) == " table" and type (f .glob ) == " string"
160160 and f .glob :find (" 3rdparty/mlas/lib/platform.cpp" , 1 , true ) ~= nil
161161end
162+ -- clsrc/opencl_kernels_<m>.cpp are written INERT by build.mcpp (cl2cpp) but never
163+ -- compiled (OpenCL OFF in this headless profile, not registered as sources), so
164+ -- their per-file flag-globs match nothing -> a permanent "[build].flags glob …
165+ -- matched no source file" warning. Drop them entirely.
166+ local function is_dead_opencl_glob (f )
167+ return type (f ) == " table" and type (f .glob ) == " string"
168+ and f .glob :find (" clsrc/opencl_kernels" , 1 , true ) ~= nil
169+ end
162170local pkgs , order = {}, {}
163171for _ , e in ipairs (INPUTS ) do pkgs [e .os ] = load_pkg (e .path ); order [# order + 1 ] = e .os end
164172local dnn_src , dnn_flg , base_flg = {}, {}, {}
@@ -172,7 +180,8 @@ for _, os_ in ipairs(order) do
172180 if not (drop_unistd and is_unistd_platform_flag (f )) then flgs [# flgs + 1 ] = f end
173181 end
174182 for _ , f in ipairs (p .mcpp .flags or {}) do
175- if type (f ) == " table" and is_dnn_glob (f .glob ) then
183+ if is_dead_opencl_glob (f ) then -- drop: inert, never compiled
184+ elseif type (f ) == " table" and is_dnn_glob (f .glob ) then
176185 if not (drop_unistd and is_unistd_platform_flag (f )) then flgs [# flgs + 1 ] = f end
177186 else cleaned [# cleaned + 1 ] = f end
178187 end
@@ -205,20 +214,27 @@ local function split_common(map)
205214 end
206215 return common , delta
207216end
208- local common_src , delta_src = split_common (dnn_src )
209- local common_flg , delta_flg = split_common (dnn_flg )
210-
211- -- neutral features: base's non-dnn features (unifont) verbatim; dnn = common-only
217+ -- `dnn` is an OS-only feature (mcpp#253): it exists only on the platforms whose
218+ -- snapshot actually built it. Each such platform carries the FULL payload under
219+ -- mcpp.<os>.features.dnn — there is NO neutral dnn, so a platform without it
220+ -- cannot half-enable the feature. Windows is intentionally excluded: mlas's x86
221+ -- kernels are GAS/ELF `.S` (`.type …,@function`), which clang-cl cannot assemble
222+ -- to Windows COFF (would need the MASM amd64 `.asm` variant or a C++-only mlas).
212223local neutral_features = {}
213224for fname , fdef in pairs (base .mcpp .features or {}) do
214225 if fname ~= " dnn" then neutral_features [fname ] = fdef end
215226end
216227local base_dnn = base .mcpp .features and base .mcpp .features .dnn
217- neutral_features .dnn = {
218- defines = (base_dnn and base_dnn .defines ) or { " HAVE_OPENCV_DNN" },
219- flags = common_flg ,
220- sources = common_src ,
221- }
228+ local dnn_defines = (base_dnn and base_dnn .defines ) or { " HAVE_OPENCV_DNN" }
229+ -- an OS "ships dnn" only if it built the actual module — gen_descriptor always
230+ -- seeds features.dnn.sources with mcpp_generated/mlas_hgemm_stub.cpp even for a
231+ -- videoio-only (non-dnn) snapshot, so a non-empty list is NOT enough.
232+ local function ships_dnn (os_ )
233+ for _ , s in ipairs (dnn_src [os_ ] or {}) do
234+ if type (s ) == " string" and s :find (" modules/dnn" , 1 , true ) then return true end
235+ end
236+ return false
237+ end
222238
223239merged .mcpp = {
224240 language = base .mcpp .language ,
@@ -232,11 +248,8 @@ for _, os_ in ipairs(order) do
232248 blk .flags = base_flg [os_ ] -- dnn-group globs stripped
233249 local sub = p .mcpp [os_ ]
234250 if sub and sub .ldflags then blk .ldflags = sub .ldflags end
235- if # dnn_src [os_ ] > 0 then -- this OS supports dnn -> its delta
236- local fd = {}
237- if # delta_src [os_ ] > 0 then fd .sources = delta_src [os_ ] end
238- if # delta_flg [os_ ] > 0 then fd .flags = delta_flg [os_ ] end
239- if next (fd ) then blk .features = { dnn = fd } end
251+ if ships_dnn (os_ ) then -- this OS ships dnn -> full payload
252+ blk .features = { dnn = { defines = dnn_defines , sources = dnn_src [os_ ], flags = dnn_flg [os_ ] } }
240253 end
241254 merged .mcpp [os_ ] = blk
242255end
0 commit comments