Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1262876imu; Wed, 16 Jan 2019 15:58:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN71olBGTgQKXqsQAqbNlUPKGnDHQl65xhOE+syZZImR1UuzTRHBrt8/WSl6caR/vPrAFVzs X-Received: by 2002:a62:ca05:: with SMTP id n5mr12614152pfg.154.1547683101839; Wed, 16 Jan 2019 15:58:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547683101; cv=none; d=google.com; s=arc-20160816; b=Uv3sxBLzoan/kz0bVlRZM2Gjf7QG1mI6XacgdQFfD4k73YYz6BKbV9QiS9uX0vwfW2 ghk10dVOLnqKgEs5tgFzhC3TonIUSOQ9Id5V1Dj5iyTQyvY1pET7PciE0hHf3i0kC470 Y8260T0q14tMQcXWpbZwk2Pd3Q/RNnWTzRyMlFqu8gx+n9exk8No2mI2GRYDEg9OrO7b zQY7VQWvq5xRw7CfUh5DPYxDFRX6U7ARmyAc3a1m4r2Yo2Rq0xfk8BY9cmmMkEqTWaxP iO3mhN+41MjEEAQjhsGsigh3YNuyXW4dGUkp0ripkL/Z8TvcvH8ItqKa0WL5vdPyhovF UUmg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=u3NmeDXrPtRK1zcDPOiylxwPTxXIwNj6TbhK9O5GIb8=; b=gTXjF4SmbYvxeZu0gKFtb+9AVweWcZuuR+VlOhFF31DC01k8CYWzQrhrL7jeGxt01E R5Vw3UA43EzXlGUUxAhI9xV/WeybFJCO3c7F/w6lq4W7ldTTQa+DFfpJOjOVIgEJfm/H lsJcdTyRwaFbdOKJFV25yKsMRqIgLS8E2Eu6I3220CIWRGhyQEz1Y4jKbrhP7ceZqHqw ikWVBzNt1udV6GjchfORyB4U4REZ8SZvj6N2IEpFMS6XSQ77imuc5ge2A/ikXvzy8QUs xJv1BuZFLNkYLyxXCht4/m8J0949pkVvFgAUFGLVJCvSkcfD3+zM3UCed/tKLkOXIdIQ JgPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lQGERS4t; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x23si7122552pgj.247.2019.01.16.15.58.01; Wed, 16 Jan 2019 15:58:21 -0800 (PST) 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=@kernel.org header.s=default header.b=lQGERS4t; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728743AbfAPS0Q (ORCPT + 99 others); Wed, 16 Jan 2019 13:26:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:45340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728671AbfAPS0P (ORCPT ); Wed, 16 Jan 2019 13:26:15 -0500 Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 03256206C2; Wed, 16 Jan 2019 18:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547663174; bh=xnGEX9v6nmKAsw2QN5b5mi4P3QWOR/2zUgstlmwUAJM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=lQGERS4tCUZX+yjgowEXKui5On8Lf6nX96c9ds9vkhTb56yB2t0I0njSfOvlpnHCz 6+dPF67EzjXbHCqdm0fLOfgdc1cMX1e7ho1I7aZsZhtHgAkEPmmYIMUILzV4GZtjg2 PhuNw0/tmRtQDrC/d6Wqbw4BndQx1pnHh+8cmQLQ= Subject: Re: [PATCH 3/4] selftests: seccomp: use LDLIBS instead of LDFLAGS To: Kees Cook , =?UTF-8?Q?Daniel_D=c3=adaz?= Cc: Fathi Boudra , Andy Lutomirski , Will Drewry , "open list:KERNEL SELFTEST FRAMEWORK" , open list , shuah References: <20190116174320.14938-1-daniel.diaz@linaro.org> <20190116174320.14938-3-daniel.diaz@linaro.org> From: shuah Message-ID: Date: Wed, 16 Jan 2019 11:26:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/16/19 11:13 AM, Kees Cook wrote: > On Wed, Jan 16, 2019 at 9:44 AM Daniel Díaz wrote: >> >> From: Fathi Boudra >> >> 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 > Thanks for the patch. > Acked-by: Kees Cook > > Shuah, can you take this? > Thanks for Ack. I will get this in for 5.0-rc3 or rc4. thanks, -- Shuah