From nobody Sat Dec 25 11:55:07 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 174C418F2056; Sat, 25 Dec 2021 11:55:08 +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 4JLj6M3DmNz4kmQ; Sat, 25 Dec 2021 11:55:07 +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 2CD9016F02; Sat, 25 Dec 2021 11:55:07 +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 1BPBt7Hx006065; Sat, 25 Dec 2021 11:55:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BPBt7tL006064; Sat, 25 Dec 2021 11:55:07 GMT (envelope-from git) Date: Sat, 25 Dec 2021 11:55:07 GMT Message-Id: <202112251155.1BPBt7tL006064@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: ab58501686f3 - stable/12 - clang: Fix -gz=zlib options for linker 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/12 X-Git-Reftype: branch X-Git-Commit: ab58501686f391152e4c1b07e9db45fad7022f34 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640433307; 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=JNw7hzayT7Zku3m7d1WnMDZE4z9k8ek+tdYosHK+KO0=; b=QnNBeHly0ku8w/2t49Nf8BUoSNUt9jnnJBFBJ336sy6FdTaho9RqbobaEfdcpcqEO/vWoR KgEgEVgEsAMie5H9nbVhmB74SQGIyQr57Q7UT7Xj6mAeFOTESN7YlIn5hbPNA5jEvDjNfk Xz+TMDPAjfJdwdMgedKOEDP92mueUDPM8yeT5F05FihxbRY7wSS9o6W512n53LyrDIpMUO y2pvxj8/AWTh75qjGYHKe3xu4x1jrUYEMS8lfNDh0xA+j4FFQj5cyEIoWAe/kfqtdR2OCY ZL12NG3SKtg9f/7P5Q2Lf+jCaUfqTfBUtLvtWM74Yhmpj8qRhvnoeZN0qEbNtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640433307; a=rsa-sha256; cv=none; b=uweg1lrZZQS7U9s9NB3UKT8Z14fIZvaOVvmhPMqL4EsUQnETjLMlh8yEPVRCARjNESJtf0 iA5Yh3wlAgHGFxT6A6Ll3YKSgqEoZfe1yAFQpepes1tzUAVYA0XqFZF9AqgJ1AOADmlpHB w2oL6hX9pzvkPatDmyVgpBGylHtxtdnCMJQ60qDxCV/4gnsPHoPr2gE1y9YoIg7+A+ZVqk m774mI6nhVqIjQwMen8UfHJtUSvyaDVL2Y4pW4oEbHcLKJsx3R0WHZPQzqT8I+c/DtFzBI 7rzBooRQLOOotNAsz5eowkuQWRNH+344V4HOD3+tFa161frviBuVVK7ew8B5RA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=ab58501686f391152e4c1b07e9db45fad7022f34 commit ab58501686f391152e4c1b07e9db45fad7022f34 Author: Ed Maste AuthorDate: 2021-03-03 01:35:57 +0000 Commit: Dimitry Andric CommitDate: 2021-12-25 11:50:58 +0000 clang: Fix -gz=zlib options for linker Clang commit ccb4124a4172bf2cb2e1cd7c253f0f1654fce294: Fix -gz=zlib options for linker gcc translates -gz=zlib to --compress-debug-options=zlib for both assembler and linker but clang only does this for assembler. The linker needs --compress-debug-options=zlib option to compress the debug sections in the generated executable or shared library. Due to this bug, -gz=zlib has no effect on the generated executable or shared library. This patch fixes that. Clang commit 462cf39a5c180621b56f7602270ce33eb7b68d23: [Driver] Fix -gz=zlib options for linker also on FreeBSD ccb4124a4172 fixed translating -gz=zlib to --compress-debug-sections for linker invocation for several ToolChains, but omitted FreeBSD. Approved by: dim MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29028 (cherry picked from commit 19587d742264c5caec33d218e9cea6eb78f6c6bb) --- .../clang/lib/Driver/ToolChains/AMDGPU.cpp | 1 + .../clang/lib/Driver/ToolChains/CommonArgs.cpp | 18 ++++++++++++++++++ .../clang/lib/Driver/ToolChains/CommonArgs.h | 4 ++++ .../clang/lib/Driver/ToolChains/FreeBSD.cpp | 1 + .../llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp | 1 + .../llvm-project/clang/lib/Driver/ToolChains/HIP.cpp | 2 ++ 6 files changed, 27 insertions(+) diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPU.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPU.cpp index bc6d1fcd4a00..10ae76cb4161 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -350,6 +350,7 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, std::string Linker = getToolChain().GetProgramPath(getShortName()); ArgStringList CmdArgs; + addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs); AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); CmdArgs.push_back("-shared"); CmdArgs.push_back("-o"); diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp index 6b6e276b8ce7..535154e492a7 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -214,6 +214,24 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs, } } +void tools::addLinkerCompressDebugSectionsOption( + const ToolChain &TC, const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) { + // GNU ld supports --compress-debug-sections=none|zlib|zlib-gnu|zlib-gabi + // whereas zlib is an alias to zlib-gabi. Therefore -gz=none|zlib|zlib-gnu + // are translated to --compress-debug-sections=none|zlib|zlib-gnu. + // -gz is not translated since ld --compress-debug-sections option requires an + // argument. + if (const Arg *A = Args.getLastArg(options::OPT_gz_EQ)) { + StringRef V = A->getValue(); + if (V == "none" || V == "zlib" || V == "zlib-gnu") + CmdArgs.push_back(Args.MakeArgString("--compress-debug-sections=" + V)); + else + TC.getDriver().Diag(diag::err_drv_unsupported_option_argument) + << A->getOption().getName() << V; + } +} + void tools::AddTargetFeature(const ArgList &Args, std::vector &Features, OptSpecifier OnOpt, OptSpecifier OffOpt, diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.h b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.h index 29dedec9b09c..0028ea0ca337 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.h +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.h @@ -27,6 +27,10 @@ void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const JobAction &JA); +void addLinkerCompressDebugSectionsOption(const ToolChain &TC, + const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs); + void claimNoWarnArgs(const llvm::opt::ArgList &Args); bool addSanitizerRuntimes(const ToolChain &TC, const llvm::opt::ArgList &Args, diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp index 8316cc65ba63..57744bac37da 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -283,6 +283,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); + addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); bool Profiling = Args.hasArg(options::OPT_pg) && diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp index c8a7fce07ef1..23e7a70f2fa7 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp @@ -568,6 +568,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); + addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); // The profile runtime also needs access to system libraries. getToolChain().addProfileRTLibs(Args, CmdArgs); diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/HIP.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/HIP.cpp index 7d17f809690e..228d970c4043 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/HIP.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/HIP.cpp @@ -88,6 +88,8 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA, if (C.getDriver().isSaveTempsEnabled()) LldArgs.push_back("-save-temps"); + addLinkerCompressDebugSectionsOption(TC, Args, LldArgs); + LldArgs.append({"-o", Output.getFilename()}); for (auto Input : Inputs) LldArgs.push_back(Input.getFilename());