Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ distcleanall: cleanall

# Generate compilation database (leverages existing clang tooling setup)
compile-database:
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src compile-database-src
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src compile-database

test: check-whitespace $(JULIA_BUILD_MODE)
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/test default JULIA_BUILD_MODE=$(JULIA_BUILD_MODE)
Expand Down
24 changes: 13 additions & 11 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ endif
default: $(JULIA_BUILD_MODE) # contains either "debug" or "release"
all: debug release

release debug: %: libjulia-internal-% libjulia-codegen-% $(BUILDDIR)/compile_commands.json
release debug: %: libjulia-internal-% libjulia-codegen-% regenerate-compile_commands

$(BUILDDIR):
mkdir -p $(BUILDDIR)
Expand Down Expand Up @@ -558,6 +558,7 @@ clean:
-rm -f $(BUILDDIR)/*.dbg.obj $(BUILDDIR)/*.o $(BUILDDIR)/*.dwo $(BUILDDIR)/*.$(SHLIB_EXT) $(BUILDDIR)/*.a $(BUILDDIR)/*.h.gen
-rm -f $(BUILDDIR)/julia.expmap
-rm -f $(BUILDDIR)/julia_version.h
-rm -f $(BUILDDIR)/compile_commands.json

clean-flisp:
-$(MAKE) -C $(SRCDIR)/flisp clean BUILDDIR='$(abspath $(BUILDDIR)/flisp)'
Expand Down Expand Up @@ -654,8 +655,10 @@ clean-analyzegc:
rm -f $(build_shlibdir)/libImplicitAtomicsPlugin.$(SHLIB_EXT)

# Compilation database generation using existing clang infrastructure
$(BUILDDIR)/compile_commands.json:
@{ \
.PHONY: regenerate-compile_commands
regenerate-compile_commands:
TMPFILE=$$(mktemp -p $(BUILDDIR) compile_commands.json.XXXXXX); \
{ \
CLANG_TOOLING_C_FLAGS="$$($(JULIAHOME)/contrib/escape_json.sh clang $(CLANG_TOOLING_C_FLAGS))"; \
CLANG_TOOLING_CXX_FLAGS="$$($(JULIAHOME)/contrib/escape_json.sh clang $(CLANG_TOOLING_CXX_FLAGS))"; \
echo "["; \
Expand Down Expand Up @@ -711,18 +714,17 @@ $(BUILDDIR)/compile_commands.json:
printf '{\n "directory": "%s",\n "file": "%s",\n "arguments": [%s]\n}' "$(abspath $(SRCDIR))" "$$included_file" "$$cmd"; \
done; \
echo "]"; \
} > $@.tmp
@# This ensures we replace the file atomically, and avoid spurious rewrites
@if ! cmp -s $@.tmp $@; then \
mv $@.tmp $@; \
} > $$TMPFILE; \
if ! cmp -s $$TMPFILE $(BUILDDIR)/compile_commands.json; then \
mv $$TMPFILE $(BUILDDIR)/compile_commands.json; \
else \
rm -f $@.tmp; \
rm -f $$TMPFILE; \
fi

compile-database: $(BUILDDIR)/compile_commands.json
compile-database: regenerate-compile_commands
$(MAKE) -C $(SRCDIR)/flisp compile-database BUILDDIR='$(abspath $(BUILDDIR)/flisp)'
$(MAKE) -C $(SRCDIR)/support compile-database BUILDDIR='$(abspath $(BUILDDIR)/support)'
@echo "Compilation database created: $<"
@echo "Compilation database created for src"

.FORCE:
.PHONY: default all debug release clean cleanall clean-* libccalltest libllvmcalltest julia_flisp.boot.inc.phony analyzegc analyzesrc compile-database $(BUILDDIR)/compile_commands.json .FORCE
.PHONY: default all debug release clean cleanall clean-* libccalltest libllvmcalltest julia_flisp.boot.inc.phony analyzegc analyzesrc compile-database .FORCE
25 changes: 13 additions & 12 deletions src/flisp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ DEBUGFLAGS_COMMON += $(FLAGS_COMMON)

default: release

release: $(BUILDDIR)/$(EXENAME)$(EXE) $(BUILDDIR)/compile_commands.json
release: $(BUILDDIR)/$(EXENAME)$(EXE) regenerate-compile_commands

debug: $(BUILDDIR)/$(EXENAME)-debug$(EXE) $(BUILDDIR)/compile_commands.json
debug: $(BUILDDIR)/$(EXENAME)-debug$(EXE) regenerate-compile_commands

$(BUILDDIR):
mkdir -p $(BUILDDIR)
Expand Down Expand Up @@ -140,8 +140,10 @@ CLANG_TOOLING_C_FLAGS = $(CLANGSA_FLAGS) $(DEBUGFLAGS_CLANG) $(JCPPFLAGS_CLANG)
INCLUDED_FLISP_FILES := flisp.c:cvalues.c flisp.c:types.c flisp.c:print.c flisp.c:read.c flisp.c:equal.c

# Compilation database generation
$(BUILDDIR)/compile_commands.json:
@{ \
.PHONY: regenerate-compile_commands
regenerate-compile_commands:
TMPFILE=$$(mktemp -p $(BUILDDIR) compile_commands.json.XXXXXX); \
{ \
CLANG_TOOLING_C_FLAGS="$$($(JULIAHOME)/contrib/escape_json.sh clang $(CLANG_TOOLING_C_FLAGS))"; \
echo "["; \
first=true; \
Expand All @@ -158,16 +160,15 @@ $(BUILDDIR)/compile_commands.json:
printf '{\n "directory": "%s",\n "file": "%s",\n "arguments": [%s]\n}' "$(abspath $(SRCDIR))" "$$included_file" "$$cmd"; \
done; \
echo "]"; \
} > $@.tmp
@# This ensures we replace the file atomically, and avoid spurious rewrites
@if ! cmp -s $@.tmp $@; then \
mv $@.tmp $@; \
} > $$TMPFILE; \
if ! cmp -s $$TMPFILE $(BUILDDIR)/compile_commands.json; then \
mv $$TMPFILE $(BUILDDIR)/compile_commands.json; \
else \
rm -f $@.tmp; \
rm -f $$TMPFILE; \
fi

compile-database: $(BUILDDIR)/compile_commands.json
@echo "Compilation database created for flisp: $<"
compile-database: regenerate-compile_commands
@echo "Compilation database created for src/flisp"

clean:
rm -f $(BUILDDIR)/*.o
Expand All @@ -178,4 +179,4 @@ clean:
rm -f $(BUILDDIR)/compile_commands.json
rm -f $(BUILDDIR)/host/*

.PHONY: flisp-deps compile-database $(BUILDDIR)/compile_commands.json
.PHONY: flisp-deps compile-database
25 changes: 13 additions & 12 deletions src/support/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ $(BUILDDIR)/host/Makefile:
@printf "%s\n" 'BUILDING_HOST_TOOLS=1' >> $@
@printf "%s\n" 'include $(SRCDIR)/Makefile' >> $@

release: $(BUILDDIR)/libsupport.a $(BUILDDIR)/compile_commands.json
debug: $(BUILDDIR)/libsupport-debug.a $(BUILDDIR)/compile_commands.json
release: $(BUILDDIR)/libsupport.a regenerate-compile_commands
debug: $(BUILDDIR)/libsupport-debug.a regenerate-compile_commands

$(BUILDDIR)/libsupport.a: $(OBJS) | $(BUILDIR)
rm -rf $@
Expand All @@ -78,8 +78,10 @@ CLANG_TOOLING_C_FLAGS = $(CLANGSA_FLAGS) $(DEBUGFLAGS_CLANG) $(JCPPFLAGS_CLANG)
INCLUDED_SUPPORT_FILES := hashing.c:MurmurHash3.c

# Compilation database generation
$(BUILDDIR)/compile_commands.json:
@{ \
.PHONY: regenerate-compile_commands
regenerate-compile_commands:
TMPFILE=$$(mktemp -p $(BUILDDIR) compile_commands.json.XXXXXX); \
{ \
CLANG_TOOLING_S_FLAGS="$$($(JULIAHOME)/contrib/escape_json.sh clang $(JCPPFLAGS) $(DEBUGFLAGS))"; \
CLANG_TOOLING_C_FLAGS="$$($(JULIAHOME)/contrib/escape_json.sh clang $(JCPPFLAGS) $(JCFLAGS) $(DEBUGFLAGS))"; \
echo "["; \
Expand All @@ -103,16 +105,15 @@ $(BUILDDIR)/compile_commands.json:
printf '{\n "directory": "%s",\n "file": "%s",\n "arguments": [%s]\n}' "$(abspath $(SRCDIR))" "$$included_file" "$$cmd"; \
done; \
echo "]"; \
} > $@.tmp
@# This ensures we replace the file atomically, and avoid spurious rewrites
@if ! cmp -s $@.tmp $@; then \
mv $@.tmp $@; \
} > $$TMPFILE; \
if ! cmp -s $$TMPFILE $(BUILDDIR)/compile_commands.json; then \
mv $$TMPFILE $(BUILDDIR)/compile_commands.json; \
else \
rm -f $@.tmp; \
rm -f $$TMPFILE; \
fi

compile-database: $(BUILDDIR)/compile_commands.json
@echo "Compilation database created in support: $<"
compile-database: regenerate-compile_commands
@echo "Compilation database created for src/support"

clean:
rm -f $(BUILDDIR)/*.o
Expand All @@ -125,4 +126,4 @@ clean:
rm -f $(BUILDDIR)/compile_commands.json
rm -f $(BUILDDIR)/host/*

.PHONY: compile-database $(BUILDDIR)/compile_commands.json
.PHONY: compile-database