Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp927675pxb; Tue, 3 Nov 2020 16:58:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxc4uYWVwGWBRxwU8b4/atBwhuHraH6xS2zuMy9q+b/50vVR2UE0ncxL7O7GQ6FYZiuzKBO X-Received: by 2002:a17:906:31c6:: with SMTP id f6mr22871285ejf.164.1604451521305; Tue, 03 Nov 2020 16:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604451521; cv=none; d=google.com; s=arc-20160816; b=oGVuBAu5+nDsJ9nAT11eiJ1qGoWHxL7U/BQmHy8P/i4+rOQViGw0Rc/Pc1SFI2fCnN D3N8bYx+Q+hWfXimr2PV2rkltmv5lBTjqp4mHixUh1rnYmM5a9klX8AmsPe5LrwRvFnd n/pntYhrxY1FPy0xzj8Ij0eyB6UADVWuCErk8xncEN56UtnfrsibEuAxULsCkpbzZGmW 48bOqXX3hHbvXKTrYYLj61zgZS25MlTTYMcDPFH8pBC6Z7nnxBSn4kmVbCwwnK9ZhNx2 ++7JJgcJzRlKeak8zEYosKUCcpDcTWvSkZYu6O27xeax4BzJ5wn7zqnBuPe6VDG698A9 Pv0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=fEgHoEwH/Qn4FmtMQAK1i8tQpW1NQPuJnI+u+2FH2KM=; b=Kxk6dckZXWVkROQN3h3g5hV2u3wZz1SllhVtdPEVblxHnIqcY7AYKYCk+AfcBdvY6O qLQLfHAjxkVaXIh0Vmusw6pLfsSYapviBQ1NUTvJbbfLW/JdZC9S8XvyMnPN9U50Ig4x 7hEhRf2NsOzFLhhneBPDcnDQtWjyD7GQ66sobzA0X0qFTxPazQR0ugt/DCDF05q6X6bU Ae0JIZt2BIlFYSzcVjUHaVNUo6har75DCCPLpKTLxSOSBL2C/TGSVZIa/w1AR2hx4TlH GS2nbnhs7gRJcjE5KoXhHf0IvuqtVsqcxi1Vxr/hoMLtWeF6fauuB1pfIu+X1JdQV7eL RTaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FPor5ao+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zn5si385692ejb.202.2020.11.03.16.58.18; Tue, 03 Nov 2020 16:58:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FPor5ao+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730175AbgKDA4O (ORCPT + 99 others); Tue, 3 Nov 2020 19:56:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729163AbgKDA4N (ORCPT ); Tue, 3 Nov 2020 19:56:13 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DB4C040203 for ; Tue, 3 Nov 2020 16:56:13 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id w4so19888728ybq.21 for ; Tue, 03 Nov 2020 16:56:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=fEgHoEwH/Qn4FmtMQAK1i8tQpW1NQPuJnI+u+2FH2KM=; b=FPor5ao+bC4TgCl1QyGqGMAkqS4F3BnFzzHIHy73yy1gvN3Jzs7nmoLnollXBLFeM/ X/DTngmWYrti7gw3skF3RfMr+899UDUFeGiYvO5fMEeJ6cwa6WuXwblz1U4PyAz3V0PV VN9QYVMoaNb7iwwtoZlMPqljXJUpS2NSvyE2F0WQ8JWMvm61lrgzlFemct7gLV8izChC k4+1j2ql4iO/zGW/QIvgw1ksmH5V7X+I0uW8VPvQDlar/pKAk/ghv7U6qv8Bohv+Sddd LhVsjdwavyTOeBeQUJc7HVQmFS4vStNv4tgoo4vywf597CeO9q32VfHbH/baP915sbgD HPdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=fEgHoEwH/Qn4FmtMQAK1i8tQpW1NQPuJnI+u+2FH2KM=; b=g2VcJKhkt2IZIGZDSmYxYm4zN+Dqqu5y8a/4rLbKzhfcNTjQyDR/fRSh+ZMadW/Hxz FPrc66cvXvLxMuOZSiBobTz0DikKJDB/XQoWAbmcIow487Qn4eohJNbO6NoZuUuTRnR9 o21+8SioJVjIXMKSplF7wl5on85b9Wxe5jgme0PHQRU6ay69/V1sM2TdN9XMuZDE+KHV 9ViYNi+qXWhVUM43uKJJsU2Fjy+uaC+UHWTvWlDLJmRoDxXUOAYYI8m/Q+2ObHfX0G0H QbISGvmtk99qNKr1sGBgWqwmKSeKSzcLY/ujYCY+IOdy9HpoDR5K4e2G6Tr5kvu2TDkO uFbg== X-Gm-Message-State: AOAM532dZ0NWQ91g35YzuGIsWROKnXqOAKkpnViLQI2gUxTpUFasd2Eg 8nB9K8kzWuZjzEjgbXCRfxWsh6kOrx/1 Sender: "maskray via sendgmr" X-Received: from maskray1.svl.corp.google.com ([2620:15c:2ce:0:a6ae:11ff:fe11:4abb]) (user=maskray job=sendgmr) by 2002:a25:57d6:: with SMTP id l205mr31348808ybb.117.1604451372895; Tue, 03 Nov 2020 16:56:12 -0800 (PST) Date: Tue, 3 Nov 2020 16:56:09 -0800 Message-Id: <20201104005609.1316230-1-maskray@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH] perf bench: Update arch/x86/lib/mem{cpy,set}_64.S From: Fangrui Song To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Dan Williams Cc: linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Ian Rogers , Fangrui Song Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In memset_64.S, the macros expand to `.weak MEMSET ... .globl MEMSET` which will produce a STB_WEAK MEMSET with GNU as but STB_GLOBAL MEMSET with LLVM's integrated assembler before LLVM 12. LLVM 12 (since https://reviews.llvm.org/D90108) will error on such an overridden symbol binding. memcpy_64.S is similar. Port http://lore.kernel.org/r/20201103012358.168682-1-maskray@google.com ("x86_64: Change .weak to SYM_FUNC_START_WEAK for arch/x86/lib/mem*_64.S") to fix the issue. Additionally, port SYM_L_WEAK and SYM_FUNC_START_WEAK from include/linux/linkage.h to tools/perf/util/include/linux/linkage.h Fixes: 7d7d1bf1d1da ("perf bench: Copy kernel files needed to build mem{cpy,set} x86_64 benchmarks") Link: https://lore.kernel.org/r/20201103012358.168682-1-maskray@google.com Signed-off-by: Fangrui Song --- tools/arch/x86/lib/memcpy_64.S | 4 +--- tools/arch/x86/lib/memset_64.S | 4 +--- tools/perf/util/include/linux/linkage.h | 7 +++++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/arch/x86/lib/memcpy_64.S b/tools/arch/x86/lib/memcpy_64.S index 0b5b8ae56bd9..9428f251df0f 100644 --- a/tools/arch/x86/lib/memcpy_64.S +++ b/tools/arch/x86/lib/memcpy_64.S @@ -16,8 +16,6 @@ * to a jmp to memcpy_erms which does the REP; MOVSB mem copy. */ -.weak memcpy - /* * memcpy - Copy a memory block. * @@ -30,7 +28,7 @@ * rax original destination */ SYM_FUNC_START_ALIAS(__memcpy) -SYM_FUNC_START_LOCAL(memcpy) +SYM_FUNC_START_WEAK(memcpy) ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \ "jmp memcpy_erms", X86_FEATURE_ERMS diff --git a/tools/arch/x86/lib/memset_64.S b/tools/arch/x86/lib/memset_64.S index fd5d25a474b7..1f9b11f9244d 100644 --- a/tools/arch/x86/lib/memset_64.S +++ b/tools/arch/x86/lib/memset_64.S @@ -5,8 +5,6 @@ #include #include -.weak memset - /* * ISO C memset - set a memory block to a byte value. This function uses fast * string to get better performance than the original function. The code is @@ -18,7 +16,7 @@ * * rax original destination */ -SYM_FUNC_START_ALIAS(memset) +SYM_FUNC_START_WEAK(memset) SYM_FUNC_START(__memset) /* * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended diff --git a/tools/perf/util/include/linux/linkage.h b/tools/perf/util/include/linux/linkage.h index b8a5159361b4..0e493bf3151b 100644 --- a/tools/perf/util/include/linux/linkage.h +++ b/tools/perf/util/include/linux/linkage.h @@ -25,6 +25,7 @@ /* SYM_L_* -- linkage of symbols */ #define SYM_L_GLOBAL(name) .globl name +#define SYM_L_WEAK(name) .weak name #define SYM_L_LOCAL(name) /* nothing */ #define ALIGN __ALIGN @@ -78,6 +79,12 @@ SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN) #endif +/* SYM_FUNC_START_WEAK -- use for weak functions */ +#ifndef SYM_FUNC_START_WEAK +#define SYM_FUNC_START_WEAK(name) \ + SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN) +#endif + /* SYM_FUNC_END_ALIAS -- the end of LOCAL_ALIASed or ALIASed function */ #ifndef SYM_FUNC_END_ALIAS #define SYM_FUNC_END_ALIAS(name) \ -- 2.29.1.341.ge80a0c044ae-goog