From patchwork Wed Jun 28 17:08:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fathi Boudra X-Patchwork-Id: 106556 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp158493qge; Wed, 28 Jun 2017 10:09:45 -0700 (PDT) X-Received: by 10.99.104.74 with SMTP id d71mr11807453pgc.7.1498669785098; Wed, 28 Jun 2017 10:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498669785; cv=none; d=google.com; s=arc-20160816; b=QNfqjS5/j+XCvgkihqVZEocs6W2UDrx8n55yykNksO87PtN877eOaHSnke/P8AH/IU ikZKq12Ukot848KCI/Xgo4t7IQ23JB/16p5KfThMwXVi/JG/fQJa7BzIQ7eDk+7KoUop L3RO115XH93+iTWwIAvjnsNsg+QqWAaiNkgwQYKBo14DmWwQOr7/E8xC8oJCvR8IPmsq QmR1P2pyXGkHh/msQ6z4FuFAmAQK88aExi7VA6HU+h7j+XwiD+ynzpFzeUm9zDdE7z/e xpdH8FtaIiFnrXZHGPm3g7F5tzsoqScjhEr+OoGySa0WC1yz4pkR+WgfzRh6/TDa5V92 wsrQ== 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=y0FuqVJLjkLXrYZ2OgokxI/xGpFHC7qi0rzVJlYcqys=; b=S5ELjezopvFampqXl1/AineQI1TfRNscT1xa95BcLZqoOGIbor3w+P19Ye3dbsKTMs 9D00SbjTEFhhQOPCoxiCqCf6+qUJEJJ29z9TSpIW4ZO+EWZWAArOm0sfbEyp8MF0S5nK 4XA12cgdq4LAo/sZDzOCDasohLmoxtM8IwkZEvCLm/9URFWFbDm3imeKrY7KuNfCQ4jV aPxBAqm6DCY7z75yBsX4GVqL+Eju1gT1rhsyOGjwGxbfKXzQ1CD7/gH8OKZ3bPRHsBBy n3NvpMgVX2XS8OdLALSNX8cKuw7ayVFq1UfWNPfsJyAcpnEugc7FBdI8fiwOy7am7/yC 9LzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=fIC68zu1; 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 k5si2110825pln.98.2017.06.28.10.09.44; Wed, 28 Jun 2017 10:09:45 -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=fIC68zu1; 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 S1752059AbdF1RJc (ORCPT + 25 others); Wed, 28 Jun 2017 13:09:32 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:34858 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751900AbdF1RJK (ORCPT ); Wed, 28 Jun 2017 13:09:10 -0400 Received: by mail-lf0-f41.google.com with SMTP id b207so38765978lfg.2 for ; Wed, 28 Jun 2017 10:09:10 -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=y0FuqVJLjkLXrYZ2OgokxI/xGpFHC7qi0rzVJlYcqys=; b=fIC68zu1VQ59fbcmxIX+CLZ2aRUgx0C+iqP1EZ7hS6IrWHa2oo+lu32JJ/CTPD83UY 4gNHMM6c+K43vV1E7EMmtZxxMIt2cSdwvjuoZh/sEvaePkM4HKITkPDL24aItgQKE56F XGoCRSMjGZ5V5qEfGyAPTBhvzAeb1uFLUShjE= 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=y0FuqVJLjkLXrYZ2OgokxI/xGpFHC7qi0rzVJlYcqys=; b=fDgIYFesVw3tj4MhOyhfMexi08jLIIv+Mb9V6GA8Bvsl7aG96kVUKlBrTImaO1chDA ssK/u7yz03JscMdstg/zSE5qcQQPtTZRIXtjc/4LxoPXDj96xspDW+xJd/i3/XWcqLvS 7hEcqqMQPW2N+8Q+AsjOOFdwq5wkLMQjL5LTSy+av42BfxqWB9pG6t9OGWiC2dseO6fH pPxRKOYh5Bje3lmLqhcCcLwoHJHnEhGAOdeWlgnBC+TJXxodAtBii2TcYe0VxMIDPIBc 0GpnhcFUNTaTfe9kP7QuXVlSktw9A8vLVxhGJrBQk5ruCiCJjCmr2398MMqDM0k0PtLm nEaw== X-Gm-Message-State: AKS2vOyasrhKhbyWf2JDFP+MKP/E9wD8TtVyyHqX8yJA9ztv38NeIMaD gJNTqKjCHFdWhfLc X-Received: by 10.25.206.205 with SMTP id e196mr3949090lfg.126.1498669749106; Wed, 28 Jun 2017 10:09:09 -0700 (PDT) Received: from localhost.localdomain (a91-156-68-101.elisa-laajakaista.fi. [91.156.68.101]) by smtp.gmail.com with ESMTPSA id h6sm580796lji.59.2017.06.28.10.09.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Jun 2017 10:09:07 -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 3/3] selftests: timers: use LDLIBS instead of LDFLAGS Date: Wed, 28 Jun 2017 20:08:59 +0300 Message-Id: <20170628170859.28583-4-fathi.boudra@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170628170859.28583-1-fathi.boudra@linaro.org> References: <20170628170859.28583-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 posix_timers 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 -O3 -Wl,-no-as-needed -Wall -DKTEST -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lrt -lpthread posix_timers.c -o /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers /tmp/cc1FTZzT.o: In function `check_timer_create': /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers.c:157: undefined reference to `timer_create' /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers.c:170: undefined reference to `timer_settime' collect2: error: ld returned 1 exit status 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: Denys Dmytriyenko Signed-off-by: Fathi Boudra --- tools/testing/selftests/timers/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.13.0 diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile index 5fa1d7e9a915..f48d7ca9d9b1 100644 --- a/tools/testing/selftests/timers/Makefile +++ b/tools/testing/selftests/timers/Makefile @@ -1,6 +1,6 @@ BUILD_FLAGS = -DKTEST CFLAGS += -O3 -Wl,-no-as-needed -Wall $(BUILD_FLAGS) -LDFLAGS += -lrt -lpthread +LDLIBS += -lrt -lpthread # these are all "safe" tests that don't modify # system time or require escalated privileges