Skip to content

Commit

Permalink
libxdp: fix build with clang 18
Browse files Browse the repository at this point in the history
clang's lld refuses to link without architecture being passed using -m
  • Loading branch information
rbgarga committed Nov 29, 2024
1 parent 906d22a commit e4295c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ check_toolchain()
done
fi

case $(uname -m) in
aarch64) ARCH_EMULATION=aarch64linux ;;
armv7*) ARCH_EMULATION=armelf_linux_eabi ;;
i386) ARCH_EMULATION=elf_i386 ;;
*) ARCH_EMULATION=elf_x86_64 ;;
esac

echo "PKG_CONFIG:=${PKG_CONFIG}" >>$CONFIG
echo "CC:=${CC}" >>$CONFIG
echo "LD:=${LD}" >>$CONFIG
Expand All @@ -144,6 +151,7 @@ check_toolchain()
echo "ARCH_INCLUDES:=$ARCH_INCLUDES" >> $CONFIG
echo "READELF:=${READELF}" >> $CONFIG
echo "BPFTOOL:=${BPFTOOL}" >> $CONFIG
echo "ARCH_EMULATION:=${ARCH_EMULATION}" >> $CONFIG
[ -n "$BPFTOOL" ] && echo "HAVE_FEATURES+=BPFTOOL" >>"$CONFIG"
}

Expand Down
2 changes: 1 addition & 1 deletion lib/libxdp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ $(TEMPLATED_SOURCES): %.c: %.c.in Makefile
$(QUIET_M4)$(M4) $(DEFINES) $< > $@ || ( ret=$$?; rm -f $@; exit $$ret )

$(EMBEDDED_XDP_OBJS): %.embed.o: %.o
$(QUIET_GEN)$(LD) -r -b binary -o $@ -z noexecstack --format=binary $<
$(QUIET_GEN)$(LD) -r -b binary -o $@ -z noexecstack -m $(ARCH_EMULATION) --format=binary $<
$(Q)$(OBJCOPY) --rename-section .data=.rodata,alloc,load,readonly,data,contents $@

$(XDP_OBJS): %.o: %.c $(BPF_HEADERS) $(LIBMK)
Expand Down

0 comments on commit e4295c1

Please sign in to comment.