From patchwork Tue Aug 28 22:27:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: avih X-Patchwork-Id: 10167 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp27854jap; Tue, 28 Aug 2018 15:27:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYha4LzQUY/J6oVCApvUc1x9qhMI8SBGEUXm9NFp9+WHoLgy7xyhnT/P5WbKFNBjeQS0OX4 X-Received: by 2002:a1c:dac9:: with SMTP id r192-v6mr2388109wmg.141.1535495269429; Tue, 28 Aug 2018 15:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535495269; cv=none; d=google.com; s=arc-20160816; b=cBt5+T/o+T+fBswmERCJ+SPqcjY+WCORTzp9wt4adC4iEDMt4gocPehCx2pSMERcM8 4QSDpRuEKlX2veq6/hwZtA4DJhgiaSISEs8rJ7N0cB6Ejs4JxvVfiHUuTx/TzjcgHW9r mw6pnu5rJRxThFnYA5Wq5xhSxZlJ2yvJQZ32CVfbi2hlVn3z/b+umpNVw6bVbfrXZ2HS yF3Pa/OZgk224IOzabaICcycY2lIxV5sV7zdfnIWQVNRh+atuWpa3UTN7VxArlJEBwZq Suw3Ys4dERE7n+OZCXQti7PVZ81y3glNKV9ZrS4fIf2KhANH+HKrWsuLwruSMXHgBPgw sxaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:references :mime-version:message-id:to:from:date:dkim-signature:delivered-to :arc-authentication-results; bh=hEtJgDJcq7CD2vxzYFesn5hBszfJnyqcLelIf4TaJck=; b=IffSw6p4N4vlulucAxjw10THk9Ij8BpFXQwxR7ct10uiMxKch1hXXwtmatED5OzcVx LLCf+0jweJ3rSP8fKWiLBzZ33JHNV/QxV7+50kvTXQF9dGFIuikLv410TUxtCkng8vxk cCJWPIrbwqCMbMBFl+TJXHk8P/2b5s6GFbhJtQ47Iz/EWOM/fULN3c6SbrwHHolNRIQ4 X5ZMAmATbtBgHO/583QvFYIOI5YBnSycXYNT1xeKM6iMJx1OZhbS3u6dqY+GVUAMdPYK GDnb5mfeU0QVU+vQ05rl/v+aOO32TVZzCzN1UncgcWf+K9Q78R9ZeD02lsWqrdvrGvxf vUaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=F3BnsXRM; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w12-v6si1768813wrl.27.2018.08.28.15.27.43; Tue, 28 Aug 2018 15:27:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@yahoo.com header.s=s2048 header.b=F3BnsXRM; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64006689E93; Wed, 29 Aug 2018 01:27:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sonic307-4.consmr.mail.bf2.yahoo.com (sonic307-4.consmr.mail.bf2.yahoo.com [74.6.134.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D652E6809D4 for ; Wed, 29 Aug 2018 01:27:30 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1535495253; bh=STKsOoajs2LKGH8slLbDIfWFIsRi7cNLKvqmsy+IR38=; h=Date:From:Reply-To:To:Subject:References:From:Subject; b=F3BnsXRMyPfIIULsTAyZCesvOVd3S2IpHE4BmRiIbqW2dzF+oMc8+tR9hX0p0XNE2FrsgGQBLvHnalhtzZENHz7T8WJHWepKrCa16lT5G/c2RUXXFNjRQqnDUPu2sIjIMCkieW2ehlrTqvnEPk/jlPtiIVY3TuX9orA168ix1hkj0qTI7yJfFdIXWE3dSJor5MsMkC66ReQWGewEPwP4g7gcVnyL+gAgje72IQ+vHXMHAs+iGbD71OpZjZ1y30Jo3rrjOxqEx2bPjiQenywgE3l5a6a93PkGAU4aqOh+Wv+AX/qqxthtgBxeSJzpbTiOg9J8IwR5y8AxCMNbbQ4TJw== X-YMail-OSG: Sz4aJ7sVM1mmz5QvLl7Gc5vkCwB5wEeQUt5op1tm4CiXe.UaxppYFCkICAbTU9z NauZqCXXjGcJZ6JOKffmK8G8zA2CffMXzwHInfFCRS.WQkENvnWF2f.LzuLnYXnl00r9qEIqweLV VClNkb8X9uGCCkTfKpNJMWAiNkkFV70yXERHkt2zWXutVn4Jn.sF1dbvFcFrb8IJm9YWq_KtWwzY XdHHUUwboNlAe1bcd1A8ZWaGPVa51GeVEkBLhzsVaBcbudBI_OrdDVBImblRyZloLTvtj5JNa3Kq JTY05ZG1kiBafHUsL8q8udTFfC3FoT3JilxlmL9A54NFf9Ah8I73dkcVedY7Y3SmrjM0arbloKDu .E0hrxNCrpa04AOMNAlhwTNBlFDYrSVVgKYGx03FE4xt4FMXbtfvbbbC8rg37L10xcTadyqb23cu aNh51dW3A_ixQlk6ACM7RWL3E6OHnkNNw8XsDoEoh2YYjZ8fIXmkXOiieYKrf68gG0bg5xrZa5du DftHq8H5Vvx_pReYBlC_buP_.3YXDELsRHRufiti4_TfIKewol3SYUi1gpWMTTpyTGyp2UYodlhZ 7iO1Qye3lkzgAc2UEQiZW6SMXSzZW1IhgQPSRGfCWKlXJeflOl5HvyacP7MdtiqvcwutostiU8XD LdIgN639q983K_1ItVr.3xQtDeqaA2OPExZxqR1R8t_S65JuM7TvTP0fo_0pcZZ5gWfDThk0euUF akk6BDIUThixx23KtyAwVzcVodF3rE7VowO7m1i4JlBg1tNAf5TRwto9L4tNyL0_VxzTvZ2eCYyM .O01en1quIPMOH7oqkByGVSB453WCO5wRaSxHGgAWee0WmEaZ5rSjnk_52ofK5fW_yIHfiG2uuJE 9ZZ6L.XW_q65YCcQXYMeV9utxWrpn_9gVZkWJ8rCvIKt8a73uigSu9HChN7Z_IVYN5WMzgDsTtop WMGnfPS9Z8s2as9pugXbAx01A8QU- Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.bf2.yahoo.com with HTTP; Tue, 28 Aug 2018 22:27:33 +0000 Date: Tue, 28 Aug 2018 22:27:31 +0000 (UTC) From: avih To: FFmpeg Development Discussions and Patches Message-ID: <1937160471.4193679.1535495251907@mail.yahoo.com> MIME-Version: 1.0 References: <1937160471.4193679.1535495251907.ref@mail.yahoo.com> X-Mailer: WebService/1.1.12262 YahooMailNeo Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] configure: _deps: validate, reduce sensitivity X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" I analyzed the linkage failures at: http://ffmpeg.org/pipermail/ffmpeg-devel/2018-August/233674.html After finding their immediate cause - expecting a specific output order from unique() - I realized that there might be a related issue where devs are expected to maintain _deps (e.g. avfilter_deps) in linking order. This can be awkward and bug-prone if the list is not empty. I noticed at least one such existing order bug. This patch makes it easier to add to these lists, in any order, while also addressing few smaller issues and adding validation. More details at the commit message of the attached patch. Avi From 4940963648cb431f1a8e827adefb58d318186b38 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Tue, 28 Aug 2018 17:14:55 +0300 Subject: [PATCH] configure: _deps: validate, reduce sensitivity - Allow to add deps in any order rather than "in linking order". - Expand deps chains as required rather than just once. - Validate that there are no cycles. - Validate that [after expansion] deps are limited to other fflibs. - Remove expectation for a specific output order of unique(). Previously when adding items to _deps, developers were required to add them in linking order. This can be awkward and bug-prone, especially when a list is not empty, e.g. when adding conditional deps. It also implicitly expected unique() to keep the last instance of recurring items such that these lists maintain their linking order after removing duplicate items. This patch mainly allows to add deps in any order by keeping just one master list in linking order, and then reordering all the _deps lists to align with the master list order. This master list is LIBRARY_LIST itself, where otherwise its order doesn't matter. The patch also removes a limit where these deps lists were expanded only once. This could have resulted in incomplete expanded lists, or forcing devs to add already-deducable deps to avoid this issue. Note: it is possible to deduce the master list order automatically from the deps lists, but in this case it's probably not worth the added complexity, even if minor. Maintaining one list should be OK. --- configure | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/configure b/configure index 3cf94129..8bbcd530 100755 --- a/configure +++ b/configure @@ -1818,16 +1818,17 @@ FEATURE_LIST=" swscale_alpha " +# this list should be kept in linking order LIBRARY_LIST=" - avcodec avdevice avfilter + swscale + postproc avformat + avcodec + swresample avresample avutil - postproc - swresample - swscale " LICENSE_LIST=" @@ -3491,7 +3492,7 @@ vaapi_transcode_example_deps="avcodec avformat avutil h264_vaapi_encoder" cpu_init_extralibs="pthreads_extralibs" cws2fws_extralibs="zlib_extralibs" -# libraries, in linking order +# libraries, in any order avcodec_deps="avutil" avcodec_suggest="libm" avcodec_select="null_bsf" @@ -6846,7 +6847,7 @@ done enabled zlib && add_cppflags -DZLIB_CONST -# conditional library dependencies, in linking order +# conditional library dependencies, in any order enabled afftfilt_filter && prepend avfilter_deps "avcodec" enabled afir_filter && prepend avfilter_deps "avcodec" enabled amovie_filter && prepend avfilter_deps "avformat avcodec" @@ -6889,11 +6890,36 @@ enabled sdl2_outdev && add_cflags $(filter_out '-Dmain=SDL_main' $sdl2_cflag enabled opus_decoder && prepend avcodec_deps "swresample" +# reorder the items at var $1 to align with the items order at var $2 . +# die if an item at $1 is not at $2 . +reorder_by(){ + eval rb_in=\$$1 + eval rb_ordered=\$$2 + + for rb in $rb_in; do + is_in $rb $rb_ordered || die "$rb at \$$1 is not at \$$2" + done + + rb_out= + for rb in $rb_ordered; do + is_in $rb $rb_in && rb_out="$rb_out$rb " + done + eval $1=\$rb_out +} + +# deps-expand fflib $1: N x {append all expanded deps; unique} +# within a set of N items, N expansions are enough to expose a cycle. expand_deps(){ - lib_deps=${1}_deps - eval "deps=\$$lib_deps" - append $lib_deps $(map 'eval echo \$${v}_deps' $deps) - unique $lib_deps + unique ${1}_deps # required for the early break test. + for dummy in $LIBRARY_LIST; do # N iteratios + eval deps=\$${1}_deps + append ${1}_deps $(map 'eval echo \$${v}_deps' $deps) + unique ${1}_deps + eval '[ ${#deps} = ${#'${1}_deps'} ]' && break # doesn't expand anymore + done + + eval is_in $1 \$${1}_deps && die "Dependency cycle at ${1}_deps" + reorder_by ${1}_deps LIBRARY_LIST # linking order is expected later } #we have to remove gpl from the deps here as some code assumes all lib deps are libs -- 2.17.1