From nobody Mon Jul 5 17:56:10 2021 X-Original-To: freebsd-hackers@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 9D36911D5A8D; Mon, 5 Jul 2021 17:56:23 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GJYK33qkjz3FLm; Mon, 5 Jul 2021 17:56:23 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: by mail-ej1-f41.google.com with SMTP id bg14so30018650ejb.9; Mon, 05 Jul 2021 10:56:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tyeG0+uP3jlC9MrCLlel3VHagTU1hREcZfOK3elRXwA=; b=HVJOE24O28XoxatAi8OjQqBAvL1GerMyE7COahU7twRdAzSaQDzuQaZOIUYbT9qC7j G7pC5rsngGuwhVs3KRIhLEMvrxNZmEcFA/HzUnxMKKAc/IabsY9J18eL7bb0cxDa+G6H UGTiRX8jmYPeGGa5JKQNFxNX+QD894ChkPn4Jtl1NN14qeXFnbml2iJ96pMMjudpPy3C qQ393EAifztOD4BPBkErjoEZurkD/MPeUSk1+3sEPIdBRCYl4EE+1qZV6BhAbhxlDnwB PbVXeZi4EUV0thPOkE828SS5LCCNfYDeHi6ArwmewR3hCFu+gZwhWJJqg3u+PdETClcN 0cEA== X-Gm-Message-State: AOAM530EBTzagdz4t8nQ5NYVx/F3WSyC5jA3tTRmx+8Lyq296eOql+g8 QpYZrnvV6ex/bFAjxWKb8TJ2BWUNZUSQ8g== X-Google-Smtp-Source: ABdhPJxjrQM1Awz3AepQlQPCbVXaP+457AYm9RZXGKdeYP0JvbHagISHQR63OBtTYfIDFoOLFc6wEw== X-Received: by 2002:a17:906:b190:: with SMTP id w16mr14631217ejy.332.1625507782113; Mon, 05 Jul 2021 10:56:22 -0700 (PDT) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com. [209.85.128.52]) by smtp.gmail.com with ESMTPSA id f9sm4101537edw.88.2021.07.05.10.56.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jul 2021 10:56:21 -0700 (PDT) Received: by mail-wm1-f52.google.com with SMTP id j16-20020a05600c1c10b0290204b096b0caso493949wms.1; Mon, 05 Jul 2021 10:56:21 -0700 (PDT) X-Received: by 2002:a1c:9d8f:: with SMTP id g137mr282085wme.13.1625507781650; Mon, 05 Jul 2021 10:56:21 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Alexander Richardson Date: Mon, 5 Jul 2021 18:56:10 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Migrating to LLVM binutils tools (ar, nm, addr2line, etc.) To: Ed Maste Cc: "freebsd-toolchain@FreeBSD.org" , FreeBSD Hackers , Dimitry Andric Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4GJYK33qkjz3FLm X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On Mon, 5 Jul 2021 at 16:09, Ed Maste wrote: > > FreeBSD migrated from GNU binutils to versions from ELF Tool Chain, > starting in 2014. At that time there were no usable LLVM versions of > those tools, but they have been developing rapidly since then. Now I > think it may be prudent to migrate to the LLVM tools where they exist, > for both functionality and maintainability reasons. > > I'd like to allow use of link-time optimization (LTO) in the FreeBSD > base system. LTO runs optimization passes over the entire executable > (or library) at link time and thus allows for more effective > optimization than when performed on individual compilation units. > > When using LTO object files (.o) including those contained in static > library archives (.a) contain LLVM IR bitcode rather than target > object code. This means that utilities that operate on object files > need to support LLVM IR; we currently use a number of bespoke tools > and ones obtained from ELF Tool Chain that do not have this support. > > Alex Richardson also pointed out that asan (address sanitizer) > produces a useful backtrace only if addr2line is llvm-symbolizer. > > Like ELF Tool Chain the LLVM tools aim for command line and output > format compatibility with GNU binutils, although there are a few minor > differences. Where these cause a material issue (breaking a port or > eliminating required functionality) we can submit LLVM bugs and work > on patches. > > In the past we provided build knobs to control individual utilities > (e.g. WITH_LLD_IS_LD); I'd like to avoid perpetuating that here. It > seems individual knobs (WITH_LLVM_AR_IS_AR, WITH_LLVM_NM_IS_NM, > WITH_LLVM_SYMBOLIZER_IS_ADDR2LINE etc.) will introduce extra > complexity without adding much value. > > Alex is working on a patch now and will follow up shortly, but I > wanted to email the list as a heads-up, and see if there are any > comments or concerns. Thanks for writing this up, I've posted the initial patch as https://reviews.freebsd.org/D31060. > > Potential next steps are: > - Introduce new build knob > - Iterate on exp-runs and call for testing > - Switch to LLVM tools by default > - Major release (14.0) > - Retire knob, leaving only the LLVM implementation.