Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752092AbdF2HZK (ORCPT ); Thu, 29 Jun 2017 03:25:10 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:33453 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751729AbdF2HZC (ORCPT ); Thu, 29 Jun 2017 03:25:02 -0400 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 0/3] selftests: fixes for undefined reference (LDFLAGS -> LDLIBS) Date: Thu, 29 Jun 2017 10:24:56 +0300 Message-Id: <20170629072459.30741-1-fathi.boudra@linaro.org> X-Mailer: git-send-email 2.13.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1500 Lines: 49 This serie fixes undefined reference errors caused by the usage of LDFLAGS instead of LDLIBS. The issue is 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. Changes in v2: * address SeongJae Park comment: instead of replacing LDFLAGS, append LDLIBS in the right order. Fathi Boudra (3): selftests: net: use LDLIBS instead of LDFLAGS selftests: seccomp: use LDLIBS instead of LDFLAGS selftests: timers: use LDLIBS instead of LDFLAGS tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/seccomp/Makefile | 4 ++-- tools/testing/selftests/timers/Makefile | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) -- 2.13.0