Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1056163iob; Fri, 13 May 2022 21:23:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7rACoT1iXRFqfag2IqFLVgVECK+yeIHAP8qK88a2VVpihZcubGKYFcbdMADWAd33/rE8j X-Received: by 2002:a05:600c:4f52:b0:394:63eb:ad27 with SMTP id m18-20020a05600c4f5200b0039463ebad27mr7392504wmq.35.1652502180587; Fri, 13 May 2022 21:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652502180; cv=none; d=google.com; s=arc-20160816; b=cDz0vJ6lU8T+jp0wN7KcN1sDlB16dPgMHyBgzSCZCa2YhBL76OljttNil2rNGss1f7 kHY1DZxVYT6O9+3hqtFoYUOUXOu3FdTAjC67y1hoSQF9Z10qoLf07H1zGryRzEJgWQvU QOxpDsJ3nIsxZP0zUS0Xu4UXIaX4HE8Lsy9Y0i4wwMSWH387w9pAOgioL4YTrhKj6qe2 481VRXPwJeQ0pBWDVLoOBoLXcuWXspbqGhsy24OZrbPJTWVvjwgCJ2lBw989BeMAAFMn Mh3VaIE4nAWyOKsj/lZ0BC8L4wi+yIc83Binlri65I94giBJvvY7ObsGVT9OJF6dc3Km hxUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5qaVyZvzGf9D9TR/BSQ+mQsaNY1sb+JjxbLPRurfSus=; b=K0o68RjHLWLp5pASJRzI6wmcEFP2Rc0GY/iCq3M1rYCXZtOe9ePgCG8y5Ihc2ELJAm JxvDv1u1h3PHR9572I0b7/wYEK95Hp4J5yau6WexZ07z7MwdIcXxCXyrVztt0jNEyarG /DGYS9sosCgO6thH16Wq7GnJA81dufb0ZS4UZ9hTg7mv8GFS8y551qbgJD2cSXgpVmeJ zoOPytEc69NcchxEb0e33BLTW/osleYtesjIr5IEzWx678i+ZWZFQdJXzrXViR9Tvd6k +mkkSGozrqt3MmdUQsxxVTvSL1DOnUbNMy8vnVrgY3MEb9geeu/fg3y+mxivhf+auyIb 8b8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YHuYmeoA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v15-20020adfebcf000000b0020cca583889si3448136wrn.985.2022.05.13.21.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 21:23:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YHuYmeoA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AED9D50AACF; Fri, 13 May 2022 17:53:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384910AbiEMW57 (ORCPT + 99 others); Fri, 13 May 2022 18:57:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244418AbiEMW55 (ORCPT ); Fri, 13 May 2022 18:57:57 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 297AE17E3F; Fri, 13 May 2022 15:57:56 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id a10so10243159ioe.9; Fri, 13 May 2022 15:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5qaVyZvzGf9D9TR/BSQ+mQsaNY1sb+JjxbLPRurfSus=; b=YHuYmeoAoE/7wiR96FKUJtLMpKbEH1Q10Gwb/VRld1GHa8ix+eu+vAdUdlnftwTjJQ 6XAU58Q4V/LE77PzJjsounf/xpYRZ6cAyXbxzmW5qtqct36AyhupilJzuPfiKi11UlXV /0GcNMIwPrw8PaGMMefuqeFL3QNgi5lCRbCRohKrsut50acQVrAgpe5Hz53hAt0NYlqy yXLfEDfTrGnClKF40KnzTqg3+jQz2wRwdEM5DCTNQ5LRLHiRNr8rJ8Be4QubMj97FrkD 602VdmJ7qcKE8FyMymTqI1DW8oFz8CHif3xLVYDEz+mdDAz22fvRd5oa+jdRQ8a8r3eW apVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5qaVyZvzGf9D9TR/BSQ+mQsaNY1sb+JjxbLPRurfSus=; b=tQxR6/O1pvWCn9nkRVvG/nH9a0k1fuDvrCTeeXStYimiQZBwoqJbv9KL45dvrSkC3K xtx2kMbF21XJLUxak1O+EzfKpSkdmHDa68J67GeQVQK03d41msLKnK3wsc6//2glkzj0 GI/Ta2JcnroObc+h1lpf21Zn8qvoYEOm4pn9zCWJKRGjDEVoasS2rz1Pv2AOFBQ0F8DE p/gXluqC1R/WuVJWgi2VQmDoZI/8SXVhRyaToUeIPrLxwdlSJH12wwvlKfTQ8GmZbD+6 azCe82nFXUJwOl10yrhGtTeWI4Wn8+li2TdTeNWjpmPQ7T+mEurqPr/t6flx/Xhsvdru lMTg== X-Gm-Message-State: AOAM532/GE6sY4TLXcHlB5JWC5zET4Zro8kR3O91HSpAfJK8MoH+74kN vHokwmv5e8gCDZAzZ9Ze2RoCN62mPUQglH8OJBE= X-Received: by 2002:a05:6638:533:b0:32a:d418:b77b with SMTP id j19-20020a056638053300b0032ad418b77bmr3731100jar.237.1652482675539; Fri, 13 May 2022 15:57:55 -0700 (PDT) MIME-Version: 1.0 References: <20220513004117.364577-1-yosryahmed@google.com> In-Reply-To: <20220513004117.364577-1-yosryahmed@google.com> From: Andrii Nakryiko Date: Fri, 13 May 2022 15:57:44 -0700 Message-ID: Subject: Re: [PATCH bpf-next] selftests/bpf: fix building bpf selftests statically To: Yosry Ahmed Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Networking , bpf , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 12, 2022 at 5:41 PM Yosry Ahmed wrote: > > bpf selftests can no longer be built with CFLAGS=-static with > liburandom_read.so and its dependent target. > > Filter out -static for liburandom_read.so and its dependent target. > > Signed-off-by: Yosry Ahmed > --- > tools/testing/selftests/bpf/Makefile | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > index 6bbc03161544..4eaefc187d5b 100644 > --- a/tools/testing/selftests/bpf/Makefile > +++ b/tools/testing/selftests/bpf/Makefile > @@ -168,14 +168,17 @@ $(OUTPUT)/%:%.c > $(call msg,BINARY,,$@) > $(Q)$(LINK.c) $^ $(LDLIBS) -o $@ > > +# If the tests are being built statically, exclude dynamic libraries defined > +# in this Makefile and their dependencies. > +DYNAMIC_CFLAGS := $(filter-out -static,$(CFLAGS)) I don't particularly like yet another CFLAGS global variable, but also you are not filtering out -static from LDFLAGS, which would be problematic if you try to do make SAN_FLAGS=-static which otherwise would work (and is probably better than overriding all of CFLAGS How about something like this diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 6bbc03161544..2e8eddf240af 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -170,11 +170,11 @@ $(OUTPUT)/%:%.c $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c $(call msg,LIB,,$@) - $(Q)$(CC) $(CFLAGS) -fPIC $(LDFLAGS) $^ $(LDLIBS) --shared -o $@ + $(Q)$(CC) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $^ $(LDLIBS) -fPIC -shared -o $@ $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so $(call msg,BINARY,,$@) - $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.c,$^) \ + $(Q)$(CC) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \ liburandom_read.so $(LDLIBS) \ -Wl,-rpath=. -Wl,--build-id=sha1 -o $@ ? But I also have a question, this leaves urandom_read relying on system-wide shared libraries, isn't that still a problem for you? Or you intend to just ignore urandom_read-related tests? $ ldd urandom_read linux-vdso.so.1 (0x00007ffd0d5e5000) liburandom_read.so (0x00007fc7f7d76000) libelf.so.1 => /lib64/libelf.so.1 (0x00007fc7f7937000) libz.so.1 => /lib64/libz.so.1 (0x00007fc7f7720000) librt.so.1 => /lib64/librt.so.1 (0x00007fc7f7518000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc7f72f8000) libc.so.6 => /lib64/libc.so.6 (0x00007fc7f6f33000) /lib64/ld-linux-x86-64.so.2 (0x00007fc7f7b50000) > $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c > $(call msg,LIB,,$@) > - $(Q)$(CC) $(CFLAGS) -fPIC $(LDFLAGS) $^ $(LDLIBS) --shared -o $@ > + $(Q)$(CC) $(DYNAMIC_CFLAGS) -fPIC $(LDFLAGS) $^ $(LDLIBS) --shared -o $@ > > $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so > $(call msg,BINARY,,$@) > - $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.c,$^) \ > - liburandom_read.so $(LDLIBS) \ > + $(Q)$(CC) $(DYNAMIC_CFLAGS) $(LDFLAGS) $(filter %.c,$^) \ > + liburandom_read.so $(LDLIBS) \ > -Wl,-rpath=. -Wl,--build-id=sha1 -o $@ > > $(OUTPUT)/bpf_testmod.ko: $(VMLINUX_BTF) $(wildcard bpf_testmod/Makefile bpf_testmod/*.[ch]) > -- > 2.36.0.550.gb090851708-goog >