-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 simple cross compile mechanism for flisp/libsupport (+ dependencies) #30526
Changes from 1 commit
e315095
1e29862
ab6ae59
428d87d
6b645b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This makes some incremental progress towards #30338 in the build system. In particular, it allows compiling a separate boostrap version of flisp and its dependencies for an architecture different from the target. The immediate use case here is to build libjulia for wasm. Of course, there's still the enormous problem of building the system image itself, but luckily wasm is largely memory-layout-identical to linux32, so doing that limited bootstrap is fairly easy after this change (though the subject of a different PR). The mechanism here is to use the out-of-tree build support to create separate host/ subdirectories for the build directories of interest. These have a special make variable set that tell it to include a different Make.user (or in the absence thereof use the host defaults).
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ | |
/libjulia-release.so | ||
/libjulia-release.dylib | ||
/julia_version.h | ||
/flisp/host | ||
/support/host |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
JULIAHOME := $(abspath ../..) | ||
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) | ||
JULIAHOME := $(abspath $(SRCDIR)/../..) | ||
BUILDDIR := . | ||
include $(JULIAHOME)/Make.inc | ||
|
||
|
@@ -15,21 +16,30 @@ SRCS := flisp.c builtins.c string.c equalhash.c table.c iostream.c \ | |
julia_extensions.c | ||
|
||
LLTDIR := ../support | ||
LLTSRCDIR := $(SRCDIR)/$(LLTDIR) | ||
NATIVE_BUILDDIR := | ||
ifeq ($(BUILDING_HOST_TOOLS), 1) | ||
NATIVE_BUILDDIR := $(BUILDDIR)/.. | ||
LLT_BUILDDIR := $(BUILDDIR)/../$(LLTDIR)/host | ||
else | ||
NATIVE_BUILDDIR := $(BUILDDIR) | ||
LLT_BUILDDIR := $(BUILDDIR)/$(LLTDIR) | ||
endif | ||
|
||
HEADERS := $(wildcard *.h) $(LIBUV_INC)/uv.h $(wildcard $(LLTDIR)/*.h) | ||
|
||
OBJS := $(SRCS:%.c=$(BUILDDIR)/%.o) | ||
DOBJS := $(SRCS:%.c=$(BUILDDIR)/%.dbg.obj) | ||
LLT_release := $(BUILDDIR)/$(LLTDIR)/libsupport.a | ||
LLT_debug := $(BUILDDIR)/$(LLTDIR)/libsupport-debug.a | ||
LLT_release := $(LLT_BUILDDIR)/libsupport.a | ||
LLT_debug := $(LLT_BUILDDIR)/libsupport-debug.a | ||
LIBFILES_release := $(LLT_release) $(LIBUV) $(LIBUTF8PROC) | ||
LIBFILES_debug := $(LLT_debug) $(LIBUV) $(LIBUTF8PROC) | ||
LIBS := | ||
ifneq ($(OS),WINNT) | ||
LIBS += -lpthread | ||
endif | ||
|
||
FLAGS := -I$(LLTDIR) $(JCFLAGS) $(HFILEDIRS:%=-I%) \ | ||
FLAGS := -I$(LLTSRCDIR) $(JCFLAGS) $(HFILEDIRS:%=-I%) \ | ||
-I$(LIBUV_INC) -I$(UTF8PROC_INC) -I$(build_includedir) $(LIBDIRS:%=-L%) \ | ||
-DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS | ||
ifneq ($(USEMSVC), 1) | ||
|
@@ -52,20 +62,22 @@ debug: $(BUILDDIR)/$(EXENAME)-debug$(EXE) | |
$(BUILDDIR): | ||
mkdir -p $(BUILDDIR) | ||
|
||
$(BUILDDIR)/%.o: %.c $(HEADERS) | $(BUILDDIR) | ||
$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR) | ||
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(SHIPFLAGS) $(DISABLE_ASSERTIONS) -c $< -o $@) | ||
$(BUILDDIR)/%.dbg.obj: %.c $(HEADERS) | $(BUILDDIR) | ||
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR) | ||
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(DEBUGFLAGS) -c $< -o $@) | ||
|
||
$(BUILDDIR)/flisp.o: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c | ||
$(BUILDDIR)/flisp.dbg.obj: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c | ||
$(BUILDDIR)/flmain.o: flmain.c flisp.h | ||
$(BUILDDIR)/flmain.dbg.obj: flmain.c flisp.h | ||
FLISP_SRCS := $(flisp.c cvalues.c types.c flisp.h print.c read.c equal.c:%=$(SRCDIR)/%) | ||
FLMAIN_SRCS := $(flmain.c flisp.h:%=$(SRCDIR)/%) | ||
$(BUILDDIR)/flisp.o: $(FLISP_SRCS) | ||
$(BUILDDIR)/flisp.dbg.obj: $(FLISP_SRCS) | ||
$(BUILDDIR)/flmain.o: $(FLMAIN_SRCS) | ||
$(BUILDDIR)/flmain.dbg.obj: $(FLMAIN_SRCS) | ||
|
||
$(LLT_release): $(LLTDIR)/*.h $(LLTDIR)/*.c | ||
$(MAKE) -C $(LLTDIR) BUILDDIR='$(abspath $(BUILDDIR)/$(LLTDIR))' | ||
$(LLT_debug): $(LLTDIR)/*.h $(LLTDIR)/*.c | ||
$(MAKE) debug -C $(LLTDIR) BUILDDIR='$(abspath $(BUILDDIR)/$(LLTDIR))' | ||
$(LLT_release): $(LLTSRCDIR)/*.h $(LLTSRCDIR)/*.c | ||
$(MAKE) -C $(NATIVE_BUILDDIR)/$(LLTDIR) $(subst $(abspath $(NATIVE_BUILDDIR)/$(LLTDIR))/,,$(abspath $(LLT_release))) | ||
$(LLT_debug): $(LLTSRCDIR)/*.h $(LLTSRCDIR)/*.c | ||
$(MAKE) -C $(NATIVE_BUILDDIR)/$(LLTDIR) $(subst $(abspath $(NATIVE_BUILDDIR)/$(LLTDIR))/,,$(abspath $(LLT_debug))) | ||
|
||
$(BUILDDIR)/$(LIBTARGET)-debug.a: $(DOBJS) | $(BUILDDIR) | ||
rm -rf $@ | ||
|
@@ -87,8 +99,19 @@ $(BUILDDIR)/$(EXENAME)-debug$(EXE): $(DOBJS) $(LIBFILES_debug) $(BUILDDIR)/$(LIB | |
$(BUILDDIR)/$(EXENAME)$(EXE): $(OBJS) $(LIBFILES_release) $(BUILDDIR)/$(LIBTARGET).a $(BUILDDIR)/flmain.o | $(BUILDDIR)/flisp.boot | ||
@$(call PRINT_LINK, $(CCLD) $(SHIPFLAGS) $(JLDFLAGS) $(OBJS) $(BUILDDIR)/flmain.o -o $@ $(BUILDDIR)/$(LIBTARGET).a $(LIBFILES_release) $(LIBS) $(OSLIBS)) | ||
|
||
ifneq ($(BUILDDIR),.) | ||
$(BUILDDIR)/flisp.boot: flisp.boot | $(BUILDDIR) | ||
$(BUILDDIR)/host/Makefile: | ||
mkdir -p $(BUILDDIR)/host | ||
@# add Makefiles to the build directories for convenience (pointing back to the source location of each) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not the right file source in the comment. Is it worth trying to use the existing code to do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixing the comment. I don't think it's worth trying to deduplicate, esp since this adds a couple extra lines. |
||
@echo '# -- This file is automatically generated in julia/Makefile -- #' > $@ | ||
@echo 'BUILDDIR=$(BUILDDIR)/host' >> $@ | ||
@echo 'BUILDING_HOST_TOOLS=1' >> $@ | ||
@echo 'include $(SRCDIR)/Makefile' >> $@ | ||
|
||
$(BUILDDIR)/host/$(EXENAME): $(BUILDDIR)/host/Makefile | ||
make -C $(BUILDDIR)/host $(EXENAME) | ||
|
||
ifneq ($(BUILDDIR)$(BUILDING_HOST_TOOLS),.) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this change may have introdced a minor build error?
|
||
$(BUILDDIR)/flisp.boot: $(SRCDIR)/flisp.boot | $(BUILDDIR) | ||
cp $< $@ | ||
endif | ||
|
||
|
@@ -103,5 +126,6 @@ clean: | |
rm -f $(BUILDDIR)/*.a | ||
rm -f $(BUILDDIR)/$(EXENAME)$(EXE) | ||
rm -f $(BUILDDIR)/$(EXENAME)-debug$(EXE) | ||
rm -f $(BUILDDIR)/host/* | ||
|
||
.PHONY: flisp-deps |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
JULIAHOME := $(abspath ../..) | ||
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) | ||
JULIAHOME := $(abspath $(SRCDIR)/../..) | ||
BUILDDIR := . | ||
include $(JULIAHOME)/Make.inc | ||
|
||
|
@@ -40,24 +41,32 @@ default: release | |
$(BUILDDIR): | ||
mkdir -p $(BUILDDIR) | ||
|
||
$(BUILDDIR)/%.o: %.c $(HEADERS) | $(BUILDDIR) | ||
$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR) | ||
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(JCFLAGS) $(SHIPFLAGS) $(DISABLE_ASSERTIONS) -c $< -o $@) | ||
$(BUILDDIR)/%.dbg.obj: %.c $(HEADERS) | $(BUILDDIR) | ||
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR) | ||
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(JCFLAGS) $(DEBUGFLAGS) -c $< -o $@) | ||
ifneq ($(USEMSVC), 1) | ||
$(BUILDDIR)/%.o: %.S | $(BUILDDIR) | ||
$(BUILDDIR)/%.o: $(SRCDIR)/%.S | $(BUILDDIR) | ||
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(SHIPFLAGS) -c $< -o $@) | ||
$(BUILDDIR)/%.dbg.obj: %.S | $(BUILDDIR) | ||
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.S | $(BUILDDIR) | ||
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(DEBUGFLAGS) -c $< -o $@) | ||
else | ||
$(BUILDDIR)/%.o: %.S | $(BUILDDIR) | ||
$(BUILDDIR)/%.o: $(SRCDIR)/%.S | $(BUILDDIR) | ||
@$(call PRINT_CC, $(CPP) -P $(JCPPFLAGS) $(SHIPFLAGS) $<) | ||
@$(call PRINT_CC, $(AS) $(JCPPFLAGS) $(SHIPFLAGS) -Fo $@ -c $*.i) | ||
$(BUILDDIR)/%.dbg.obj: %.S | $(BUILDDIR) | ||
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.S | $(BUILDDIR) | ||
@$(call PRINT_CC, $(CPP) -P $(JCPPFLAGS) $(DEBUGFLAGS) $<) | ||
@$(call PRINT_CC, $(AS) $(JCPPFLAGS) $(DEBUGFLAGS) -Fo $@ -c $*.i) | ||
endif | ||
|
||
$(BUILDDIR)/host/Makefile: | ||
mkdir -p $(BUILDDIR)/host | ||
@# add Makefiles to the build directories for convenience (pointing back to the source location of each) | ||
@echo '# -- This file is automatically generated in julia/Makefile -- #' > $@ | ||
@echo 'BUILDDIR=$(BUILDDIR)/host' >> $@ | ||
@echo 'BUILDING_HOST_TOOLS=1' >> $@ | ||
@echo 'include $(SRCDIR)/Makefile' >> $@ | ||
|
||
release: $(BUILDDIR)/libsupport.a | ||
debug: $(BUILDDIR)/libsupport-debug.a | ||
|
||
|
@@ -69,6 +78,12 @@ $(BUILDDIR)/libsupport-debug.a: $(DOBJS) | $(BUILDDIR) | |
rm -rf $@ | ||
@$(call PRINT_LINK, $(AR) -rcs $@ $^) | ||
|
||
$(BUILDDIR)/host/libsupport.a: $(BUILDDIR)/host/Makefile | ||
$(MAKE) -C $(BUILDDIR)/host libsupport.a | ||
|
||
$(BUILDDIR)/host/libsupport-debug.a: $(BUILDDIR)/host/Makefile | ||
$(MAKE) -C $(BUILDDIR)/host libsupport.a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -debug |
||
|
||
clean: | ||
rm -f $(BUILDDIR)/*.o | ||
rm -f $(BUILDDIR)/*.dbg.obj | ||
|
@@ -77,3 +92,4 @@ clean: | |
rm -f $(BUILDDIR)/core* | ||
rm -f $(BUILDDIR)/libsupport.a | ||
rm -f $(BUILDDIR)/libsupport-debug.a | ||
rm -f $(BUILDDIR)/host/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn’t this slightly conflicted? The directory seems to be for native, but the subst looks for a slightly different prefix? Maybe we should add the abspath rule to the LLT Makefile, so we can remove the subst from here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's much to be gained. Keeping the targets appropriately relative seems simplest to me. This just turns the absolute path back into a relative path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, just seemed like it wasn't relative to anything obviously meaningful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's just "relative" to the LLT build dir, which seems reasonably meaningful.