From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05970C433B4 for ; Tue, 13 Apr 2021 22:18:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB0E861246 for ; Tue, 13 Apr 2021 22:18:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231240AbhDMWSX (ORCPT ); Tue, 13 Apr 2021 18:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231238AbhDMWSX (ORCPT ); Tue, 13 Apr 2021 18:18:23 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01E1CC061574 for ; Tue, 13 Apr 2021 15:18:02 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id l14so18243789ljb.1 for ; Tue, 13 Apr 2021 15:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vI1T++XVMddunMQm6m8+Ept2Pbyb4PuMdjV9WGh6X2k=; b=W6w4Vd5ppA+JcaRcEKuDOnKiZQ+9mb7XB1uwX0jMZ/HhT1fI5kBAhMUT7NEarvEF+E J1syqD97wKfBlBdssG9C4KliNWCB3XGjtE8E7ymDETR1osbqzkRMkHPl+3VnMsZhcJS8 kjs75GBdmCUjlGwLswZ3lO8PcCUsBDiolcas+XiAkFjdzXEjPhl4TV18klZfnXCW3dwl FcpTPDuhhK2aAX6U0Pc5wDn7xt9aYS21ZDYWNrHqP3dPRLMbC1JPIGR7GMVn36Qvetbd VAkp1l0+wqjaVBidC7g5tolV6yxJvMyAczFSIuGMAa6BxyM/27RBiS4umsarK6VpZd6w 0rWw== 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=vI1T++XVMddunMQm6m8+Ept2Pbyb4PuMdjV9WGh6X2k=; b=cxMPOIsvBMkDn7zHC3atexA9gQ/52Yrnclza1gg1oS4OQ/Klmm6/wPznR5QfMgYX1R a4WmvU2S2MDSyhSXwDzs2nvzQWC/+tifG/8MqxYJcGBaWBgP3OeSuCi4o2BFmP9T2jdR IxlvJS/wiTwniwklmDjkWN3FrIx8L4nkvcKeH30hR5VO2gby9RYm2b4OLstzWZc8qtkv RUt3eb11yotCSizZnLsIYhqmOQbP8OSOJUQPWIAjAi1AjcoHZDbJNHPXYA5i6LnHTLrd dLCJTJF67hJ8BA9ZMezaAwg7TsxYTcYjNMPg58G3ak6ahOq85iobjskOtlodby5chZRd J3Jw== X-Gm-Message-State: AOAM531Pc4pkip+aBHdPjQgSa8LNcg0VMBFDkrgVOYqs5G31+Bf7I7Wl 2a1xRsPgxTfpT4PRTgRwpR/SXf0MhFILebDCmq+epw== X-Google-Smtp-Source: ABdhPJxn0rbbwtOSInyleVJ9d9m7vZP3dMmAyoteQYX9VeoG1bvChHXvZyDc4L+SsjppQxBrrtW+yF4u1r3EQGV+XhE= X-Received: by 2002:a2e:b008:: with SMTP id y8mr21360358ljk.233.1618352280935; Tue, 13 Apr 2021 15:18:00 -0700 (PDT) MIME-Version: 1.0 References: <20210413153408.3027270-1-yhs@fb.com> <20210413153429.3029377-1-yhs@fb.com> In-Reply-To: From: Nick Desaulniers Date: Tue, 13 Apr 2021 15:17:49 -0700 Message-ID: Subject: Re: [PATCH bpf-next v3 4/5] selftests/bpf: silence clang compilation warnings To: Andrii Nakryiko Cc: Yonghong Song , bpf , Andrii Nakryiko , Arnaldo Carvalho de Melo , Kernel Team , Sedat Dilek Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Tue, Apr 13, 2021 at 3:08 PM Andrii Nakryiko wrote: > > On Tue, Apr 13, 2021 at 8:34 AM Yonghong Song wrote: > > > > With clang compiler: > > make -j60 LLVM=1 LLVM_IAS=1 <=== compile kernel > > make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1 > > Some linker flags are not used/effective for some binaries and > > we have warnings like: > > warning: -lelf: 'linker' input unused [-Wunused-command-line-argument] > > > > We also have warnings like: > > .../selftests/bpf/prog_tests/ns_current_pid_tgid.c:74:57: note: treat the string as an argument to avoid this > > if (CHECK(waitpid(cpid, &wstatus, 0) == -1, "waitpid", strerror(errno))) > > ^ > > "%s", > > .../selftests/bpf/test_progs.h:129:35: note: expanded from macro 'CHECK' > > _CHECK(condition, tag, duration, format) > > ^ > > .../selftests/bpf/test_progs.h:108:21: note: expanded from macro '_CHECK' > > fprintf(stdout, ##format); \ > > ^ > > The first warning can be silenced with clang option -Wno-unused-command-line-argument. > > For the second warning, source codes are modified as suggested by the compiler > > to silence the warning. Since gcc does not support the option > > -Wno-unused-command-line-argument and the warning only happens with clang > > compiler, the option -Wno-unused-command-line-argument is enabled only when > > clang compiler is used. > > > > Signed-off-by: Yonghong Song > > --- > > LGTM, please see the question below. > > Acked-by: Andrii Nakryiko > > > tools/testing/selftests/bpf/Makefile | 5 +++++ > > tools/testing/selftests/bpf/prog_tests/fexit_sleep.c | 4 ++-- > > tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c | 4 ++-- > > 3 files changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > > index dcc2dc1f2a86..c45ae13b88a0 100644 > > --- a/tools/testing/selftests/bpf/Makefile > > +++ b/tools/testing/selftests/bpf/Makefile > > @@ -28,6 +28,11 @@ CFLAGS += -g -Og -rdynamic -Wall $(GENFLAGS) $(SAN_CFLAGS) \ > > -Dbpf_load_program=bpf_test_load_program > > LDLIBS += -lcap -lelf -lz -lrt -lpthread > > > > +# Silence some warnings when compiled with clang > > +ifneq ($(LLVM),) > > This won't handle the case where someone does `make CC=clang`, right? > Do we care at all? Right; it would be better to check CC=clang and have LLVM=1 enable CC=clang from a higher level Makefile (since tools/build/Makefile seems to override the top level $CC). See the top level Makefile L448-456. Then it should work for CC=clang or LLVM=1. > > > > +CFLAGS += -Wno-unused-command-line-argument > > +endif > > + > > [...] -- Thanks, ~Nick Desaulniers