From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 80F67138334 for ; Thu, 12 Sep 2019 11:32:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 643DFE0943; Thu, 12 Sep 2019 11:32:47 +0000 (UTC) Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0E25AE0935 for ; Thu, 12 Sep 2019 11:32:45 +0000 (UTC) Received: by mail-pl1-x649.google.com with SMTP id p8so13930417plo.16 for ; Thu, 12 Sep 2019 04:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=FoP9WdVUKHAMAlnyfdr2Pu8noJfINrXJrjdSt9Tz9PU=; b=twYOnZk4dDGDzUQwXPzqstho5s5oJLpo4U06LB1JvIwvZqMUckktgR3LaQI92o59iR IBrHqKY+OaCFLAJfJi3/oGnoeYA5/uXgQeyUqcQvpY695jVunih6M2uaS3m+LeFGvrbG i6GfAXhoDa6VH0qpjSbSTbcQ5uJf99CMKUx1JAhvK1WlMbLRYccmVkCe0IpsNiP6XEeK 7MWbPdrIBeSOZOkpf7ejzitAdmCYKV6lHQ4N4TYdNrCjXhGiPN9cWMKnRIyqFV22b/D6 Sb0bnLvRJfY3OTrkt85AaJktNhCqGfSQ5QduLjDStFRgcpah0naBDPNXFE0AQBtyeNmb LmXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=FoP9WdVUKHAMAlnyfdr2Pu8noJfINrXJrjdSt9Tz9PU=; b=B1Bln5ay68bcMXhqBh6Be4xS9KpVnLGBM8zA3wbZt70EEglaIi088EaU1jkK7z8tTL ZDfhYJ5rPK/2donE5tqmR+5DDon3u1W3eu2pAymKzZneM5LuAS99ePegdnByz0mYojq7 EHSMaZZx0fet46NDqa+kt4wqfxeVKbAa7bauseaopd3ZlHIsJIXzfEzVbRxdOPIyfdnV LI7sU9+VLb2ExljADSNwhRIm8GNARvELf/IKCBldPr0LevniuW3j7UJ76vE4SGpz0h2C LgS4vS4HWgpsOoidE/+tkNIFx3o0xouspFp8Y0cImfM+m/qHtCVB86qSuEF1sPFx9ctg xzow== X-Gm-Message-State: APjAAAXOXdy/njlkQYi7Rk49Aop69OyqmfptXrjHi8UEt2prk7vIt0cV oGhUbXTE6Gk9ePXTTOZQwJbn8F3AevJIGw03Ud8Os6ehM6Az6dmb9/jzYHbNABLm4NVCm/dHU7c XwWsXjVtjNoRPwwgfPkwXlFVcCQlR4HZhJRCZ1wJa8QChsWx7xdAA4ONhZPVsE8w/tAzObZ3O51 Zk0bU= X-Google-Smtp-Source: APXvYqzlkc16pAKgBzojXudmAnUPg0m2EQ/FzQJW4R+yRZQUTQIU/lNwCjTvdekQiekg2nEf2yL80a/827ngTDjN X-Received: by 2002:a63:c1c:: with SMTP id b28mr37692446pgl.354.1568287964317; Thu, 12 Sep 2019 04:32:44 -0700 (PDT) Date: Thu, 12 Sep 2019 04:32:40 -0700 Message-Id: <20190912113240.226571-1-manojgupta@google.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply Mime-Version: 1.0 X-Mailer: git-send-email 2.23.0.162.g0b9fbb3734-goog Subject: [gentoo-dev] [PATCH] toolchain-funcs: Add tc-ld-is-lld helper. From: Manoj Gupta To: gentoo-dev@lists.gentoo.org Cc: Manoj Gupta Content-Type: text/plain; charset="UTF-8" X-Archives-Salt: 4158afdd-c838-47fe-9e48-f5d77dc7ac82 X-Archives-Hash: 7dbcc3157666a3df89637159c56e4b0c LLD is a new linker for LLVM project. Add tc-ld-is-lld helper to be able to detect it. Signed-off-by: Manoj Gupta --- eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 7bd90bb4e4a..e358d484417 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -453,6 +453,36 @@ tc-ld-is-gold() { return 1 } +# @FUNCTION: tc-ld-is-lld +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# Return true if the current linker is set to lld. +tc-ld-is-lld() { + local out + + # First check the linker directly. + out=$($(tc-getLD "$@") --version 2>&1) + if [[ ${out} == *"LLD"* ]] ; then + return 0 + fi + + # Then see if they're selecting lld via compiler flags. + # Note: We're assuming they're using LDFLAGS to hold the + # options and not CFLAGS/CXXFLAGS. + local base="${T}/test-tc-lld" + cat <<-EOF > "${base}.c" + int main() { return 0; } + EOF + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1) + rm -f "${base}"* + if [[ ${out} == *"LLD"* ]] ; then + return 0 + fi + + # No lld here! + return 1 +} + # @FUNCTION: tc-ld-disable-gold # @USAGE: [toolchain prefix] # @DESCRIPTION: -- 2.23.0.162.g0b9fbb3734-goog