From patchwork Thu Jun 29 07:24: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: 106611 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp780850qge; Thu, 29 Jun 2017 00:26:31 -0700 (PDT) X-Received: by 10.84.229.69 with SMTP id d5mr16109687pln.197.1498721190954; Thu, 29 Jun 2017 00:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498721190; cv=none; d=google.com; s=arc-20160816; b=fKklVVxTk/zfrAyhK+O1J7fAfPfeqKcPzXO3VdADJmQE/JYOfo8G7+H3pgfQIMWwZ5 OmdBH0zxA+8srg9+q6e7sOOyvPPX2WswjLeq/6+qMWOHyz4T83h2U4aUKf5qUs2do+cr kDY4OA/YxHvvb9h2KTgOTQ6pWJGfizyh+M4H1kHikjBcfdphwmmOHz78dRkGCH3RDGB4 M+hih6UONbmeVpOI/8yJIp83nSK3xKpXSMmd9gka66JyO3oCJo4M/oriUB8E1ecBUsu5 WEXJzqu2gj1F0pttlboQlI2BdYNncE4Y5iR83esyneBw8/dwjCAtQQ8ZCvDnxeSYFJA2 LQng== 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=bl6Ytb10oquZsV8LdVBA1dyxdky4LIgvixGjdGm3WqavQFuV/i4TPjyzjXwzES9D5p bcEOsLtloJVzv3OfP3jPYoT8XOWmmQDZj8w8frt7fJzJJ67ARRzIpSot1axBKyNAjZ96 XE2KojmtwoeomJazHc4f4Sg+/UFxGnJh/P8yW8u0t+OnC0z2/fbMzm7xGQzkp7TDSSI1 yO7tvDH3bx8P3ItrE6Q1U1hRXLks00X6G7oeYKB6MmdFN5QiNnQcWmTWGJFBJpppILYO AQwrR5c0bRTx1up5OQS7PeLRcQW11O0lk2NPtYAeEfu5QsWONUDVG1HtyNtiOSGTMzN8 KO0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=NGmzUjVS; 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 b124si3071460pgc.307.2017.06.29.00.26.30; Thu, 29 Jun 2017 00:26:30 -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=NGmzUjVS; 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 S1752483AbdF2H0D (ORCPT + 25 others); Thu, 29 Jun 2017 03:26:03 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:36710 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752017AbdF2HZI (ORCPT ); Thu, 29 Jun 2017 03:25:08 -0400 Received: by mail-lf0-f48.google.com with SMTP id h22so47513190lfk.3 for ; Thu, 29 Jun 2017 00:25:07 -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=NGmzUjVShRQqVovo/+V6Q+JhLpPPxrUERT7DdM7j4+yDj6siOdheDFjNbcR0pk1eYV p2uajtAVfyQ9fJzfCqAl8GFjvH90dA5Z+foqRzs+jDMj3CKE50fnl8V9gjw0j0PqTRhp OIcL4mgP/kTC/JLElzu5nChCbWfbh49gdBCbM= 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=XMDqb/6Sj++il5f+EZP2icQ9I5ZlXSFeWEaFQ1A2GrHNdYfQmme9r9y+Ege5tX0WwN pKBW3ZnVOBf9Wn42EQKJ/9/K/K5oxPBnv3axqoyPZ7nrvFLBpKoNjZQF3s2z5Z/+BkUK ykSyV6EeeyJbC4VZ2eOcgWgZz69lkG4LQ81QaZ7Sar5Wh5lUBIUlg++lNdUMsPjirEsC vBJMfDHJ0K7d+GY+WzXQs+gBemwqB26dy9zRav42fzuzzVc9RW0DsU9PaX4JuL7Ja2fM EgKM7fKsOEjiuItw225+/1Yv7mzpNAWjA/ASBq0vG+UsOggKRLu9pOLb4s3V6hCivxHy oPfw== X-Gm-Message-State: AKS2vOxuEcqkNXYbdEqq9rp87+0MyPfa4TL1i5AVkSp0HHedr5ZoQHeO 0jbLqcqtA6ceTEu4 X-Received: by 10.25.235.69 with SMTP id j66mr4950417lfh.141.1498721106188; Thu, 29 Jun 2017 00:25:06 -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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jun 2017 00:25:04 -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 3/3] selftests: timers: use LDLIBS instead of LDFLAGS Date: Thu, 29 Jun 2017 10:24:59 +0300 Message-Id: <20170629072459.30741-4-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 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