Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1772593ybg; Sat, 19 Oct 2019 02:11:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxF49MvC+sHoEL9HvXH8ebIRAhePGEXj7upJOySbx922bvUJWsh9wxWXAO3+4pdq6LBz6vJ X-Received: by 2002:a17:907:397:: with SMTP id ss23mr1704137ejb.177.1571476290547; Sat, 19 Oct 2019 02:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571476290; cv=none; d=google.com; s=arc-20160816; b=wg67MCeCv+aPJ2Z3Ht7agf8ibP3uQUJlKDWHMPtrnEDsDEPJBFIWIGYw66q6Vf8SwW +1V3+0eRS+yC6iaT6lp8IXobVqsMvlQEzKNJkMjvVO8MVhb1n6SMigOnazMn0ySKfLfI 43eWTLXzV/HHPKrF/gBZaWZMNFSxEpxolg2JleaZF0rB1VZ+4PTdfjeyYQpgdka9lAVU HJLuUxu18HVOtissvloPwD/RyBGlVGtsXOtL5v3ZdS61WkB172QxbRYd0frQCYTsJeZ8 VVuW788E3q64IJmCGViIEPCvKGN5Zoi2jtrWvCIv27rVP/LIJqcJOH6FuS/OE1jq9F5p 4Rlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=t99ObJB56KhBS/WNpgsgAnYcJ+G543s7eRggbvF+GSc=; b=OLDXF78cGH6z6i87MwU/M6OUKSbDlCJRhVYBXc6MzbOxQ2xhGzBmo13Rh0Y/Ni6KTz Y7Hw8guEZB/iZtpyevwy2Ta7xo1i5pEJ3/eccVxP7c/C6xmJvIYIanF/NcZ0+L6J7tDq luI83g4Ii5IBMZ1r8tWugN69dl5nlZRBrYrVtFRzZ6AN+oeYv1vKL15/lOQK+jq4WPjZ vI5Z8tAvu3+TdVAmK1YGZhsr7a9DycRVVZenMk6cvsMV/peADiUT2thQWud/FDN8xlM7 AlRwngkR1QQzVgDXLQ6oWNPOR+cRdYsuabdj0WqQjMvqKWX7pAuUphzFqyStk3YKpQdj WQEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZI5aiYWM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si5082417edo.172.2019.10.19.02.11.06; Sat, 19 Oct 2019 02:11:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZI5aiYWM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2443199AbfJRTA0 (ORCPT + 99 others); Fri, 18 Oct 2019 15:00:26 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:34207 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443193AbfJRTAZ (ORCPT ); Fri, 18 Oct 2019 15:00:25 -0400 Received: by mail-oi1-f196.google.com with SMTP id 83so6129042oii.1 for ; Fri, 18 Oct 2019 12:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=t99ObJB56KhBS/WNpgsgAnYcJ+G543s7eRggbvF+GSc=; b=ZI5aiYWM+xn39N9ZL4bzOc/HegZiWV9I8vBroRd4GUo4BX8a7uWfmvRi1rOlQ0yOrm F2179cWsuL18gEZhsafeFRl2Kd1ODlkoge3lflx7dcGTLhP5mUamYddeu5/X3VGr74F9 VWi93Dqdvc2LrlYCPsfEqE5NP58rgHfjloniDzkqOnOP4qFHLzxyCRYDZeJhxSQ0dQNg XzdQ6ua1WZ61PFAu9IJbUwo1iVS70dOWIMPFL7LvxLeUbsw1NOGnUy3xQ+qNVitnWQbW tfJfJJ/on8S90wHJ0FlTGGVjqegtf10GO1HyEhdxyJShol9qzaWIQXbdtRMuLFIdRj+G bttQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=t99ObJB56KhBS/WNpgsgAnYcJ+G543s7eRggbvF+GSc=; b=oe2Ztf7urwbtUuwGgl8v95e3fiwA5fVYPqZJQcKHPE1O+IT2ZMaMShTd/oTmrffhCJ w5qdwVqad9nsJO1wISJkPRCDwPaywjT8XkKnFPVYiLi1EvyTW8/62f40CzIc0mHpguvc YAk3JfhzopiL3oPUQ71kNyWXJezzJOyfmsF9JuomBH66bjCv1T8xC5dUkXX7W/uBqJEZ Z5jBTIpSWl9ohw/3jvM3Yr+CTn2iQ5G5h1U15pgWzPdI7VfY+dNISQ9DnRP64KidV/mO IL0s9rVYJ914XGNVVOd8B29e6CbalVE9xysQWtmQWQTx4CGtKjc89iEDjOWBO0jsTmQN fwyg== X-Gm-Message-State: APjAAAXg4cVYCujszlX28NOcT+VWdVlUCoK6zE7ZZY0CO/Vsk7b3MsyF OW8p7yN1Rx095+z961qBXwM= X-Received: by 2002:aca:1b04:: with SMTP id b4mr2309849oib.81.1571425224537; Fri, 18 Oct 2019 12:00:24 -0700 (PDT) Received: from ubuntu-m2-xlarge-x86 ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id u14sm1745760otj.61.2019.10.18.12.00.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Oct 2019 12:00:23 -0700 (PDT) Date: Fri, 18 Oct 2019 12:00:22 -0700 From: Nathan Chancellor To: Segher Boessenkool Cc: Nick Desaulniers , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , clang-built-linux , linuxppc-dev , LKML Subject: Re: [PATCH v4 3/3] powerpc/prom_init: Use -ffreestanding to avoid a reference to bcmp Message-ID: <20191018190022.GA1292@ubuntu-m2-xlarge-x86> References: <20190911182049.77853-1-natechancellor@gmail.com> <20191014025101.18567-1-natechancellor@gmail.com> <20191014025101.18567-4-natechancellor@gmail.com> <20191014093501.GE28442@gate.crashing.org> <20191014191141.GK28442@gate.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191014191141.GK28442@gate.crashing.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 14, 2019 at 02:11:41PM -0500, Segher Boessenkool wrote: > On Mon, Oct 14, 2019 at 08:56:12AM -0700, Nick Desaulniers wrote: > > On Mon, Oct 14, 2019 at 2:35 AM Segher Boessenkool > > wrote: > > > > > > On Sun, Oct 13, 2019 at 07:51:01PM -0700, Nathan Chancellor wrote: > > > > r374662 gives LLVM the ability to convert certain loops into a reference > > > > to bcmp as an optimization; this breaks prom_init_check.sh: > > > > > > When/why does LLVM think this is okay? This function has been removed > > > from POSIX over a decade ago (and before that it always was marked as > > > legacy). > > > > Segher, do you have links for any of the above? If so, that would be > > helpful to me. > > Sure! > > https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html > > Older versions are harder to find online, unfortunately. But there is > > https://kernel.org/pub/linux/docs/man-pages/man-pages-posix/ > > in which man3p/bcmp.3p says: > > FUTURE DIRECTIONS > This function may be withdrawn in a future version. > > Finally, the Linux man pages say (man bcmp): > > CONFORMING TO > 4.3BSD. This function is deprecated (marked as LEGACY in > POSIX.1-2001): use memcmp(3) in new programs. POSIX.1-2008 removes the > specification of bcmp(). > > > > I'm arguing against certain transforms that assume that > > one library function is faster than another, when such claims are > > based on measurements from one stdlib implementation. > > Wow. The difference between memcmp and bcmp is trivial (just the return > value is different, and that costs hardly anything to add). And memcmp > is guaranteed to exist since C89/C90 at least. > > > The rationale for why it was added was that memcmp takes a measurable > > amount of time in Google's fleet, and most calls to memcmp don't care > > about the position of the mismatch; bcmp is lower overhead (or at > > least for our libc implementation, not sure about others). > > You just have to do the read of the last words you compare as big-endian, > and then you can just subtract the two words, convert that to "int" (which > is very inconvenient to do, but hardly expensive), and there you go. > > Or on x86 use the bswap insn, or something like it. > > Or, if you use GCC, it has __builtin_memcmp but also __builtin_memcmp_eq, > and those are automatically used, too. > > > Segher Just as an FYI, there was some more discussion around the availablity and use of bcmp in this LLVM bug which spawned commit 5f074f3e192f ("lib/string.c: implement a basic bcmp"). https://bugs.llvm.org/show_bug.cgi?id=41035#c13 I believe this is the proper solution but I am fine with whatever works, I just want our CI to be green without any out of tree patches again... Cheers, Nathan