Skip to content

Commit

Permalink
Use LLVM/clang toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
djphoenix committed Apr 20, 2017
1 parent d0b7f98 commit f50e784
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions makefiles/common.mk
@@ -1,9 +1,8 @@
CFLAGS := -g -m64 -mno-sse
CFLAGS += -nostdlib -std=c++11
CFLAGS += -O2 -Os -Wall -Wextra -Werror
CFLAGS += -Wsuggest-attribute=format -Wsuggest-attribute=pure
CFLAGS += -Wsuggest-attribute=const -Wsuggest-attribute=noreturn
CFLAGS += -Wcast-qual -Wcast-align -Wuseless-cast -Winline
CFLAGS += -Wproperty-attribute-mismatch
CFLAGS += -Wcast-qual -Wcast-align -Winline
CFLAGS += -ffreestanding -fno-exceptions -fno-rtti -fshort-wchar
CFLAGS += -ffunction-sections -fdata-sections -fpic -fpie

Expand Down
2 changes: 1 addition & 1 deletion makefiles/defs.mk
Expand Up @@ -32,7 +32,7 @@ KERNOBJS += $(OLIBDIR)/$$(LIBNAME_$(1)).a
$(OLIBDIR)/$$(LIBNAME_$(1)).a: $$(OBJS_$(1))
@ mkdir -p $$(dir $$@)
$(QECHO) AR $$(subst $(OLIBDIR)/,,$$@)
$(Q) $(AR) -cru $$@ $$?
$(Q) $(AR) cru $$@ $$?
endef

define LIBRULES
Expand Down
2 changes: 1 addition & 1 deletion makefiles/rules.mk
Expand Up @@ -36,7 +36,7 @@ $(OOBJDIR)/%.o: $(SRCDIR)/%.s
$(BIN).elf: $(KERNOBJS) $(OOBJDIR)/modules-linked.o
@ mkdir -p $(dir $@)
$(QECHO) LD $(subst $(OIMGDIR)/,,$@)
$(Q) $(LD) $(LDFLAGS) -Tld/system.ld -o $@ -Wl,--start-group $^ -Wl,--end-group
$(Q) $(LD) $(LDFLAGS) -Tld/system.ld -o $@ $^

$(BIN).elf.strip: $(BIN).elf
$(Q) $(STRIP) -o $@ $^
Expand Down
9 changes: 6 additions & 3 deletions makefiles/toolchain.mk
@@ -1,12 +1,15 @@
PREFIX=x86_64-linux-gnu-
NPROC=1
CLANG_BIN=$(dir $(shell which clang-5.0))
CLANG_BIN ?= /usr/bin

ifeq ($(OS),Windows_NT)
PREFIX=x86_64-w64-mingw32-
else
UNAME_S=$(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PREFIX=x86_64-elf-
CLANG_BIN=/usr/local/opt/llvm/bin
NPROC=$(shell sysctl -n hw.ncpu)
else
NPROC=$(shell grep -c ^processor /proc/cpuinfo)
Expand All @@ -25,9 +28,9 @@ else
QECHO=@ echo
endif

CC=$(PREFIX)g++
LD=$(PREFIX)g++
AR=$(PREFIX)ar
CC=$(CLANG_BIN)/clang-5.0 --target=x86_64-none-elf
LD=$(firstword $(wildcard $(CLANG_BIN)/ld.lld-5.0 $(CLANG_BIN)/ld.lld))
AR=$(firstword $(wildcard $(CLANG_BIN)/llvm-ar-5.0 $(CLANG_BIN)/llvm-ar))
OBJCOPY=$(PREFIX)objcopy
STRIP=$(PREFIX)strip

Expand Down

0 comments on commit f50e784

Please sign in to comment.