ruby-changes:50127
From: nobu <ko1@a...>
Date: Tue, 6 Feb 2018 12:19:47 +0900 (JST)
Subject: [ruby-changes:50127] nobu:r62245 (trunk): mjit headers for universal binary
nobu 2018-02-06 12:19:42 +0900 (Tue, 06 Feb 2018) New Revision: 62245 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62245 Log: 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. Added files: trunk/defs/universal.mk Modified files: trunk/Makefile.in trunk/common.mk trunk/defs/gmake.mk trunk/template/GNUmakefile.in trunk/win32/Makefile.sub Index: template/GNUmakefile.in =================================================================== --- template/GNUmakefile.in (revision 62244) +++ template/GNUmakefile.in (revision 62245) @@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/template/GNUmakefile.in#L1 include Makefile +include $(srcdir)/defs/universal.mk -include uncommon.mk include $(srcdir)/defs/gmake.mk Index: Makefile.in =================================================================== --- Makefile.in (revision 62244) +++ Makefile.in (revision 62245) @@ -71,6 +71,8 @@ cppflags = @cppflags@ https://github.com/ruby/ruby/blob/trunk/Makefile.in#L71 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) Index: common.mk =================================================================== --- common.mk (revision 62244) +++ common.mk (revision 62245) @@ -59,6 +59,7 @@ ENC_TRANS_D = $(TIMESTAMPDIR)/.enc-tra https://github.com/ruby/ruby/blob/trunk/common.mk#L59 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:stat https://github.com/ruby/ruby/blob/trunk/common.mk#L196 .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) Index: defs/gmake.mk =================================================================== --- defs/gmake.mk (revision 62244) +++ defs/gmake.mk (revision 62245) @@ -48,7 +48,7 @@ define archcmd https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L48 %.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,$(MAKECMDGO https://github.com/ruby/ruby/blob/trunk/defs/gmake.mk#L144 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 Index: defs/universal.mk =================================================================== --- defs/universal.mk (nonexistent) +++ defs/universal.mk (revision 62245) @@ -0,0 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/defs/universal.mk#L1 +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 Property changes on: defs/universal.mk ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: win32/Makefile.sub =================================================================== --- win32/Makefile.sub (revision 62244) +++ win32/Makefile.sub (revision 62245) @@ -287,6 +287,8 @@ LDSHARED_2 = @if exist $(@).manifest @$( https://github.com/ruby/ruby/blob/trunk/win32/Makefile.sub#L287 !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 = -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/