From patchwork Wed Sep 23 06:39:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 22562 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id EBB3A44B08F for ; Wed, 23 Sep 2020 10:02:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BC76568B5E7; Wed, 23 Sep 2020 10:02:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 161D168A1B9 for ; Wed, 23 Sep 2020 10:02:39 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id v23so16313487ljd.1 for ; Wed, 23 Sep 2020 00:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=8VBtYQYVvVDx+hW/J/AoSaSIGsjlvXyC3v1/TYvwRQA=; b=wxL0H5daZ02DziyI3QLJib74symOKqXSqL1xDTziFhmejdtTc7YmtvTvb6MZ1kdsrY 6/FGwJO3FcjWcUyBjx+2zGB370br5x1S1Xo7QAi20YI6qa6lKB3VihTYGXI2yEhPSmE5 7H1XOz/Si8yp5q93lyDAh15bsU8jgT1shJs2o/yi3QqyQHVWE41Oy1W54ADsHdytebxz KhXjJ0q5XbHkGuMJrWVi/qT8fnqQAI643gWDunxkIHAAOgdSqpsQkpCX26Eg4sXKciod hR6JDzz2A36cJuHVNoaQf/Jfacu+teeJW21q9dvKRld8QMCx3boFcfmTxQAW/vhDHofd y3Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8VBtYQYVvVDx+hW/J/AoSaSIGsjlvXyC3v1/TYvwRQA=; b=BS0qs6JRLd5QHAV4G9+6CvCWJ248i0igpKa+t9CMk7sEZwuM52HeWMK1yiBP0KLsF1 1HMRioJCwEiv2lfnx9i9STusvZCZjShyqT3Gt2GTwwjVhxUl4GkBt5EemaP4F/iKBSMg apwyT6+mm9h/3vDkyFuY90uGSBZZK4EU1K1+bXKqJP+7e4pbDFFtfFWRA7ikpGk+1Ip1 8ImkB0yFWq8FJqJisFEhLb25Nondg3rLdFPErGQlhPMLc+PS6KzCZvy7iShVdToynQ9z JGpNRoepOl8P+DzN92jeKrXtKtLHjPQPZYvPT4H0x65AVo1KWAdyw9vuf8tCtO/UJZj2 Wzag== X-Gm-Message-State: AOAM532aXls095xpr6RFebrGO7va4dLTkIKbPLVnXPP7vEzC8FKNzxTA hdqdv3dy/AiSK4Zi/8jdsCKxh647fOEf9wgd X-Google-Smtp-Source: ABdhPJz+wUanEfZ/Lm1vXK17aWMfpjAxU4y8Pobl5jrJtbQ6+5ytoUUr1r/5jsCTKfc7rDZmT+zYEA== X-Received: by 2002:a2e:9b13:: with SMTP id u19mr2557844lji.204.1600843160552; Tue, 22 Sep 2020 23:39:20 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id 138sm4343331lfl.241.2020.09.22.23.39.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 23:39:20 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 23 Sep 2020 09:39:17 +0300 Message-Id: <20200923063917.19016-2-martin@martin.st> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200923063917.19016-1-martin@martin.st> References: <20200923063917.19016-1-martin@martin.st> Subject: [FFmpeg-devel] [GASPP PATCH 2/2] Use cl for preprocessing when using armasm 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When invoking gas-preprocessor to preprocess only to get the dependency list, we still need to use cpp, as cl doesn't support the -M options. This allows using gas-preprocessor in an environment with only MSVC available, no GCC/Clang providing a cpp.exe, allowing building e.g. dav1d with MSVC targeting ARM, without any mingw/msys tools involved. --- gas-preprocessor.pl | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl index e9baeba..69f6f6d 100755 --- a/gas-preprocessor.pl +++ b/gas-preprocessor.pl @@ -103,14 +103,7 @@ if (grep /\.c$/, @gcc_cmd) { if ($as_type eq "armasm") { $preprocess_c_cmd[0] = "cpp"; - push(@preprocess_c_cmd, "-undef"); - # Normally a preprocessor for windows would predefine _WIN32, - # but we're using any generic system-agnostic preprocessor "cpp" - # with -undef (to avoid getting predefined variables from the host - # system in cross compilation cases), so manually define it here. - push(@preprocess_c_cmd, "-D_WIN32"); - - @preprocess_c_cmd = grep ! /^-nologo$/, @preprocess_c_cmd; + # Remove -ignore XX parameter pairs from preprocess_c_cmd my $index = 1; while ($index < $#preprocess_c_cmd) { @@ -121,10 +114,23 @@ if ($as_type eq "armasm") { $index++; } if (grep /^-MM$/, @preprocess_c_cmd) { + push(@preprocess_c_cmd, "-D_WIN32"); + # Normally a preprocessor for windows would predefine _WIN32, + # but we're using any generic system-agnostic preprocessor "cpp" + # with -undef (to avoid getting predefined variables from the host + # system in cross compilation cases), so manually define it here. + # We only use this generic preprocessor for generating dependencies, + # if the build system runs preprocessing with -M/-MM without -MF. + push(@preprocess_c_cmd, "-undef"); + @preprocess_c_cmd = grep ! /^-nologo$/, @preprocess_c_cmd; print STDERR join(" ", @preprocess_c_cmd)."\n" if $verbose; system(@preprocess_c_cmd) == 0 or die "Error running preprocessor"; exit 0; } + + # If not preprocessing for getting a dependency list, use cl.exe + # instead. + $preprocess_c_cmd[0] = "cl"; } # if compiling, avoid creating an output file named '-.o' @@ -139,13 +145,12 @@ if ((grep /^-c$/, @gcc_cmd) && !(grep /^-o/, @gcc_cmd)) { } } } -# replace only the '-o' argument with '-', avoids rewriting the make dependency -# target specified with -MT to '-' +# Remove the -o argument; if omitted, we by default preprocess to stdout. my $index = 1; while ($index < $#preprocess_c_cmd) { if ($preprocess_c_cmd[$index] eq "-o") { - $index++; - $preprocess_c_cmd[$index] = "-"; + splice(@preprocess_c_cmd, $index, 2); + last; } $index++; } @@ -166,6 +171,7 @@ if ($as_type ne "armasm") { @preprocess_c_cmd = grep ! /^-oldit/, @preprocess_c_cmd; @preprocess_c_cmd = grep ! /^-FS/, @preprocess_c_cmd; @preprocess_c_cmd = grep ! /^-w/, @preprocess_c_cmd; + @preprocess_c_cmd = grep ! /^-M/, @preprocess_c_cmd; @gcc_cmd = grep ! /^-G/, @gcc_cmd; @gcc_cmd = grep ! /^-W/, @gcc_cmd;