Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildsystem: honour OBJDIR #481

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ LIB_OBJS += $(foreach obj,$(UTIL_OBJS),$(LIB_DIR)/util/$(obj))
EXTRA_DEPS +=
EXTRA_USER_DEPS +=

LDFLAGS+=-L$(LIBXDP_DIR)
LDFLAGS+=-L$(LIBXDP_DIR)/$(OBJDIR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies that OBJDIR is always relative to LIBXDP_DIR - I am not sure there is any such guarantee? I.e., OBJDIR could be an absolute path?

How were you setting OBJDIR, exactly, when you ran into this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I'm setting OBJDIR=output.

Will take care both both cases OBJDIR is absolute and relative.

ifeq ($(DYNAMIC_LIBXDP),1)
LDLIBS:=-lxdp $(LDLIBS)
OBJECT_LIBXDP:=$(LIBXDP_DIR)/libxdp.so.$(LIBXDP_VERSION)
else
LDLIBS:=-l:libxdp.a $(LDLIBS)
LDLIBS:=-l:$(OBJDIR)/libxdp.a $(LDLIBS)
OBJECT_LIBXDP:=$(LIBXDP_DIR)/libxdp.a
endif

Expand Down
6 changes: 3 additions & 3 deletions lib/libxdp/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ USER_C := ${USER_TARGETS:=.c}
USER_OBJ := ${USER_C:.c=.o}
BPF_OBJS := $(BPF_TARGETS:=.o)

LDFLAGS+=-L$(LIBXDP_DIR)
LDFLAGS+=-L$(LIBXDP_DIR)/$(OBJDIR)
ifeq ($(DYNAMIC_LIBXDP),1)
LDLIBS:=-lxdp $(LDLIBS)
OBJECT_LIBXDP:=$(LIBXDP_DIR)/libxdp.so.$(LIBXDP_VERSION)
else
LDLIBS:=-l:libxdp.a $(LDLIBS)
LDLIBS:=-l:$(OBJDIR)/libxdp.a $(LDLIBS)
OBJECT_LIBXDP:=$(LIBXDP_DIR)/libxdp.a
endif

Expand Down Expand Up @@ -83,4 +83,4 @@ $(BPF_OBJS): %.o: %.c $(BPF_HEADERS) $(LIBMK) $(EXTRA_DEPS)
$(QUIET_LLC)$(LLC) -march=$(BPF_TARGET) -filetype=obj -o $@ ${@:.o=.ll}

run: all
$(Q)env CC="$(CC)" CFLAGS="$(CFLAGS) $(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDLIBS="$(LDLIBS)" V=$(V) $(TEST_RUNNER) $(TEST_FILE) $(RUN_TESTS)
$(Q)env CC="$(CC)" CFLAGS="$(CFLAGS) $(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDLIBS="$(LDLIBS)" OBJDIR="$(OBJDIR)" V=$(V) $(TEST_RUNNER) $(TEST_FILE) $(RUN_TESTS)
2 changes: 1 addition & 1 deletion lib/libxdp/tests/test-libxdp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char **argv) {
return 0;
}
EOF
$CC -o $TMPDIR/libxdptest $TMPDIR/libxdptest.c $CFLAGS $CPPFLAGS -l:libxdp.a $LDLIBS 2>&1
$CC -o $TMPDIR/libxdptest $TMPDIR/libxdptest.c $CFLAGS $CPPFLAGS -l:$OBJDIR/libxdp.a $LDLIBS 2>&1
retval=$?
rm -rf "$TMPDIR"
return $retval
Expand Down
2 changes: 1 addition & 1 deletion lib/libxdp/tests/test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ usage()

if [ "$EUID" -ne "0" ]; then
if command -v sudo >/dev/null 2>&1; then
exec sudo env CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDLIBS="$LDLIBS" V=${VERBOSE_TESTS} "$0" "$@"
exec sudo env CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDLIBS="$LDLIBS" OBJDIR="$OBJDIR" V=${VERBOSE_TESTS} "$0" "$@"
else
die "Tests must be run as root"
fi
Expand Down