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

add clang/lld support #478

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ jobs:
CROSS_COMPILE: ""
<<: *do_steps

clang-lld-x86_64:
docker:
- image: lkldocker/circleci-clang-x86_64:0.1
environment:
CROSS_COMPILE: ""
MKARG: "CC=clang LD=ld.lld dpdk=no"
<<: *do_steps

clang-lld-i386:
docker:
- image: lkldocker/circleci-clang-i386:0.1
environment:
CROSS_COMPILE: ""
MKARG: "CC=clang LD=ld.lld"
<<: *do_steps

mingw32:
docker:
- image: lkldocker/circleci-mingw:0.6
Expand Down Expand Up @@ -173,6 +189,8 @@ workflows:
- freebsd11_x86_64
- checkpatch
- i386
- clang-lld-x86_64
- clang-lld-i386
nightly:
triggers:
- schedule:
Expand Down
25 changes: 24 additions & 1 deletion arch/lkl/auto.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
export OUTPUT_FORMAT=$(shell $(LD) -r -print-output-format)
ifneq ($(shell $(LD) --version 2>&1 | head -n 1 | grep LLD),)
ifneq (,$(shell $(CC) --version 2>&1 | grep clang | head -n 1))
TRIPLE=$(shell $(CC) --version 2>&1 | grep Target | cut -d " " -f2)
else
TRIPLE=$(shell $(CC) -dumpmachine)
endif
TRIPLE_ARCH=$(shell echo $(TRIPLE) | cut -d - -f1)
TRIPLE_VENDOR=$(shell echo $(TRIPLE) | cut -d - -f2)
TRIPLE_OS=$(shell echo $(TRIPLE) | cut -d - -f3)
ifneq (,$(filter linux,$(TRIPLE_VENDOR)))
TRIPLE_OS=$(TRIPLE_VENDOR)
endif
ifneq (,$(filter x86_64,$(TRIPLE_ARCH)))
ifneq (,$(filter linux,$(TRIPLE_OS)))
export OUTPUT_FORMAT=elf64-x86-64
endif
else ifneq (,$(filter i386 i686,$(TRIPLE_ARCH)))
ifneq (,$(filter linux,$(TRIPLE_OS)))
export OUTPUT_FORMAT=elf32-i386
endif
endif
else
export OUTPUT_FORMAT=$(shell $(LD) -r -print-output-format)
endif
export EXEC_FORMAT=$(shell echo $(OUTPUT_FORMAT) | cut -d - -f1)
18 changes: 17 additions & 1 deletion tools/lkl/Makefile.autoconf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ define set_autoconf_var
export LKL_HOST_CONFIG_$(1)=$(2)
endef

define set_output_format
$(eval output_format=$(shell $(LD) -r -print-output-format))
$(if $(output_format),,$(if $(shell $(CC) --version 2>&1 | grep clang),$(eval \
triple=$(shell $(CC) --version 2>&1 | grep Target | cut -d " " -f2)),$(eval \
triple=$(shell $(CC) -dumpmachine))))
$(eval arch=$(shell echo $(triple) | cut -d - -f1))
$(eval vendor=$(shell echo $(triple) | cut -d - -f2))
$(eval os=$(shell echo $(triple) | cut -d - -f3))
$(if $(filter linux,$(vendor)),$(eval os=$(vendor)))
$(if $(filter x86_64,$(arch)),$(if $(filter linux,$(os)),$(eval \
output_format=elf64-x86-64)))
$(if $(filter i386 i686,$(arch)),$(if $(filter linux,$(os)),$(eval \
output_format=elf32-i386)))
$(1) := $$(output_format)
endef

define find_include
$(eval include_paths=$(shell $(CC) -E -Wp,-v -xc /dev/null 2>&1 | grep '^ '))
$(foreach f, $(include_paths), $(wildcard $(f)/$(1)))
Expand Down Expand Up @@ -98,7 +114,7 @@ define do_autoconf
export AR := $(CROSS_COMPILE)ar
$(eval LD := $(CROSS_COMPILE)ld)
$(eval CC := $(CROSS_COMPILE)gcc)
$(eval LD_FMT := $(shell $(LD) -r -print-output-format))
$(eval $(call set_output_format,LD_FMT))
$(eval EXEC_FMT := $(shell echo $(LD_FMT) | cut -d "-" -f1))
$(if $(filter $(EXEC_FMT),$(POSIX_HOSTS)),$(call posix_host,$(LD_FMT)))
$(if $(filter $(EXEC_FMT),$(NT_HOSTS)),$(call nt_host,$(LD_FMT)))
Expand Down