2020-10-04 12:00:33 +03:00
|
|
|
CC=clang
|
|
|
|
CXX=clang++
|
2020-09-29 09:05:29 +03:00
|
|
|
|
2020-10-09 14:47:45 +03:00
|
|
|
CURRENT_DIR=$(shell pwd)
|
|
|
|
TBB_LIBDIR=$(wildcard $(CURRENT_DIR)/oneTBB/build/linux_intel64_*_release/)
|
2021-01-18 06:54:28 +03:00
|
|
|
MALLOC_LIBDIR=$(CURRENT_DIR)/mimalloc/out/release
|
2020-10-09 14:47:45 +03:00
|
|
|
|
2021-03-15 09:35:15 +03:00
|
|
|
CPPFLAGS=-g -IoneTBB/include -IxxHash -pthread -std=c++20 \
|
2021-04-26 08:25:41 +03:00
|
|
|
-Wno-deprecated-volatile -Wno-switch \
|
2021-03-23 14:49:59 +03:00
|
|
|
-DGIT_HASH=\"$(shell git rev-parse HEAD)\"
|
2021-05-17 14:41:32 +03:00
|
|
|
LDFLAGS=-static -fuse-ld=lld -L$(TBB_LIBDIR) -Wl,-rpath=$(TBB_LIBDIR) \
|
2021-03-15 09:35:15 +03:00
|
|
|
-L$(MALLOC_LIBDIR) -Wl,-rpath=$(MALLOC_LIBDIR) \
|
2021-04-03 11:37:07 +03:00
|
|
|
-L$(CURRENT_DIR)/xxHash -Wl,-rpath=$(CURRENT_DIR)/xxHash
|
|
|
|
LIBS=-lcrypto -pthread -ltbb -lmimalloc -lz -lxxhash -ldl
|
2020-11-19 03:24:10 +03:00
|
|
|
OBJS=main.o object_file.o input_sections.o output_chunks.o mapfile.o perf.o \
|
2021-01-27 12:18:11 +03:00
|
|
|
linker_script.o archive_file.o output_file.o subprocess.o gc_sections.o \
|
2021-05-06 16:33:49 +03:00
|
|
|
icf.o symbols.o cmdline.o filepath.o glob.o passes.o tar.o compress.o \
|
2021-04-08 18:29:01 +03:00
|
|
|
arch_x86_64.o arch_i386.o
|
2020-10-02 07:28:26 +03:00
|
|
|
|
2021-03-30 17:52:02 +03:00
|
|
|
DEBUG ?= 0
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CPPFLAGS += -O0
|
|
|
|
else
|
|
|
|
CPPFLAGS += -O2
|
|
|
|
endif
|
|
|
|
|
2021-04-05 16:51:15 +03:00
|
|
|
LTO ?= 0
|
|
|
|
ifeq ($(LTO), 1)
|
2021-04-07 12:52:38 +03:00
|
|
|
CPPFLAGS += -flto -O3
|
|
|
|
LDFLAGS += -flto
|
2021-04-05 16:51:15 +03:00
|
|
|
endif
|
|
|
|
|
2021-04-07 12:52:38 +03:00
|
|
|
ASAN ?= 0
|
|
|
|
ifeq ($(ASAN), 1)
|
2021-04-07 09:38:31 +03:00
|
|
|
CPPFLAGS += -fsanitize=address
|
2021-04-07 12:52:38 +03:00
|
|
|
LDFLAGS += -fsanitize=address
|
|
|
|
endif
|
|
|
|
|
|
|
|
TSAN ?= 0
|
|
|
|
ifeq ($(TSAN), 1)
|
|
|
|
CPPFLAGS += -fsanitize=thread
|
|
|
|
LDFLAGS += -fsanitize=thread
|
2021-04-07 09:38:31 +03:00
|
|
|
endif
|
|
|
|
|
2021-03-25 10:03:23 +03:00
|
|
|
all: mold mold-wrapper.so
|
|
|
|
|
2020-10-20 08:54:35 +03:00
|
|
|
mold: $(OBJS)
|
2020-11-30 11:06:52 +03:00
|
|
|
$(CXX) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS) $(LIBS)
|
2021-03-25 10:03:23 +03:00
|
|
|
|
|
|
|
mold-wrapper.so: mold-wrapper.c Makefile
|
|
|
|
cc -fPIC -shared -o $@ $< -ldl
|
2020-10-02 07:28:26 +03:00
|
|
|
|
2021-01-09 08:53:26 +03:00
|
|
|
$(OBJS): mold.h elf.h Makefile
|
2020-10-08 11:01:54 +03:00
|
|
|
|
2021-01-15 05:08:57 +03:00
|
|
|
submodules:
|
2020-09-29 09:05:29 +03:00
|
|
|
$(MAKE) -C oneTBB
|
2021-04-03 11:37:07 +03:00
|
|
|
$(MAKE) -C oneTBB extra_inc=big_iron.inc
|
2021-01-18 06:54:28 +03:00
|
|
|
mkdir -p mimalloc/out/release
|
2021-04-03 11:37:07 +03:00
|
|
|
(cd mimalloc/out/release; CFLAGS=-DMI_USE_ENVIRON=0 cmake ../..)
|
2021-01-18 06:54:28 +03:00
|
|
|
$(MAKE) -C mimalloc/out/release
|
2021-03-15 09:35:15 +03:00
|
|
|
$(MAKE) -C xxHash
|
2020-09-29 09:05:29 +03:00
|
|
|
|
2021-03-31 18:52:10 +03:00
|
|
|
test: all
|
2021-03-01 10:28:16 +03:00
|
|
|
for i in test/*.sh; do $$i || exit 1; done
|
2020-09-29 09:05:29 +03:00
|
|
|
|
2021-05-14 14:41:21 +03:00
|
|
|
install: all
|
2021-05-17 09:39:35 +03:00
|
|
|
install -m 755 mold /usr/bin
|
|
|
|
install -m 755 -d /usr/lib/mold
|
2021-05-14 15:55:49 +03:00
|
|
|
install -m 644 mold-wrapper.so /usr/lib/mold
|
2021-05-17 09:39:35 +03:00
|
|
|
install -m 644 docs/mold.1 /usr/share/man/man1
|
2021-05-17 15:09:07 +03:00
|
|
|
rm -f /usr/share/man/man1/mold.1.gz
|
2021-05-17 09:39:35 +03:00
|
|
|
gzip -9 /usr/share/man/man1/mold.1
|
2021-05-14 14:41:21 +03:00
|
|
|
|
2020-09-29 09:05:29 +03:00
|
|
|
clean:
|
2021-03-25 10:03:23 +03:00
|
|
|
rm -f *.o *~ mold mold-wrapper.so
|
2020-09-29 09:05:29 +03:00
|
|
|
|
2021-03-25 10:03:23 +03:00
|
|
|
.PHONY: all intel_tbb test clean
|