From nobody Fri Dec 10 21:29:25 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 190AC18D4A4C; Fri, 10 Dec 2021 21:29:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J9kYx5pHpz4pVj; Fri, 10 Dec 2021 21:29:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A664921A2B; Fri, 10 Dec 2021 21:29:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BALTPC9077967; Fri, 10 Dec 2021 21:29:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BALTPNh077966; Fri, 10 Dec 2021 21:29:25 GMT (envelope-from git) Date: Fri, 10 Dec 2021 21:29:25 GMT Message-Id: <202112102129.1BALTPNh077966@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: e4bde9c969cc - stable/13 - Apply fix for clang crashing on invalid -Wa,-march= values List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e4bde9c969cc1d079403850e964d9548316968a1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639171765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4KzSPVll4clY+MjKdIEMz8wyEzFFF/gndX36hSyKLO4=; b=nyxV8uWy8gfN5va+7DylTFBVmSIOKO5etWrxRU8b5x2vt5MA1RbZ3DwnR00QOQkWsqMm16 gmfLaDoa6tw9hIsFXgabrukRRPhqDRRXL+8kAfRz4lSNblkU8zbN5/RIZdocKqZnbB39R/ un2MhJIDU53Tz+0nmZo/mxU33VBbJPT2DMvDr+eCy9b0SjG9Iw/ePnvaUbWAa+JJKT+tql djWoFsEB54c9Lw/2A6VQyQL2v+r55agLvduudriJrSpqk+G00lMZiS725z5Fb/y/HexyLc 3Kj78UiwrGuLk3DjqVmYXBvbmX3oqCGa0wmCrppjUkonbMsx09lZqCxZfU7yuw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639171765; a=rsa-sha256; cv=none; b=y2pL4I7m1CYI9cowtTmYUG4Mu92FpDVLyyks/Cl6d0Ipcy5q7I/czkcabdqyQkVFAz1CU3 zaau7wHJEqWAJqtDTQx9e4gHhCuO9xaeSJBRv8CuyHvTlV+DvEMSPIq/xc+sCjF9WRkQnP uHnVdt8HSpwUCY5S07t3Jj0KQpy1MOWwBxafqDteYQkd/K3QBaeNjpUpV5gHCnE2nW1tOp I96HxU6JV1OrIJHLfMnmR07l2wvcWXbJgAeAflWED47TA2ORig3FpRIjv3z9Bz4PvQwPN6 mv5k7CXGcISLbtaGhQrBoo39jxlRM9qr4nDFvDKdFuW1Y4F+KrJLE5CdfmXzpQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=e4bde9c969cc1d079403850e964d9548316968a1 commit e4bde9c969cc1d079403850e964d9548316968a1 Author: Dimitry Andric AuthorDate: 2021-12-05 17:54:13 +0000 Commit: Dimitry Andric CommitDate: 2021-12-10 21:28:56 +0000 Apply fix for clang crashing on invalid -Wa,-march= values Merge commit df08b2fe8b35 from llvm git (by Dimitry Andric): [AArch64] Avoid crashing on invalid -Wa,-march= values As reported in https://bugs.freebsd.org/260078, the gnutls Makefiles pass -Wa,-march=all to compile a number of assembly files. Clang does not support this -march value, but because of a mistake in handling the arguments, an unitialized Arg pointer is dereferenced, which can cause a segfault. Work around this by adding a check if the local WaMArch variable is initialized, and if so, using its value in the diagnostic message. Reviewed By: tschuett Differential Revision: https://reviews.llvm.org/D114677 PR: 260078 Reported by: bz MFC after: 3 days (cherry picked from commit a9cd5c30d64e213c537c76c2a261f7a222f348bf) --- .../clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/AArch64.cpp index ed8c7e94b013..0e354a49b59a 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -191,7 +191,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D, bool success = true; // Enable NEON by default. Features.push_back("+neon"); - llvm::StringRef WaMArch = ""; + llvm::StringRef WaMArch; if (ForAS) for (const auto *A : Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) @@ -201,7 +201,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D, // Call getAArch64ArchFeaturesFromMarch only if "-Wa,-march=" or // "-Xassembler -march" is detected. Otherwise it may return false // and causes Clang to error out. - if (WaMArch.size()) + if (!WaMArch.empty()) success = getAArch64ArchFeaturesFromMarch(D, WaMArch, Args, Features); else if ((A = Args.getLastArg(options::OPT_march_EQ))) success = getAArch64ArchFeaturesFromMarch(D, A->getValue(), Args, Features); @@ -222,8 +222,15 @@ void aarch64::getAArch64TargetFeatures(const Driver &D, success = getAArch64MicroArchFeaturesFromMcpu( D, getAArch64TargetCPU(Args, Triple, A), Args, Features); - if (!success) - D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); + if (!success) { + auto Diag = D.Diag(diag::err_drv_clang_unsupported); + // If "-Wa,-march=" is used, 'WaMArch' will contain the argument's value, + // while 'A' is uninitialized. Only dereference 'A' in the other case. + if (!WaMArch.empty()) + Diag << "-march=" + WaMArch.str(); + else + Diag << A->getAsString(Args); + } if (Args.getLastArg(options::OPT_mgeneral_regs_only)) { Features.push_back("-fp-armv8");