mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
mjit headers for universal binary
* common.mk (MJIT_HEADER, MJIT_MIN_HEADER): added hook to separate intermediate headers per archs. * defs/gmake.mk: build mjit headers per -arch options, and then merge the headers with `#ifdef`s. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7112c6a1c1
commit
88035b9979
6 changed files with 38 additions and 6 deletions
|
@ -71,6 +71,8 @@ cppflags = @cppflags@
|
|||
XCFLAGS = @XCFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@ $(INCFLAGS) -DMJIT_HEADER_BUILD_DIR=\""$(EXTOUT)/include/$(arch)"\" -DLIBRUBYARG_SHARED=\""$(LIBRUBYARG_SHARED)"\" -DMJIT_HEADER_INSTALL_DIR=\""include/$(RUBY_BASE_NAME)-$(ruby_version)/$(arch)"\"
|
||||
MJIT_HEADER_FLAGS = @MJIT_HEADER_FLAGS@
|
||||
MJIT_HEADER_SUFFIX =
|
||||
MJIT_HEADER_ARCH =
|
||||
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
|
||||
EXTLDFLAGS = @EXTLDFLAGS@
|
||||
XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
|
||||
|
|
12
common.mk
12
common.mk
|
@ -59,6 +59,7 @@ ENC_TRANS_D = $(TIMESTAMPDIR)/.enc-trans.time
|
|||
RDOCOUT = $(EXTOUT)/rdoc
|
||||
HTMLOUT = $(EXTOUT)/html
|
||||
CAPIOUT = doc/capi
|
||||
MJIT_HEADER = rb_mjit_header.h
|
||||
MJIT_MIN_HEADER = $(EXTOUT)/include/$(arch)/rb_mjit_min_header-$(RUBY_PROGRAM_VERSION).h
|
||||
|
||||
INITOBJS = dmyext.$(OBJEXT) dmyenc.$(OBJEXT)
|
||||
|
@ -195,14 +196,15 @@ main: $(SHOWFLAGS) exts $(ENCSTATIC:static=lib)encs $(MJIT_MIN_HEADER)
|
|||
.PHONY: mjit-headers
|
||||
mjit-headers: $(MJIT_MIN_HEADER)
|
||||
|
||||
rb_mjit_header.h: PHONY probes.h
|
||||
$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: PHONY probes.h
|
||||
$(ECHO) building $@
|
||||
$(Q) $(CPP) $(MJIT_HEADER_FLAGS) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -DMJIT_HEADER $(srcdir)/vm.c $(CPPOUTFLAG)vm.new
|
||||
$(Q) $(IFCHANGE) $@ vm.new
|
||||
$(Q) $(CPP) $(MJIT_HEADER_FLAGS) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -DMJIT_HEADER $(srcdir)/vm.c $(CPPOUTFLAG)$(@F).new
|
||||
$(Q) $(IFCHANGE) $@ $(@F).new
|
||||
|
||||
$(MJIT_MIN_HEADER): rb_mjit_header.h $(srcdir)/tool/transform_mjit_header.rb $(PREP)
|
||||
$(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: $(srcdir)/tool/transform_mjit_header.rb $(PREP)
|
||||
$(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: $(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h
|
||||
$(ECHO) building $@
|
||||
$(MINIRUBY) $(srcdir)/tool/transform_mjit_header.rb "$(CC) $(ARCH_FLAG)" rb_mjit_header.h $@
|
||||
$(MINIRUBY) $(srcdir)/tool/transform_mjit_header.rb "$(CC) $(ARCH_FLAG)" $(MJIT_HEADER:.h=)$(MJIT_HEADER_ARCH).h $@
|
||||
|
||||
.PHONY: showflags
|
||||
exts enc trans: $(SHOWFLAGS)
|
||||
|
|
|
@ -48,7 +48,7 @@ define archcmd
|
|||
%.i: %.$(1).i
|
||||
endef
|
||||
|
||||
$(foreach arch,$(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG))),\
|
||||
$(foreach arch,$(arch_flags),\
|
||||
$(eval $(call archcmd,$(patsubst -arch=%,%,$(value arch)),$(patsubst -arch=%,-arch %,$(value arch)))))
|
||||
endif
|
||||
|
||||
|
@ -144,3 +144,23 @@ commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS
|
|||
ifeq ($(words $(filter update-gems extract-gems,$(MAKECMDGOALS))),2)
|
||||
extract-gems: update-gems
|
||||
endif
|
||||
|
||||
ifeq ($(filter 0 1,$(words $(arch_flags))),)
|
||||
$(foreach x,$(patsubst -arch=%,%,$(arch_flags)), \
|
||||
$(eval $$(MJIT_HEADER:.h=)-$(value x).h \
|
||||
$$(MJIT_MIN_HEADER:.h=)-$(value x).h \
|
||||
: ARCH_FLAG := -arch $(value x)))
|
||||
|
||||
mjit_min_headers := $(patsubst -arch=%,$(MJIT_MIN_HEADER:.h=-%.h),$(arch_flags))
|
||||
$(MJIT_MIN_HEADER): $(mjit_min_headers)
|
||||
@ set -e; set $(patsubst -arch=%,%,$(arch_flags)); \
|
||||
cd $(@D); h=$(@F:.h=); set -x; \
|
||||
cp $$h-$$1.h $$h.h.new; shift; \
|
||||
for arch; do \
|
||||
mv $$h.h.new $$h.h.tmp; \
|
||||
diff -B -D__$${arch}__ $$h.h.tmp $$h-$$arch.h > $$h.h.new || :; \
|
||||
done
|
||||
$(RM) $@.tmp
|
||||
$(IFCHANGE) $@ $@.new
|
||||
|
||||
endif
|
||||
|
|
5
defs/universal.mk
Normal file
5
defs/universal.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
arch_flags := $(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG)))
|
||||
ifeq ($(filter 0 1,$(words $(arch_flags))),)
|
||||
override MJIT_HEADER_SUFFIX = -%
|
||||
override MJIT_HEADER_ARCH = -$(word 2,$(ARCH_FLAG))
|
||||
endif
|
|
@ -1,4 +1,5 @@
|
|||
include Makefile
|
||||
include $(srcdir)/defs/universal.mk
|
||||
-include uncommon.mk
|
||||
include $(srcdir)/defs/gmake.mk
|
||||
|
||||
|
|
|
@ -287,6 +287,8 @@ LDSHARED_2 = @if exist $(@).manifest @$(RM) $(@:/=\).manifest
|
|||
!endif
|
||||
CPPFLAGS = $(DEFS) $(ARCHDEFS) $(CPPFLAGS) -DMJIT_HEADER_BUILD_DIR=\""$(EXTOUT)/include/$(arch)"\" -DLIBRUBYARG_SHARED=\""$(LIBRUBYARG_SHARED)"\" -DMJIT_HEADER_INSTALL_DIR=\""include/$(RUBY_BASE_NAME)-$(ruby_version)/$(arch)"\"
|
||||
MJIT_HEADER_FLAGS = -P
|
||||
MJIT_HEADER_SUFFIX =
|
||||
MJIT_HEADER_ARCH =
|
||||
|
||||
DLDFLAGS = $(LDFLAGS) -dll
|
||||
SOLIBS =
|
||||
|
|
Loading…
Reference in a new issue