From patchwork Thu Jun 29 07:24:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fathi Boudra X-Patchwork-Id: 106610 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp780103qge; Thu, 29 Jun 2017 00:25:17 -0700 (PDT) X-Received: by 10.101.83.197 with SMTP id z5mr7059693pgr.261.1498721117136; Thu, 29 Jun 2017 00:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498721117; cv=none; d=google.com; s=arc-20160816; b=OGKx8DBxHhzynHGJZD0FE+jJldivqi0RpjgCdqk+CeR6QmRva3Haycv8sf/hI13g4D nafzafkhzadclCVt/FXmvVO5cWzxS8ugG+J2nYu0PbeTwDmd8XUxQadXCAsRawVX245v SRbRLrHR2ekbs8YfrEMnzteshx11nnKZ+JDiq8eldXVibLFkprGN/rf8GlwJ3zgMOVLL GrVoWk75mLwobeKh6uuwJY5gn2MmiLOkmyXhi5eFpneCf46dCHsu8JIeycHpuk/uMae1 IX0n/olAAWmd3jpZuBiKi4BnZfjpENbAop1Un1hec9swI7oppanBSgQurTV8S6PRxOlH LQCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=0jaSXxDZeQdlhSPxlAB2wUQZDgPruqXO5LerNrcLZco=; b=M0bB3jPmFo5PfTpmtvsRnrjwJ5OO05hisXJMi+fE3yvfM/6EMhK06EhOpV5JclNvcG dbf/M7K1kQPaK29xPLpwYrtG5w8MCB5Gn+VtSd4A6bHwUvJJbdsby7VBiGYcf9NZAO4+ xLICqAJWFWCGJ8+k1SSyNVSwM88uRHlFcX8REwU5Z6pFVulBuLaDIYXWMgW4/OCWgbW5 UtywJgVgHfB2ko9pk7e8Y5pLcH7sMqMzCkQCsqTSHZZDhjRAFAuMvj1vvy3Pqq2KeZV4 KPeUtovwZcB2F2+E5/7P95JYd4F8URtLB89fFpYy+aiJmMdnEsGc2+3OEoSSs/8fIn4F Sg9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=PLZCXViD; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d188si3185026pfc.312.2017.06.29.00.25.16; Thu, 29 Jun 2017 00:25:17 -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=@linaro.org header.b=PLZCXViD; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752167AbdF2HZO (ORCPT + 25 others); Thu, 29 Jun 2017 03:25:14 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:34474 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751934AbdF2HZG (ORCPT ); Thu, 29 Jun 2017 03:25:06 -0400 Received: by mail-lf0-f45.google.com with SMTP id l13so47571720lfl.1 for ; Thu, 29 Jun 2017 00:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0jaSXxDZeQdlhSPxlAB2wUQZDgPruqXO5LerNrcLZco=; b=PLZCXViD8WJ0diyJ0M1NBpGGAXDM+cl6piagBQG12GbQbU2Ofh8IOHZqmHpDhUIW0T XmJuvWSieLvObPbBzlYrVJnDmsa1HXOCd4RZ2yx7liUmaThiiED/HJsi7XobdTA5cASK RT4D2qWIiiHvgVnuVmhNoStHukQATGHwLflWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0jaSXxDZeQdlhSPxlAB2wUQZDgPruqXO5LerNrcLZco=; b=kXjg+6RdK3mJFMs0cTLGf3IbDiRxaYbqz4/rBzGpwCK9J8l1ndJPx022DSJsdiyBBb +33QkptWvqar5BIXucvnm1mYoe9TaVyqOwWpbIITT+2/53dhhgdNQvuJ6jURzlfj7YuA 3mumKXRDxEkeIFdGiEo4YqAwMrbDFErdakGbUe2DPUjIPo/FgElTYL6qQL5P68r1vz8z BraLI2dcrLMGrUTAa5cCNpm98FPzTbeq/RCtc2IFJ+mnj1oL5nqujZ/sKV03bEuaHHWB E/pVcB/Jy2vnbp18PdnctZkuDvt2kwrExSwekKIy3VnkCRXbG1kHeXB5AzJNH0zJCGP/ Mkgg== X-Gm-Message-State: AKS2vOx0QkEbMGGUvx69TlXeN+nN/cNYXw11NOmQ4Uv7/Xzx6VgT3nzh 2M48rfoP9uF7bD1s X-Received: by 10.25.234.6 with SMTP id i6mr5648142lfh.42.1498721103886; Thu, 29 Jun 2017 00:25:03 -0700 (PDT) Received: from localhost.localdomain (a91-156-68-101.elisa-laajakaista.fi. [91.156.68.101]) by smtp.gmail.com with ESMTPSA id m27sm1082006lfi.50.2017.06.29.00.25.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jun 2017 00:25:02 -0700 (PDT) From: Fathi Boudra To: linux-kselftest@vger.kernel.org, Shuah Khan Cc: linux-kernel@vger.kernel.org, John Stultz , Denys Dmytriyenko , SeongJae Park , Fathi Boudra Subject: [PATCH v2 2/3] selftests: seccomp: use LDLIBS instead of LDFLAGS Date: Thu, 29 Jun 2017 10:24:58 +0300 Message-Id: <20170629072459.30741-3-fathi.boudra@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170629072459.30741-1-fathi.boudra@linaro.org> References: <20170629072459.30741-1-fathi.boudra@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org seccomp_bpf fails to build due to undefined reference errors: aarch64-linaro-linux-gcc --sysroot=/build/tmp-rpb-glibc/sysroots/hikey -O2 -pipe -g -feliminate-unused-debug-types -Wl,-no-as-needed -Wall -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lpthread seccomp_bpf.c -o /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf /tmp/ccrlR3MW.o: In function `tsync_sibling': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1920: undefined reference to `sem_post' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1920: undefined reference to `sem_post' /tmp/ccrlR3MW.o: In function `TSYNC_setup': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1863: undefined reference to `sem_init' /tmp/ccrlR3MW.o: In function `TSYNC_teardown': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1904: undefined reference to `sem_destroy' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1897: undefined reference to `pthread_kill' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1898: undefined reference to `pthread_cancel' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1899: undefined reference to `pthread_join' /tmp/ccrlR3MW.o: In function `tsync_start_sibling': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /tmp/ccrlR3MW.o: In function `TSYNC_siblings_fail_prctl': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1978: undefined reference to `sem_wait' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1990: undefined reference to `pthread_join' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1992: undefined reference to `pthread_join' /tmp/ccrlR3MW.o: In function `tsync_start_sibling': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_ancestor': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2016: undefined reference to `sem_wait' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2032: undefined reference to `pthread_join' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2034: undefined reference to `pthread_join' /tmp/ccrlR3MW.o: In function `tsync_start_sibling': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /tmp/ccrlR3MW.o: In function `TSYNC_two_sibling_want_nnp': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2046: undefined reference to `sem_wait' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2058: undefined reference to `pthread_join' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2060: undefined reference to `pthread_join' /tmp/ccrlR3MW.o: In function `tsync_start_sibling': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_no_filter': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2073: undefined reference to `sem_wait' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2098: undefined reference to `pthread_join' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2100: undefined reference to `pthread_join' /tmp/ccrlR3MW.o: In function `tsync_start_sibling': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_one_divergence': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2125: undefined reference to `sem_wait' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2143: undefined reference to `pthread_join' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2145: undefined reference to `pthread_join' /tmp/ccrlR3MW.o: In function `tsync_start_sibling': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_not_under_filter': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2169: undefined reference to `sem_wait' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2202: undefined reference to `pthread_join' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2227: undefined reference to `pthread_join' /tmp/ccrlR3MW.o: In function `tsync_start_sibling': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create' It's GNU Make and linker specific. The default Makefile rule looks like: $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS) When linking is done by gcc itself, no issue, but when it needs to be passed to proper ld, only LDLIBS follows and then ld cannot know what libs to link with. More detail: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html LDFLAGS Extra flags to give to compilers when they are supposed to invoke the linker, ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable instead. LDLIBS Library flags or names given to compilers when they are supposed to invoke the linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS variable. https://lkml.org/lkml/2010/2/10/362 tools/perf: libraries must come after objects Link order matters, use LDLIBS instead of LDFLAGS to properly link against libpthread. Signed-off-by: Fathi Boudra --- tools/testing/selftests/seccomp/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.13.0 diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index aeb0c805f3ca..7c0afc3c8aef 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,8 +1,8 @@ TEST_GEN_PROGS := seccomp_bpf CFLAGS += -Wl,-no-as-needed -Wall -LDFLAGS += -lpthread +LDLIBS += -lpthread include ../lib.mk $(TEST_GEN_PROGS): seccomp_bpf.c ../kselftest_harness.h - $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS) -o $@